From fd43ca56d74cbb32046b5a37e12434c0dc885cfe Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 9 May 2024 18:04:13 +0200 Subject: [PATCH] Properly write properties --- .../BlockItemPacketRewriter1_20_5.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java index 2099affb..9b4cc99c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/BlockItemPacketRewriter1_20_5.java @@ -210,28 +210,25 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem skullOwnerTag.put("Id", idTag); } - final Tag propertiesListTag = profileTag.remove("properties"); - if (!(propertiesListTag instanceof ListTag)) { + final ListTag propertiesListTag = profileTag.getListTag("properties", CompoundTag.class); + if (propertiesListTag == null) { return; } final CompoundTag propertiesTag = new CompoundTag(); - for (final Tag propertyTag : ((ListTag) propertiesListTag)) { - if (!(propertyTag instanceof CompoundTag)) { - continue; - } - - final CompoundTag propertyCompoundTag = (CompoundTag) propertyTag; - final String property = propertyCompoundTag.getString("name", ""); - final String value = propertyCompoundTag.getString("value", ""); - final String signature = propertyCompoundTag.getString("signature"); + for (final CompoundTag propertyTag : propertiesListTag) { + final String property = propertyTag.getString("name", ""); + final String value = propertyTag.getString("value", ""); + final String signature = propertyTag.getString("signature"); + final ListTag list = new ListTag<>(CompoundTag.class); final CompoundTag updatedPropertyTag = new CompoundTag(); updatedPropertyTag.putString("Value", value); if (signature != null) { updatedPropertyTag.putString("Signature", signature); } - propertiesTag.put(property, updatedPropertyTag); + list.add(updatedPropertyTag); + propertiesTag.put(property, list); } skullOwnerTag.put("Properties", propertiesTag); }