Jump to content

Recommended Posts

Posted

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));
   }

 

Posted (edited)

Why are you reporting a "bug" in Mojang's code?  I am not saying there aren't any bugs in Mojang's code. 🙂

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

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.

 

Posted (edited)

You can try to raise it as a real bug report here: https://github.com/MinecraftForge/MinecraftForge

But I guess it would be more likely to get fixed if you submitted a PR?

https://docs.minecraftforge.net/en/latest/forgedev/

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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