From 2d57e8c2125655c9c0ba332deaaa53c39ef889c8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 8 Dec 2023 21:06:30 +0100 Subject: [PATCH] Clone tag instead of abusing tag conversion --- .../packets/BlockItemPackets1_13.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java index 97d2f17a..df1403ae 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java @@ -40,8 +40,14 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3; -import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry; -import com.viaversion.viaversion.libs.opennbt.tag.builtin.*; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; @@ -50,8 +56,12 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter; import com.viaversion.viaversion.util.Key; - -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter { @@ -575,7 +585,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit if (blockTag == null) return; ListTag newCanPlaceOn = new ListTag(StringTag.class); - tag.put(extraNbtTag + "|" + tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag))); + tag.put(extraNbtTag + "|" + tagName, blockTag.clone()); for (Tag oldTag : blockTag) { Object value = oldTag.getValue(); String[] newValues = value instanceof String ? @@ -825,7 +835,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit if (!(tag.get(tagName) instanceof ListTag)) return; ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName); if (blockTag != null) { - tag.put(tagName, ConverterRegistry.convertToTag(ConverterRegistry.convertToValue(blockTag))); + tag.put(tagName, blockTag.clone()); } else if ((blockTag = tag.get(tagName)) != null) { ListTag newCanPlaceOn = new ListTag(StringTag.class); for (Tag oldTag : blockTag) {