diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-15 22:17:32 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-15 22:17:32 +0200 |
| commit | ff4b3d697a65940b812d4d8e6977ed180709a3c0 (patch) | |
| tree | 7dce2a4600d092ae174627a9cbe4963888d82dd0 /common/darkknight/jewelrycraft/item/ItemMolds.java | |
| parent | 3e7036bf39c640b9d0dd94115f8b1f7947d26f71 (diff) | |
Added Mold stuff
Diffstat (limited to 'common/darkknight/jewelrycraft/item/ItemMolds.java')
| -rw-r--r-- | common/darkknight/jewelrycraft/item/ItemMolds.java | 75 |
1 files changed, 75 insertions, 0 deletions
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()); + } + } +} |
