2015-11-09 18:05:52 +01:00
|
|
|
/*
|
|
|
|
* This file ("BlockCrystal.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.blocks;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-12-03 20:15:07 +01:00
|
|
|
import ellpeck.actuallyadditions.blocks.base.BlockBase;
|
|
|
|
import ellpeck.actuallyadditions.blocks.base.ItemBlockBase;
|
2015-11-09 18:05:52 +01:00
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheCrystals;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-11-23 19:06:07 +01:00
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-11-09 18:05:52 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public class BlockCrystal extends BlockBase{
|
2015-11-09 18:05:52 +01:00
|
|
|
|
|
|
|
public static final TheCrystals[] allCrystals = TheCrystals.values();
|
|
|
|
|
2015-12-03 20:15:07 +01:00
|
|
|
public BlockCrystal(String name){
|
|
|
|
super(Material.rock, name);
|
2015-11-09 18:05:52 +01:00
|
|
|
this.setHardness(1.5F);
|
|
|
|
this.setResistance(10.0F);
|
|
|
|
this.setHarvestLevel("pickaxe", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IIcon getIcon(int side, int metadata){
|
|
|
|
return this.blockIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-01 19:48:09 +01:00
|
|
|
public int damageDropped(int meta){
|
|
|
|
return meta;
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-01 19:48:09 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public int getRenderColor(int meta){
|
|
|
|
return meta >= allCrystals.length ? super.getRenderColor(meta) : allCrystals[meta].color;
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public int colorMultiplier(IBlockAccess world, int x, int y, int z){
|
|
|
|
return this.getRenderColor(world.getBlockMetadata(x, y, z));
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List list){
|
|
|
|
for(int j = 0; j < allCrystals.length; j++){
|
|
|
|
list.add(new ItemStack(item, 1, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
2015-12-03 20:15:07 +01:00
|
|
|
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-19 10:30:39 +01:00
|
|
|
public Class<? extends ItemBlockBase> getItemBlock(){
|
|
|
|
return TheItemBlock.class;
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-19 10:30:39 +01:00
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
return stack.getItemDamage() >= allCrystals.length ? EnumRarity.common : allCrystals[stack.getItemDamage()].rarity;
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class TheItemBlock extends ItemBlockBase{
|
|
|
|
|
|
|
|
public TheItemBlock(Block block){
|
|
|
|
super(block);
|
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2015-11-23 19:06:07 +01:00
|
|
|
return stack.getItemDamage() >= allCrystals.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+allCrystals[stack.getItemDamage()].name;
|
2015-11-09 18:05:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|