Stargate Journey

Stargate Journey

6M Downloads

Iris durability getter mutates ItemStack

slava110 opened this issue ยท 0 comments

commented

Describe the bug
Durability getter mutates ItemStack state in 1.20.1 which shouldn't happen for getters. This getter is, notably, used on client side for hover info, which could lead to desync

public static int getDurability(ItemStack stack)
{
if(stack.getItem() instanceof StargateIrisItem irisItem)
{
int durability;
CompoundTag tag = stack.getOrCreateTag();
if(!tag.contains(DURABILITY))
tag.putInt(DURABILITY, irisItem.getMaxDurability());
durability = tag.getInt(DURABILITY);
return durability;
}
else
return 0;
}

Not a problem in 1.21 version of the mod

To Reproduce
Use getter and it will modify NBT of an item