Bottom Upgrade Slot voids any upgrades in it
tweakbsd opened this issue ยท 2 comments
Since we have 3 Upgrade Slots per Rat I recognized that every upgrade I put in the left bottom slot vanishes after
sending a rat through a portal or after leaving and re-joining a world.
Forge 34.1.42 - 1.16.3
Rats 7.1.0 download from curseforge.com
Ratlantis 1.0 is also loaded.
Also have this issue, in addition to this if a rat has the Angel upgrade and dies with all 3 slots filled, the bottom slot is deleted.
Forge 35.1.36 - 1.16.4
Rats 7.1.0
Ratlantis 1.0
All The Mods 6, updated bc crashes in old Rats version
I have found the issue in EntityRat.java
`
public void readAdditional(CompoundNBT compound) {
...
if (ratInventory != null) {
ListNBT nbttaglist = compound.getList("Items", 10);
this.initInventory();
for (int i = 0; i < nbttaglist.size(); ++i) {
CompoundNBT CompoundNBT = nbttaglist.getCompound(i);
int j = CompoundNBT.getByte("Slot") & 255;
// BUG IS HERE... why only load up to <= 4 inventory slots ?? Removing this IF-Case solves the problem
if (j <= 4) {
ItemStack itemstack = ItemStack.read(CompoundNBT);
ratInventory.setInventorySlotContents(j, itemstack);
}
}
} else {
// This code path doesn't trigger the BUG but is actually never called for my worlds
ListNBT nbttaglist = compound.getList("Items", 10);
this.initInventory();
for (int i = 0; i < nbttaglist.size(); ++i) {
CompoundNBT CompoundNBT = nbttaglist.getCompound(i);
int j = CompoundNBT.getByte("Slot") & 255;
ItemStack itemstack = ItemStack.read(CompoundNBT);
System.out.println("LOADING RAT INVENTORY Var2 SLOT #" + i + " with itemstack: " + itemstack.toString());
ratInventory.setInventorySlotContents(j, itemstack);
}
}
...
}
`
I'm probably making a PR with the fix in the next days, unfortunately I'm not sure if I'm allowed to send you a fixed version of the mod without explicit consent of Alex.