From 9b8e65c59dee4ebad9f9cb5c596f718491e575df Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 2 May 2024 15:28:40 +0200 Subject: [PATCH] Implement handleTranslate() for tags in TranslatableRewriter (#734) --- .../api/rewriters/TranslatableRewriter.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java index 1dd778fa..26a654bf 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/TranslatableRewriter.java @@ -20,9 +20,12 @@ package com.viaversion.viabackwards.api.rewriters; import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; +import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.rewriter.ComponentRewriter; import java.util.HashMap; import java.util.Map; @@ -67,6 +70,14 @@ public class TranslatableRewriter extends Compo } } + @Override + protected void handleTranslate(final UserConnection connection, final CompoundTag parentTag, final StringTag translateTag) { + final String newTranslate = mappedTranslationKey(translateTag.getValue()); + if (newTranslate != null) { + parentTag.put("translate", new StringTag(newTranslate)); + } + } + public @Nullable String mappedTranslationKey(final String translationKey) { return translatables.get(translationKey); }