Jump to content

LIMachi

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by LIMachi

  1. Thanks, I will try to do a PR tomorrow then
  2. Because this is not a "bug" in itself, but might cause bugs in mods that assume that the index is correct (when using it to replace an item with Inventory#setItem for example). And so Mojang as no reason to "fix" this since it doesn't affect any Vanilla items (only compass and map items use the tick method in vanilla), but Forge might be interested in tweaking this behavior to ensure that mods using the tick method work as intended.
  3. In Inventory#tick, the function iterate on all slots in the player inventory to tick them, passing their index as the 3rd parameter and if they are selected as the 4th parameter, but those are not valid for armor or offhand, since the variable 'i' is reset per inventory compartment, resulting in index 0 for offhand and boots, and 1,2,3 for leggings, chest and helmet. public void tick() { 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); } } } armor.forEach(e -> e.onArmorTick(player.level, player)); } I think a simple tweak would be enough to fix this since 'compartments' are initialized in order: public void tick() { int index = 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, index, this.selected == index); ++index; } } } armor.forEach(e -> e.onArmorTick(player.level, player)); }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.