From 68e578a04e46c5d3e346181f83fff3377c71b553 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 18 Mar 2023 13:16:22 +0100 Subject: [PATCH] Handle translatables in 1.13.1 entity display names --- .../api/rewriters/EntityRewriterBase.java | 25 +++++++++++++++---- .../Protocol1_13To1_13_1.java | 7 +++++- .../packets/EntityPackets1_13_1.java | 4 +++ .../packets/EntityPackets1_19_4.java | 4 +++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java index 9aee0bee..bc006929 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/EntityRewriterBase.java @@ -175,17 +175,32 @@ public abstract class EntityRewriterBase { MetaType type = meta.metaType(); - if (itemType != null && type == itemType) { + if (type == itemType) { protocol.getItemRewriter().handleItemToClient(meta.value()); - } else if (blockType != null && type == blockType) { + } else if (type == blockType) { int data = meta.value(); meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); - } else if (particleType != null && type == particleType) { + } else if (type == particleType) { rewriteParticle(meta.value()); - } else if (optionalComponentType != null && type == optionalComponentType) { + } else if (type == optionalComponentType || type == componentType) { JsonElement text = meta.value(); if (text != null) { protocol.getTranslatableRewriter().processText(text); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index fbd88bd0..8b6d9cce 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -49,6 +49,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); public Protocol1_13To1_13_1() { super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); @@ -60,7 +61,6 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol translatableRewriter = new TranslatableRewriter<>(this); translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE); translatableRewriter.registerCombatEvent(ClientboundPackets1_13.COMBAT_EVENT); translatableRewriter.registerDisconnect(ClientboundPackets1_13.DISCONNECT); @@ -227,4 +227,9 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol getTranslatableRewriter() { + return translatableRewriter; + } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java index d3ac3320..92623e91 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13to1_13_1/packets/EntityPackets1_13_1.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.Particle; import com.viaversion.viaversion.api.type.types.version.Types1_13; +import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import java.util.List; @@ -139,6 +140,9 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter { // TODO Maybe spawn an extra entity to ride the armor stand for blocks and items