Skip to content

Commit

Permalink
Fix inventoryTick receiving the wrong slot index and deprecate onArmo…
Browse files Browse the repository at this point in the history
…rTick (#549)
  • Loading branch information
Shadows-of-Fire authored Jan 29, 2024
1 parent d27a0bd commit 98c7acc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion patches/net/minecraft/world/entity/player/Inventory.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@
if (p_36049_.hasTag()) {
itemstack.setTag(p_36049_.getTag().copy());
}
@@ -237,6 +_,7 @@
@@ -230,13 +_,18 @@
}

public void tick() {
+ int slot = 0;
for(NonNullList<ItemStack> 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);
+ // Neo: Fix the slot param to be the global index instead of the per-compartment index.
+ // Neo: Fix the selected param to only be true for hotbar slots.
+ nonnulllist.get(i).inventoryTick(this.player.level(), this.player, slot, this.selected == slot);
+ slot++;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ default boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.level.Le

/**
* Called to tick armor in the armor slot. Override to do something
*
* @deprecated Use {@link Item#inventoryTick(ItemStack, Level, Entity, int, boolean)} by checking that the slot argument is an armor slot. Armor slots are 36, 37, 38 and 39.
*/
@Deprecated(forRemoval = true, since = "1.20.4")
default void onArmorTick(ItemStack stack, Level level, Player player) {}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ default float getXpRepairRatio() {

/**
* Called to tick armor in the armor slot. Override to do something
*
* @deprecated Use {@link Item#inventoryTick(ItemStack, Level, Entity, int, boolean)} by checking that the slot argument is an armor slot. Armor slots are 36, 37, 38 and 39.
*/
@Deprecated(forRemoval = true, since = "1.20.4")
default void onArmorTick(Level level, Player player) {
self().getItem().onArmorTick(self(), level, player);
}
Expand Down

0 comments on commit 98c7acc

Please sign in to comment.