From 43d12f2d514059448c8ab22a77a11e0cbd407a8c Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Tue, 28 May 2024 09:30:30 +0100 Subject: [PATCH] fix: ACTUALLY fix the empty itemstack issue this time Third time's the charm https://github.com/FTBTeam/FTB-Mods-Issues/issues/1182 --- .../dev/ftb/mods/ftbquests/item/MissingItem.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/item/MissingItem.java b/common/src/main/java/dev/ftb/mods/ftbquests/item/MissingItem.java index 42eae033..73c23a7e 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/item/MissingItem.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/item/MissingItem.java @@ -42,8 +42,12 @@ public static ItemStack readItem(CompoundTag tag) { return stack; } - // Kludge: see kludge comment below! - return ItemStack.of(tag).copyWithCount(tag.getInt("Count")); + // Kludge: vanilla serializes the stack size as a byte, which breaks for a stack >127 items, + // leading to the stack turning into an empty (air) stack + // (note: using ItemStack#copyWithCount will *not* work here) + ItemStack stack = ItemStack.of(tag); + stack.setCount(tag.getInt("Count")); + return stack; } public static CompoundTag writeItem(ItemStack stack) { @@ -54,9 +58,7 @@ public static CompoundTag writeItem(ItemStack stack) { SNBTCompoundTag tag = new SNBTCompoundTag(); stack.save(tag); - // kludge: vanilla saves the stack size as a byte, which means negative sizes for big stacks, - // leading to the stack turning into an empty (air) stack - // https://github.com/FTBTeam/FTB-Mods-Issues/issues/1182 + // kludge: see above! tag.putInt("Count", stack.getCount()); if (tag.size() == 2) {