From 1b9d53af2af73ffa5b4264c42f384d61f8c8214b Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 17 Oct 2024 19:44:37 +0200 Subject: [PATCH] Create tag if needed --- .../rewriter/BlockItemPacketRewriter1_20_5.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 3d0c5a64..16f764e7 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -381,10 +381,11 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem if (customData != null) { // We later don't know which tags are custom data and which are not because the VV conversion // keeps converted data, so we backup the original custom data and restore it later + if (oldItem.tag() == null) { + oldItem.setTag(new CompoundTag()); + } oldItem.tag().put(nbtTagName(), customData.copy()); - } - - if (oldItem.tag() != null && oldItem.tag().isEmpty()) { + } else if (oldItem.tag() != null && oldItem.tag().isEmpty()) { // Improve item equality checks by removing empty tags oldItem.setTag(null); }