From ace8c29085d275c830ab97c1779fc1426533b897 Mon Sep 17 00:00:00 2001 From: LexManos Date: Fri, 15 Feb 2013 04:25:08 -0800 Subject: [PATCH] Added a hook into SlotArmor so Items can control if they are classified as a Armor type. Closes #408 --- .../minecraft/inventory/SlotArmor.java.patch | 12 ++++++++++ .../net/minecraft/item/Item.java.patch | 24 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 patches/minecraft/net/minecraft/inventory/SlotArmor.java.patch diff --git a/patches/minecraft/net/minecraft/inventory/SlotArmor.java.patch b/patches/minecraft/net/minecraft/inventory/SlotArmor.java.patch new file mode 100644 index 000000000..142ab5b8c --- /dev/null +++ b/patches/minecraft/net/minecraft/inventory/SlotArmor.java.patch @@ -0,0 +1,12 @@ +--- ../src_base/minecraft/net/minecraft/inventory/SlotArmor.java ++++ ../src_work/minecraft/net/minecraft/inventory/SlotArmor.java +@@ -40,7 +40,8 @@ + */ + public boolean isItemValid(ItemStack par1ItemStack) + { +- return par1ItemStack == null ? false : (par1ItemStack.getItem() instanceof ItemArmor ? ((ItemArmor)par1ItemStack.getItem()).armorType == this.armorType : (par1ItemStack.getItem().itemID != Block.pumpkin.blockID && par1ItemStack.getItem().itemID != Item.skull.itemID ? false : this.armorType == 0)); ++ Item item = (par1ItemStack == null ? null : par1ItemStack.getItem()); ++ return item != null && item.isValidArmor(par1ItemStack, armorType); + } + + @SideOnly(Side.CLIENT) diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch index 7b248a427..5f235873f 100644 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/item/Item.java.patch @@ -57,7 +57,7 @@ Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21); return par1World.rayTraceBlocks_do_do(var13, var23, par3, !par3); } -@@ -701,4 +716,318 @@ +@@ -701,4 +716,340 @@ { StatList.initStats(); } @@ -374,5 +374,27 @@ + { + + } ++ ++ /** ++ * Determines if the specific ItemStack can be placed in the specified armor slot. ++ * ++ * @param stack The ItemStack ++ * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots ++ * @return True if the given ItemStack can be inserted in the slot ++ */ ++ public boolean isValidArmor(ItemStack stack, int armorType) ++ { ++ if (this instanceof ItemArmor) ++ { ++ return ((ItemArmor)this).armorType == armorType; ++ } ++ ++ if (armorType == 0) ++ { ++ return itemID == Block.pumpkin.blockID || itemID == Item.skull.itemID; ++ } ++ ++ return false; ++ } + }