From ff4b3d697a65940b812d4d8e6977ed180709a3c0 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Sun, 15 Dec 2013 22:17:32 +0200 Subject: Added Mold stuff --- common/darkknight/jewelrycraft/item/ItemMolds.java | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 common/darkknight/jewelrycraft/item/ItemMolds.java (limited to 'common/darkknight/jewelrycraft/item/ItemMolds.java') diff --git a/common/darkknight/jewelrycraft/item/ItemMolds.java b/common/darkknight/jewelrycraft/item/ItemMolds.java new file mode 100644 index 0000000..9beb03a --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemMolds.java @@ -0,0 +1,75 @@ +package darkknight.jewelrycraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.MathHelper; + +public class ItemMolds extends Item +{ + /** List of molds color names */ + public static final String[] moldsItemNames = new String[] {"ingot", "ring", "necklace"}; + @SideOnly(Side.CLIENT) + private Icon[] moldsIcons; + + public ItemMolds(int par1) + { + super(par1); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setMaxStackSize(1); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @SideOnly(Side.CLIENT) + + /** + * Gets an icon index based on an item's damage value + */ + public Icon getIconFromDamage(int par1) + { + int j = MathHelper.clamp_int(par1, 0, 2); + return this.moldsIcons[j]; + } + + /** + * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have + * different names based on their damage or NBT. + */ + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 2); + return super.getUnlocalizedName() + "." + moldsItemNames[i]; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @SideOnly(Side.CLIENT) + + /** + * returns a list of items with the same ID, but different meta (eg: molds returns 16 items) + */ + public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int j = 0; j < 3; ++j) + { + par3List.add(new ItemStack(par1, 1, j)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + this.moldsIcons = new Icon[moldsItemNames.length]; + + for (int i = 0; i < moldsItemNames.length; ++i) + { + this.moldsIcons[i] = par1IconRegister.registerIcon("jewelrycraft:" + moldsItemNames[i] + this.getIconString()); + } + } +} -- cgit v1.2.3