From 87cb125ee4b4a20b4094b6c5276ec743fd4c848f Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:43:11 +0200 Subject: [PATCH] Updated Via API usage --- .../vialegacy/api/remapper/LegacyItemRewriter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/raphimc/vialegacy/api/remapper/LegacyItemRewriter.java b/src/main/java/net/raphimc/vialegacy/api/remapper/LegacyItemRewriter.java index 67d6152..36072b7 100644 --- a/src/main/java/net/raphimc/vialegacy/api/remapper/LegacyItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/api/remapper/LegacyItemRewriter.java @@ -35,7 +35,6 @@ public abstract class LegacyItemRewriter

extends RewriterBas private final ObjectList rewriteEntries = new ObjectArrayList<>(); private final ObjectList nonExistentItems = new ObjectArrayList<>(); - protected final String tagName; protected final String protocolName; private final Type itemType; private final Type mappedItemType; @@ -48,7 +47,6 @@ public abstract class LegacyItemRewriter

extends RewriterBas public LegacyItemRewriter(final P protocol, final String protocolName, final Type itemType, final Type itemArrayType, final Type mappedItemType, final Type mappedItemArrayType) { super(protocol); - this.tagName = "ViaLegacy_" + protocolName.replace(".", "_"); this.protocolName = protocolName; this.itemType = itemType; this.itemArrayType = itemArrayType; @@ -155,6 +153,10 @@ public abstract class LegacyItemRewriter

extends RewriterBas return this.mappedItemArrayType; } + @Override + public String nbtTagName() { + return "VL|" + this.protocol.getClass().getSimpleName(); + } private void handleClientboundItem(final PacketWrapper wrapper) throws Exception { final Item item = this.handleItemToClient(wrapper.read(this.itemType)); @@ -177,7 +179,7 @@ public abstract class LegacyItemRewriter

extends RewriterBas item.setTag(tag); viaLegacyTag.putBoolean("RemoveTag", true); } - tag.put(this.tagName, viaLegacyTag); + tag.put(this.nbtTagName(), viaLegacyTag); CompoundTag display = tag.getCompoundTag("display"); if (display == null) { @@ -203,7 +205,7 @@ public abstract class LegacyItemRewriter

extends RewriterBas private void setRemappedTagWrite(final Item item) { final CompoundTag tag = item.tag(); if (tag == null) return; - final CompoundTag viaLegacyTag = tag.removeUnchecked(this.tagName); + final CompoundTag viaLegacyTag = tag.removeUnchecked(this.nbtTagName()); if (viaLegacyTag == null) return; item.setIdentifier(viaLegacyTag.getNumberTag("Id").asInt());