2015-03-07 12:51:28 +01:00
|
|
|
package ellpeck.actuallyadditions.blocks;
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-03-07 12:51:28 +01:00
|
|
|
import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks;
|
2015-06-18 13:14:57 +02:00
|
|
|
import ellpeck.actuallyadditions.util.BlockUtil;
|
2015-04-06 15:51:59 +02:00
|
|
|
import ellpeck.actuallyadditions.util.INameableItem;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-02-17 16:15:16 +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;
|
2015-06-18 13:14:57 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-03-07 02:23:31 +01:00
|
|
|
import net.minecraft.item.EnumRarity;
|
2015-02-17 16:15:16 +01:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-04 05:20:19 +02:00
|
|
|
public class BlockMisc extends Block implements INameableItem{
|
2015-02-17 16:15:16 +01:00
|
|
|
|
|
|
|
public static final TheMiscBlocks[] allMiscBlocks = TheMiscBlocks.values();
|
|
|
|
public IIcon[] textures = new IIcon[allMiscBlocks.length];
|
|
|
|
|
|
|
|
public BlockMisc(){
|
|
|
|
super(Material.rock);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.setHardness(1.5F);
|
|
|
|
this.setHarvestLevel("pickaxe", 1);
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List list){
|
2015-03-07 12:51:28 +01:00
|
|
|
for (int j = 0; j < allMiscBlocks.length; j++){
|
2015-02-17 16:15:16 +01:00
|
|
|
list.add(new ItemStack(item, 1, j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public int damageDropped(int meta){
|
2015-03-07 12:51:28 +01:00
|
|
|
return meta;
|
2015-02-20 22:45:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public IIcon getIcon(int side, int metadata){
|
2015-06-12 19:12:06 +02:00
|
|
|
return metadata >= textures.length ? null : textures[metadata];
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
|
|
|
for(int i = 0; i < textures.length; i++){
|
2015-03-29 15:29:05 +02:00
|
|
|
textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + allMiscBlocks[i].getName());
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
|
|
|
public String getName(){
|
|
|
|
return "blockMisc";
|
|
|
|
}
|
|
|
|
|
2015-04-04 05:20:19 +02:00
|
|
|
@Override
|
|
|
|
public String getOredictName(){
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
public static class TheItemBlock extends ItemBlock{
|
2015-02-17 16:15:16 +01:00
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
private Block theBlock;
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
public TheItemBlock(Block block){
|
2015-02-17 16:15:16 +01:00
|
|
|
super(block);
|
2015-02-20 22:45:33 +01:00
|
|
|
this.theBlock = block;
|
2015-02-17 16:15:16 +01:00
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
2015-06-12 19:12:06 +02:00
|
|
|
return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity;
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2015-06-12 19:12:06 +02:00
|
|
|
return this.getUnlocalizedName() + (stack.getItemDamage() >= allMiscBlocks.length ? " ERROR!" : allMiscBlocks[stack.getItemDamage()].getName());
|
2015-02-17 16:15:16 +01:00
|
|
|
}
|
|
|
|
|
2015-06-18 13:14:57 +02:00
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
|
|
|
BlockUtil.addInformation(theBlock, list, 1, allMiscBlocks[stack.getItemDamage()].getName());
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public int getMetadata(int damage){
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|