Added a hook into SlotArmor so Items can control if they are classified as a Armor type. Closes #408
This commit is contained in:
parent
1c57f03722
commit
ace8c29085
2 changed files with 35 additions and 1 deletions
|
@ -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)
|
|
@ -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;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue