From 26d28c9b93133a6cfc5d2544c662e9d77955b6f5 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Mon, 16 Dec 2013 16:34:17 +0200 Subject: Rings and molder --- common/darkknight/jewelrycraft/item/ItemList.java | 2 + common/darkknight/jewelrycraft/item/ItemMolds.java | 9 ++--- common/darkknight/jewelrycraft/item/ItemRing.java | 46 ++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 common/darkknight/jewelrycraft/item/ItemRing.java (limited to 'common/darkknight/jewelrycraft/item') diff --git a/common/darkknight/jewelrycraft/item/ItemList.java b/common/darkknight/jewelrycraft/item/ItemList.java index 261fa9e..5418c52 100644 --- a/common/darkknight/jewelrycraft/item/ItemList.java +++ b/common/darkknight/jewelrycraft/item/ItemList.java @@ -10,6 +10,7 @@ public class ItemList public static Item thiefGloves; public static Item shadowIngot; public static Item molds; + public static Item ring; private static boolean isInitialized = false; @@ -20,6 +21,7 @@ public class ItemList thiefGloves = new ItemThiefGloves(ConfigHandler.idThiefGloves).setUnlocalizedName("jewelrycraft.thiefGloves").setCreativeTab(JewelrycraftMod.jewelrycraft); shadowIngot = new ItemBase(ConfigHandler.idShadowIngot).setUnlocalizedName("jewelrycraft.ingotShadow").setCreativeTab(JewelrycraftMod.jewelrycraft); molds = new ItemMolds(ConfigHandler.idMolds).setUnlocalizedName("jewelrycraft.mold").setTextureName("Mold").setCreativeTab(JewelrycraftMod.jewelrycraft); + ring = new ItemRing(ConfigHandler.idRing).setUnlocalizedName("jewelrycraft.ring").setCreativeTab(JewelrycraftMod.jewelrycraft); } } } diff --git a/common/darkknight/jewelrycraft/item/ItemMolds.java b/common/darkknight/jewelrycraft/item/ItemMolds.java index 9beb03a..090d53a 100644 --- a/common/darkknight/jewelrycraft/item/ItemMolds.java +++ b/common/darkknight/jewelrycraft/item/ItemMolds.java @@ -14,7 +14,7 @@ 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"}; + public static final String[] moldsItemNames = new String[] {"ingot", "ring"}; @SideOnly(Side.CLIENT) private Icon[] moldsIcons; @@ -24,7 +24,6 @@ public class ItemMolds extends Item this.setHasSubtypes(true); this.setMaxDamage(0); this.setMaxStackSize(1); - this.setCreativeTab(CreativeTabs.tabMaterials); } @SideOnly(Side.CLIENT) @@ -34,7 +33,7 @@ public class ItemMolds extends Item */ public Icon getIconFromDamage(int par1) { - int j = MathHelper.clamp_int(par1, 0, 2); + int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); return this.moldsIcons[j]; } @@ -44,7 +43,7 @@ public class ItemMolds extends Item */ public String getUnlocalizedName(ItemStack par1ItemStack) { - int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 2); + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, moldsItemNames.length - 1); return super.getUnlocalizedName() + "." + moldsItemNames[i]; } @@ -56,7 +55,7 @@ public class ItemMolds extends Item */ public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int j = 0; j < 3; ++j) + for (int j = 0; j < moldsItemNames.length; ++j) { par3List.add(new ItemStack(par1, 1, j)); } diff --git a/common/darkknight/jewelrycraft/item/ItemRing.java b/common/darkknight/jewelrycraft/item/ItemRing.java new file mode 100644 index 0000000..155261c --- /dev/null +++ b/common/darkknight/jewelrycraft/item/ItemRing.java @@ -0,0 +1,46 @@ +package darkknight.jewelrycraft.item; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; + +public class ItemRing extends ItemBase +{ + public ItemStack ingot; + public PotionEffect effect; + + public ItemRing(int par1) + { + super(par1); + this.setMaxStackSize(1); + } + + public ItemRing(int par1, ItemStack ingot) + { + this(par1); + this.ingot = ingot; + } + + public ItemRing(int par1, ItemStack ingot, PotionEffect effect) + { + this(par1, ingot); + this.effect = effect; + } + + public int getColor(ItemStack par1ItemStack) + { + return 65535; + } + + /** + * allows items to add custom lines of information to the mouseover description + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) + { + if(ingot != null) list.add(EnumChatFormatting.GRAY + ingot.getDisplayName()); + if(effect != null) list.add(EnumChatFormatting.GREEN + effect.getEffectName()); + } +} -- cgit v1.2.3