From 1afdf0fb8128bfe8d495bda21f123a6b4da76105 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 30 Jul 2020 15:43:34 +0200 Subject: [PATCH] Process player info entries with 1.16->1.15 color correction --- .../packets/EntityPackets1_16.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index 00c1f7a2..5cde4f4b 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -142,6 +142,45 @@ public class EntityPackets1_16 extends EntityRewriter { }); } }); + + protocol.registerOutgoing(ClientboundPackets1_16.PLAYER_INFO, new PacketRemapper() { + @Override + public void registerMap() { + handler(packetWrapper -> { + int action = packetWrapper.passthrough(Type.VAR_INT); + int playerCount = packetWrapper.passthrough(Type.VAR_INT); + for (int i = 0; i < playerCount; i++) { + packetWrapper.passthrough(Type.UUID); + if (action == 0) { // Add + packetWrapper.passthrough(Type.STRING); + int properties = packetWrapper.passthrough(Type.VAR_INT); + for (int j = 0; j < properties; j++) { + packetWrapper.passthrough(Type.STRING); + packetWrapper.passthrough(Type.STRING); + if (packetWrapper.passthrough(Type.BOOLEAN)) { + packetWrapper.passthrough(Type.STRING); + } + } + packetWrapper.passthrough(Type.VAR_INT); + packetWrapper.passthrough(Type.VAR_INT); + if (packetWrapper.passthrough(Type.BOOLEAN)) { + // Display Name + protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT)); + } + } else if (action == 1) { // Update Game Mode + packetWrapper.passthrough(Type.VAR_INT); + } else if (action == 2) { // Update Ping + packetWrapper.passthrough(Type.VAR_INT); + } else if (action == 3) { // Update Display Name + if (packetWrapper.passthrough(Type.BOOLEAN)) { + // Display name + protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT)); + } + } // 4 = Remove Player + } + }); + } + }); } @Override