Fix syncable itemstack syncing empty stacks when nothing actually changed. It turns out ItemStack#isItemEqual checks to make sure the stack is not empty and if it is, returns false even if the other stack is also empty
@@ -48,6 +48,13 @@ public class SyncableItemStack implements ISyncableData {
@Override
public DirtyType isDirty() {
ItemStack value = get();
+ if (value.isEmpty() && this.lastKnownValue.isEmpty()) {
+ //If they are both empty, we don't need to update anything they are identical
+ // Note: isItemEqual returns false if one is empty, even if the other may also be empty
+ return DirtyType.CLEAN;
+ }
+ //TODO: Should same item be replaced with ItemHandlerHelper#canItemStacksStack so that we take cap NBT into account?
+ // Cap NBT isn't synced so in a sense it doesn't matter, though maybe it will at some point?
boolean sameItem = value.isItemEqual(this.lastKnownValue) && ItemStack.areItemStackTagsEqual(value, this.lastKnownValue);
if (!sameItem || value.getCount() != this.lastKnownValue.getCount()) {
//Make sure to copy it in case our item stack object is the same object so would be getting modified
