From b506060e48ed4c2e2b70237535f0a8d06f300bc8 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Tue, 23 Jun 2020 19:20:39 +0200 Subject: [PATCH] Fix component length read --- .../api/rewriters/TranslatableRewriter.java | 20 +++++++++---------- .../packets/BlockItemPackets1_14.java | 4 ++-- .../Protocol1_13To1_13_1.java | 2 +- .../Protocol1_15_2To1_16.java | 4 ++-- pom.xml | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/TranslatableRewriter.java b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/TranslatableRewriter.java index fda2e5f0..e7901227 100644 --- a/core/src/main/java/nl/matsv/viabackwards/api/rewriters/TranslatableRewriter.java +++ b/core/src/main/java/nl/matsv/viabackwards/api/rewriters/TranslatableRewriter.java @@ -50,7 +50,7 @@ public class TranslatableRewriter { protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() { @Override public void registerMap() { - handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)))); } }); } @@ -59,7 +59,7 @@ public class TranslatableRewriter { protocol.registerOutgoing(packetType, new PacketRemapper() { @Override public void registerMap() { - handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)))); } }); } @@ -68,7 +68,7 @@ public class TranslatableRewriter { protocol.registerOutgoing(packetType, new PacketRemapper() { @Override public void registerMap() { - handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)))); } }); } @@ -82,7 +82,7 @@ public class TranslatableRewriter { handler(wrapper -> { int action = wrapper.get(Type.VAR_INT, 0); if (action == 0 || action == 3) { - wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); + wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))); } }); } @@ -95,7 +95,7 @@ public class TranslatableRewriter { public void registerMap() { map(Type.UNSIGNED_BYTE); // Id map(Type.STRING); // Window Type - handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)))); } }); } @@ -106,7 +106,7 @@ public class TranslatableRewriter { public void registerMap() { map(Type.VAR_INT); // Id map(Type.VAR_INT); // Window Type - handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING)))); } }); } @@ -119,7 +119,7 @@ public class TranslatableRewriter { if (wrapper.passthrough(Type.VAR_INT) == 2) { wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.INT); - wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); + wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))); } }); } @@ -133,7 +133,7 @@ public class TranslatableRewriter { handler(wrapper -> { int action = wrapper.passthrough(Type.VAR_INT); if (action >= 0 && action <= 2) { - wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); + wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))); } }); } @@ -145,8 +145,8 @@ public class TranslatableRewriter { @Override public void registerMap() { handler(wrapper -> { - wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); - wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))); + wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))); + wrapper.write(Type.COMPONENT_STRING, processText(wrapper.read(Type.COMPONENT_STRING))); }); } }); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java index 87782a4e..38664510 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13_2to1_14/packets/BlockItemPackets1_14.java @@ -137,7 +137,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It wrapper.write(Type.STRING, stringType); - String title = wrapper.read(Type.STRING); + String title = wrapper.read(Type.COMPONENT_STRING); if (containerTitle != null) { // Don't rewrite renamed, only translatable titles JsonObject object = GsonUtil.getGson().fromJson(title, JsonObject.class); @@ -148,7 +148,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It } } } - wrapper.write(Type.STRING, title); + wrapper.write(Type.COMPONENT_STRING, title); wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize); } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java index 7b9a6d99..2b64c4c4 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_13to1_13_1/Protocol1_13To1_13_1.java @@ -103,7 +103,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, translatableRewriter.processText(wrapper.read(Type.COMPONENT_STRING)))); map(Type.BYTE); map(Type.UUID, Type.NOTHING); // Sender } @@ -64,7 +64,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)))); + handler(wrapper -> wrapper.write(Type.COMPONENT_STRING, translatableRewriter.processText(wrapper.read(Type.COMPONENT_STRING)))); handler(wrapper -> { int windowType = wrapper.get(Type.VAR_INT, 1); if (windowType == 20) { // Smithing table diff --git a/pom.xml b/pom.xml index 410e322f..71aaf884 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ us.myles viaversion - 3.0.0-SNAPSHOT + 3.0.1-SNAPSHOT provided