From 39d3265463d7b0c27fe2b5e973670e5b76830dd7 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:48:19 +0200 Subject: [PATCH] Update VV ItemRewriter API Usage (#716) --- .../BackwardsStructuredItemRewriter.java | 4 ++-- .../api/rewriters/EnchantmentRewriter.java | 4 ++-- .../api/rewriters/ItemRewriter.java | 6 +++--- .../api/rewriters/ItemRewriterBase.java | 18 ++++++------------ .../api/rewriters/LegacyBlockItemRewriter.java | 10 +++++----- .../packets/BlockItemPackets1_11.java | 2 +- .../packets/ItemPackets1_11_1.java | 3 +-- .../packets/BlockItemPackets1_13.java | 2 +- .../packets/BlockItemPackets1_20.java | 4 ++-- 9 files changed, 23 insertions(+), 30 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java index a59264c4..c388e88a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/BackwardsStructuredItemRewriter.java @@ -67,7 +67,7 @@ public class BackwardsStructuredItemRewriter> extends ItemRewriter { protected final boolean jsonNameFormat; - protected final String protocolName; protected ItemRewriterBase(T protocol, Type itemType, Type itemArrayType, Type mappedItemType, Type mappedItemArrayType, boolean jsonFormat) { super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType); this.jsonNameFormat = jsonFormat; - protocolName = protocol.getClass().getSimpleName(); } protected ItemRewriterBase(T protocol, Type itemType, Type itemArrayType, boolean jsonNameFormat) { @@ -55,12 +53,12 @@ public abstract class ItemRewriterBase original, String name) { // Multiple places might try to backup data - String backupName = getNbtTagName() + "|o" + name; + String backupName = nbtTagName("o" + name); if (!displayTag.contains(backupName)) { displayTag.put(backupName, original.copy()); } @@ -80,7 +78,7 @@ public abstract class ItemRewriterBase) original).copy()); } } - - public String getNbtTagName() { - return "VB|" + protocolName; - } } diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java index ac18cc8b..a43fb212 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyBlockItemRewriter.java @@ -154,12 +154,12 @@ public abstract class LegacyBlockItemRewriter