ActuallyAdditions/src/main/java/ellpeck/someprettyrandomstuff/items/ItemMisc.java

59 lines
2 KiB
Java
Raw Normal View History

2015-01-30 20:16:32 +01:00
package ellpeck.someprettyrandomstuff.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2015-01-30 20:16:32 +01:00
import ellpeck.someprettyrandomstuff.creative.CreativeTab;
import ellpeck.someprettyrandomstuff.items.metalists.TheMiscItems;
import ellpeck.someprettyrandomstuff.util.Util;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import java.util.List;
public class ItemMisc extends Item{
2015-01-30 20:16:32 +01:00
private final TheMiscItems[] allMiscItems = TheMiscItems.values();
public ItemMisc(){
this.setUnlocalizedName("itemMisc");
2015-01-30 20:16:32 +01:00
this.setHasSubtypes(true);
2014-12-03 22:33:46 +01:00
this.setCreativeTab(CreativeTab.instance);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
2015-01-30 20:16:32 +01:00
for(TheMiscItems theMisc : allMiscItems){
theMisc.theIcon = iconReg.registerIcon(Util.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + theMisc.name);
}
}
2015-01-30 20:16:32 +01:00
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1){
return allMiscItems[par1].theIcon;
}
2015-01-30 20:16:32 +01:00
@SuppressWarnings("all")
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list){
for (int j = 0; j < allMiscItems.length; j++){
list.add(new ItemStack(this, 1, j));
}
}
2015-01-30 20:16:32 +01:00
public String getUnlocalizedName(ItemStack stack){
return this.getUnlocalizedName() + allMiscItems[stack.getItemDamage()].name;
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){
if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName(stack).substring(5) + ".desc"));
else list.add(Util.shiftForInfo());
}
}