diff --git a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch index 7c3f0eb1c6..f8b404df7e 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Inventory.java.patch @@ -19,15 +19,19 @@ if (p_36049_.hasTag()) { itemstack.setTag(p_36049_.getTag().copy()); } -@@ -229,7 +_,7 @@ +@@ -222,10 +_,11 @@ + } + + public void tick() { ++ int idx = 0; + for(NonNullList nonnulllist : this.compartments) { + for(int i = 0; i < nonnulllist.size(); ++i) { + if (!nonnulllist.get(i).isEmpty()) { +- nonnulllist.get(i).inventoryTick(this.player.level(), this.player, i, this.selected == i); ++ nonnulllist.get(i).onInventoryTick(this.player.level(), this.player, idx++, this.selected); } } } -- -+ armor.forEach(e -> e.onArmorTick(player.level(), player)); - } - - public boolean add(ItemStack p_36055_) { @@ -277,6 +_,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Adding item to inventory"); diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index 6385cdb683..a7502247fe 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -340,16 +340,17 @@ public interface IForgeItem */ default void onInventoryTick(ItemStack stack, Level level, Player player, int slotIndex, int selectedIndex) { - // For compatibility reasons we have to use non-local index values, I think this is a vanilla bug but lets maintain compatibility - int vanillaIndex = slotIndex; - if (slotIndex >= 36) { - vanillaIndex -= 36; - if (vanillaIndex >= 4) - vanillaIndex -= 4; - else - onArmorTick(stack, level, player); - } - stack.inventoryTick(level, player, vanillaIndex, selectedIndex == vanillaIndex); + // For compatibility reasons we have to use non-local index values, I think this is a vanilla bug but lets maintain compatibility + var inv = player.getInventory(); + int vanillaIndex = slotIndex; + if (slotIndex >= inv.items.size()) { + vanillaIndex -= inv.items.size(); + if (vanillaIndex >= inv.armor.size()) + vanillaIndex -= inv.armor.size(); + else + onArmorTick(stack, level, player); + } + stack.inventoryTick(level, player, vanillaIndex, selectedIndex == vanillaIndex); } /**