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;
|
|
|
|
import ellpeck.actuallyadditions.util.IName;
|
|
|
|
import ellpeck.actuallyadditions.util.Util;
|
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;
|
|
|
|
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 net.minecraft.util.StatCollector;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
public class BlockMisc extends Block implements IName{
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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){
|
|
|
|
return textures[metadata];
|
|
|
|
}
|
|
|
|
|
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-02-20 22:45:33 +01:00
|
|
|
textures[i] = iconReg.registerIcon(Util.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-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){
|
|
|
|
return allMiscBlocks[stack.getItemDamage()].rarity;
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
|
|
|
return this.getUnlocalizedName() + allMiscBlocks[stack.getItemDamage()].getName();
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
2015-02-20 22:45:33 +01:00
|
|
|
if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + Util.MOD_ID_LOWER + "." + ((IName)theBlock).getName() + allMiscBlocks[stack.getItemDamage()].getName() + ".desc"));
|
2015-02-17 16:15:16 +01:00
|
|
|
else list.add(Util.shiftForInfo());
|
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public int getMetadata(int damage){
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|