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