use same save logic in 1.20.1 and 1.20.4

This commit is contained in:
EoD 2025-06-17 21:04:54 +00:00
parent 2d891db071
commit 51200c28b3

View File

@ -451,10 +451,20 @@ public class VanillaSync {
return itemStack.getTag().getString("playersync:original_item_nbt");
} else {
// It's a normal item or empty, serialize its current NBT
return serialize(itemStack.serializeNBT().toString());
return serialize(serializeNBT(itemStack).toString());
}
}
public static CompoundTag serializeNBT(ItemStack itemStack) {
if (itemStack == null || itemStack.isEmpty()) {
return new CompoundTag();
}
// Serialize the ItemStack to NBT
CompoundTag compoundTag = new CompoundTag();
itemStack.save(compoundTag);
return compoundTag;
}
public static void store(Player player, boolean init) throws SQLException, IOException {
String player_uuid = player.getUUID().toString();
PlayerSync.LOGGER.info("Storing data for player " + player_uuid + " (init=" + init + ")");