From b4676f5a0bfc3f1049189d247be45bbe53e813f2 Mon Sep 17 00:00:00 2001 From: Landmaster Date: Mon, 2 Oct 2017 15:53:31 -0700 Subject: [PATCH] Add hook to configure EntityEquipmentSlot for item. --- .../minecraft/entity/EntityLiving.java.patch | 11 ++++++- .../net/minecraft/item/Item.java.patch | 29 +++++++++++++++---- .../chunk/storage/AnvilChunkLoader.java.patch | 2 +- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch index fa205bfed..34b7b96b0 100644 --- a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch @@ -39,7 +39,16 @@ public float func_70603_bj() { return 1.0F; -@@ -1003,7 +1015,7 @@ +@@ -991,6 +1003,8 @@ + + public static EntityEquipmentSlot func_184640_d(ItemStack p_184640_0_) + { ++ final EntityEquipmentSlot slot = p_184640_0_.func_77973_b().getEquipmentSlot(p_184640_0_); ++ if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item + if (p_184640_0_.func_77973_b() != Item.func_150898_a(Blocks.field_150423_aK) && p_184640_0_.func_77973_b() != Items.field_151144_bL) + { + if (p_184640_0_.func_77973_b() instanceof ItemArmor) +@@ -1003,7 +1017,7 @@ } else { diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch index 7d3e65135..173edb757 100644 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/item/Item.java.patch @@ -70,7 +70,7 @@ CreativeTabs creativetabs = this.func_77640_w(); return creativetabs != null && (p_194125_1_ == CreativeTabs.field_78027_g || p_194125_1_ == creativetabs); } -@@ -435,11 +445,666 @@ +@@ -435,11 +445,683 @@ return false; } @@ -336,10 +336,12 @@ + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack){} + + /** -+ * Determines if the specific ItemStack can be placed in the specified armor slot. ++ * Determines if the specific ItemStack can be placed in the specified armor slot, for the entity. ++ * ++ * TODO: Change name to canEquip in 1.13? + * + * @param stack The ItemStack -+ * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots ++ * @param armorType Armor slot to be verified. + * @param entity The entity trying to equip the armor + * @return True if the given ItemStack can be inserted in the slot + */ @@ -349,6 +351,21 @@ + } + + /** ++ * Override this to set a non-default armor slot for an ItemStack, but ++ * do not use this to get the armor slot of said stack; for that, use ++ * {@link net.minecraft.entity.EntityLiving#getSlotForItemStack(ItemStack)}. ++ * ++ * @param stack the ItemStack ++ * @return the armor slot of the ItemStack, or {@code null} to let the default ++ * vanilla logic as per {@code EntityLiving.getSlotForItemStack(stack)} decide ++ */ ++ @Nullable ++ public EntityEquipmentSlot getEquipmentSlot(ItemStack stack) ++ { ++ return null; ++ } ++ ++ /** + * Allow or forbid the specific book/item combination as an anvil enchant + * + * @param stack The item @@ -737,7 +754,7 @@ public static void func_150900_l() { func_179214_a(Blocks.field_150350_a, new ItemAir(Blocks.field_150350_a)); -@@ -999,6 +1664,8 @@ +@@ -999,6 +1681,8 @@ private final float field_78010_h; private final float field_78011_i; private final int field_78008_j; @@ -746,7 +763,7 @@ private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_) { -@@ -1034,6 +1701,7 @@ +@@ -1034,6 +1718,7 @@ return this.field_78008_j; } @@ -754,7 +771,7 @@ public Item func_150995_f() { if (this == WOOD) -@@ -1057,5 +1725,21 @@ +@@ -1057,5 +1742,21 @@ return this == DIAMOND ? Items.field_151045_i : null; } } diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch index cc7cd6424..887a35164 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch @@ -84,7 +84,7 @@ } } } -@@ -121,7 +167,9 @@ +@@ -121,7 +167,10 @@ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound.func_74782_a("Level", nbttagcompound1); nbttagcompound.func_74768_a("DataVersion", 1343);