9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-19 14:59:21 +00:00

fix: don't update ItemMeta of empty containers, close #499

This causes a `minecraft:block_entity_data` component to be added to the item, which causes stuff not to stack.
This commit is contained in:
William278
2025-05-10 23:27:52 +01:00
parent 34b183a35e
commit 5cea4665a1

View File

@@ -102,11 +102,12 @@ public interface BukkitMapHandler {
} }
if (item.getType() == Material.FILLED_MAP && item.hasItemMeta()) { if (item.getType() == Material.FILLED_MAP && item.hasItemMeta()) {
items[i] = function.apply(item); items[i] = function.apply(item);
} else if (item.getItemMeta() instanceof BlockStateMeta b && b.getBlockState() instanceof Container box) { } else if (item.getItemMeta() instanceof BlockStateMeta b && b.getBlockState() instanceof Container box
&& !box.getInventory().isEmpty()) {
forEachMap(box.getInventory().getContents(), function); forEachMap(box.getInventory().getContents(), function);
b.setBlockState(box); b.setBlockState(box);
item.setItemMeta(b); item.setItemMeta(b);
} else if (item.getItemMeta() instanceof BundleMeta bundle) { } else if (item.getItemMeta() instanceof BundleMeta bundle && bundle.hasItems()) {
bundle.setItems(List.of(forEachMap(bundle.getItems().toArray(ItemStack[]::new), function))); bundle.setItems(List.of(forEachMap(bundle.getItems().toArray(ItemStack[]::new), function)));
item.setItemMeta(bundle); item.setItemMeta(bundle);
} }