Merge pull request #84 from EoD/sync-save-logic

use same save logic in 1.20.1 and 1.20.4
This commit is contained in:
mlus 2025-06-18 12:28:07 +08:00 committed by GitHub
commit 7a47c58316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 + ")");