SPIGOT-7735: Fix serialization of player heads with note block sound

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
CraftBukkit/Spigot 2024-06-10 08:35:53 +10:00
parent bf2a69e0fc
commit 95f120b7ff
2 changed files with 7 additions and 3 deletions

View File

@ -591,7 +591,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
String unhandled = SerializableMeta.getString(map, "unhandled", true);
if (unhandled != null) {
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(internal));
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(unhandled));
try {
NBTTagCompound unhandledTag = NBTCompressedStreamTools.readCompressed(buf, NBTReadLimiter.unlimitedHeap());
unhandledTags.copy(DataComponentPatch.CODEC.parse(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), unhandledTag).result().get());
@ -1817,6 +1817,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
CraftMetaMap.MAP_ID.TYPE,
CraftMetaPotion.POTION_CONTENTS.TYPE,
CraftMetaSkull.SKULL_PROFILE.TYPE,
CraftMetaSkull.NOTE_BLOCK_SOUND.TYPE,
CraftMetaSpawnEgg.ENTITY_TAG.TYPE,
CraftMetaBlockState.BLOCK_ENTITY_TAG.TYPE,
CraftMetaBook.BOOK_CONTENT.TYPE,

View File

@ -288,13 +288,16 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
super.serialize(builder);
if (this.profile != null) {
return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
}
NamespacedKey namespacedKeyNB = this.getNoteBlockSound();
if (namespacedKeyNB != null) {
return builder.put(NOTE_BLOCK_SOUND.BUKKIT, namespacedKeyNB.toString());
builder.put(NOTE_BLOCK_SOUND.BUKKIT, namespacedKeyNB.toString());
}
return builder;
}
}