From e70f595f76d16a5bf54bf5c825a30ca1568e54ee Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 19 Nov 2021 22:09:36 +0100 Subject: [PATCH] Handle translatable changes --- build.gradle.kts | 2 +- .../api/rewriters/TranslatableRewriter.java | 11 ++++ .../Protocol1_16_4To1_17.java | 1 + .../packets/EntityPackets1_17.java | 1 + .../Protocol1_17_1To1_18.java | 22 ++++++- .../packets/EntityPackets1_18.java | 3 +- .../data/translation-mappings.json | 61 +++++++++++++++++++ 7 files changed, 97 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4eb1054a..7a813cc0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { allprojects { group = "com.viaversion" - version = "4.1.0-1.18-pre2-SNAPSHOT" + version = "4.1.0-1.18-pre5-SNAPSHOT" description = "Allow older clients to join newer server versions." } 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 e7da6e67..a6829723 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 @@ -123,6 +123,17 @@ public class TranslatableRewriter extends ComponentRewriter { }); } + public void registerCombatKill(ClientboundPacketType packetType) { + protocol.registerClientbound(packetType, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); + map(Type.INT); + handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT))); + } + }); + } + @Override protected void handleTranslate(JsonObject root, String translate) { String newTranslate = newTranslatables.get(translate); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java index e1450820..d8696b20 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_16_4to1_17/Protocol1_16_4To1_17.java @@ -225,6 +225,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol