diff options
Diffstat (limited to 'common/darkknight/jewelrycraft/item')
| -rw-r--r-- | common/darkknight/jewelrycraft/item/ItemMolds.java | 22 | ||||
| -rw-r--r-- | common/darkknight/jewelrycraft/item/ItemThiefGloves.java | 35 |
2 files changed, 31 insertions, 26 deletions
diff --git a/common/darkknight/jewelrycraft/item/ItemMolds.java b/common/darkknight/jewelrycraft/item/ItemMolds.java index 090d53a..25ebe70 100644 --- a/common/darkknight/jewelrycraft/item/ItemMolds.java +++ b/common/darkknight/jewelrycraft/item/ItemMolds.java @@ -14,10 +14,10 @@ import net.minecraft.util.MathHelper; public class ItemMolds extends Item { /** List of molds color names */ - public static final String[] moldsItemNames = new String[] {"ingot", "ring"}; + public static final String[] moldsItemNames = new String[] { "ingot", "ring" }; @SideOnly(Side.CLIENT) - private Icon[] moldsIcons; - + private Icon[] moldsIcons; + public ItemMolds(int par1) { super(par1); @@ -25,9 +25,8 @@ public class ItemMolds extends Item this.setMaxDamage(0); this.setMaxStackSize(1); } - + @SideOnly(Side.CLIENT) - /** * Gets an icon index based on an item's damage value */ @@ -36,20 +35,19 @@ public class ItemMolds extends Item int j = MathHelper.clamp_int(par1, 0, moldsItemNames.length - 1); 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. + * 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, moldsItemNames.length - 1); 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) */ @@ -60,12 +58,12 @@ public class ItemMolds extends Item 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()); diff --git a/common/darkknight/jewelrycraft/item/ItemThiefGloves.java b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java index 5e43010..ff934a9 100644 --- a/common/darkknight/jewelrycraft/item/ItemThiefGloves.java +++ b/common/darkknight/jewelrycraft/item/ItemThiefGloves.java @@ -23,6 +23,7 @@ import net.minecraft.village.MerchantRecipeList; public class ItemThiefGloves extends ItemBase { public Random rand; + public ItemThiefGloves(int par1) { super(par1); @@ -38,27 +39,31 @@ public class ItemThiefGloves extends ItemBase EntityVillager villager = (EntityVillager) par3EntityLivingBase; int wealth = (Integer) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "wealth", "field_70956_bz"); MerchantRecipeList buyingList = (MerchantRecipeList) ReflectionHelper.getPrivateValue(EntityVillager.class, villager, "buyingList", "field_70963_i"); - if(buyingList!=null) + if (buyingList != null) { Iterator<?> iterator = buyingList.iterator(); - while(iterator.hasNext()) + while (iterator.hasNext()) { - MerchantRecipe recipe = (MerchantRecipe)iterator.next(); + MerchantRecipe recipe = (MerchantRecipe) iterator.next(); int toolUses = (Integer) ReflectionHelper.getPrivateValue(MerchantRecipe.class, recipe, "toolUses", "field_77400_d"); int quantity; - if(recipe.getItemToSell().isStackable()) quantity = recipe.getItemToSell().stackSize * (7 - toolUses); - else quantity = 1; + if (recipe.getItemToSell().isStackable()) + quantity = recipe.getItemToSell().stackSize * (7 - toolUses); + else + quantity = 1; ItemStack s = new ItemStack(recipe.getItemToSell().itemID, quantity, recipe.getItemToSell().getItemDamage()); s.setTagCompound(recipe.getItemToSell().getTagCompound()); - if(par2EntityPlayer.inventory.addItemStackToInventory(s)); - else villager.entityDropItem(s, 0); + if (par2EntityPlayer.inventory.addItemStackToInventory(s)) + ; + else + villager.entityDropItem(s, 0); par2EntityPlayer.addChatMessage("Villager #" + villager.getProfession() + ": Hmmm... I seem to have lost my " + s.getDisplayName() + "!"); - } + } buyingList.clear(); ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 300, "timeUntilReset", "field_70961_j"); ReflectionHelper.setPrivateValue(EntityVillager.class, villager, true, "needsInitilization", "field_70959_by"); - } - + } + villager.dropItem(Item.emerald.itemID, wealth); ReflectionHelper.setPrivateValue(EntityVillager.class, villager, 0, "wealth", "field_70956_bz"); return true; @@ -68,11 +73,14 @@ public class ItemThiefGloves extends ItemBase return super.itemInteractionForEntity(par1ItemStack, par2EntityPlayer, par3EntityLivingBase); } } + @SuppressWarnings("unchecked") public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - if(!shouldAddAdditionalInfo()) list.add(EnumChatFormatting.GRAY + additionalInfoInstructions()); - else{ + if (!shouldAddAdditionalInfo()) + list.add(EnumChatFormatting.GRAY + additionalInfoInstructions()); + else + { list.add(EnumChatFormatting.GRAY + "Right click with the gloves,"); list.add(EnumChatFormatting.GRAY + "while sneaking, on a villager"); list.add(EnumChatFormatting.GRAY + "to steal his stuff."); @@ -90,8 +98,7 @@ public class ItemThiefGloves extends ItemBase } return false; } - - + public static String additionalInfoInstructions() { String message = "§oPress §b<SHIFT>§7§o for more information."; |
