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

This commit is contained in:
blablubbabc 2024-06-10 08:35:53 +10:00 committed by md_5
parent fd2f418340
commit 340ccd57f7
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
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;
}
}