From 869755ec4a0a92da21fde660b383ac468127495a Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Mon, 27 May 2024 13:28:39 +0200 Subject: [PATCH] Perform deep copy in DataItem#copy (#3883) --- .../viaversion/api/minecraft/item/DataItem.java | 10 +++------- .../v1_12_2to1_13/Protocol1_12_2To1_13.java | 17 ++++++++--------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java index ff8ff19ed..192cbe29b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/item/DataItem.java @@ -45,10 +45,6 @@ public class DataItem implements Item { this.tag = tag; } - public DataItem(Item toCopy) { - this(toCopy.identifier(), (byte) toCopy.amount(), toCopy.data(), toCopy.tag()); - } - @Override public int identifier() { return identifier; @@ -98,8 +94,8 @@ public class DataItem implements Item { } @Override - public Item copy() { - return new DataItem(identifier, amount, data, tag); + public DataItem copy() { + return new DataItem(identifier, amount, data, tag != null ? tag.copy() : null); } @Override @@ -131,4 +127,4 @@ public class DataItem implements Item { ", tag=" + tag + '}'; } -} +} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java index 39ab5f7c0..75fd57acc 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_12_2to1_13/Protocol1_12_2To1_13.java @@ -23,10 +23,9 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.BlockPosition; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13; -import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.platform.providers.ViaProviders; import com.viaversion.viaversion.api.protocol.AbstractProtocol; @@ -46,7 +45,6 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.Connec import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers.BlockConnectionProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.blockconnections.providers.PacketBlockConnectionProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.data.BlockIdData; -import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ComponentRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.data.MappingData1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.data.RecipeData; import com.viaversion.viaversion.protocols.v1_12_2to1_13.data.StatisticData; @@ -56,6 +54,7 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPacke import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.BlockEntityProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.PaintingProvider; import com.viaversion.viaversion.protocols.v1_12_2to1_13.provider.PlayerLookTargetProvider; +import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ComponentRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.EntityPacketRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ItemPacketRewriter1_13; import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.WorldPacketRewriter1_13; @@ -787,11 +786,11 @@ public class Protocol1_12_2To1_13 extends AbstractProtocol