From 2e1de306fb41bddecb2991fa907610606a835cb3 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 9 Aug 2018 10:14:44 -0400 Subject: [PATCH] Complete tab-complete support back to Minecraft 1.8. --- .../velocitypowered/proxy/protocol/StateRegistry.java | 7 ++++++- .../proxy/protocol/packet/TabCompleteRequest.java | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java index fea896527..43f79eb8e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -33,7 +33,10 @@ public enum StateRegistry { PLAY { { SERVERBOUND.register(TabCompleteRequest.class, TabCompleteRequest::new, - map(0x01, MINECRAFT_1_12_2), + map(0x14, MINECRAFT_1_8), + map(0x01, MINECRAFT_1_9), + map(0x02, MINECRAFT_1_12), + map(0x01, MINECRAFT_1_12_1), map(0x05, MINECRAFT_1_13)); SERVERBOUND.register(Chat.class, Chat::new, map(0x01, MINECRAFT_1_8), @@ -69,6 +72,8 @@ public enum StateRegistry { map(0x0F, MINECRAFT_1_12), map(0x0E, MINECRAFT_1_13)); CLIENTBOUND.register(TabCompleteResponse.class, TabCompleteResponse::new, + map(0x3A, MINECRAFT_1_8), + map(0x0E, MINECRAFT_1_9), map(0x0E, MINECRAFT_1_12), map(0x10, MINECRAFT_1_13)); CLIENTBOUND.register(PluginMessage.class, PluginMessage::new, diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java index 94d80b66e..10c14b400 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteRequest.java @@ -6,6 +6,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils; import io.netty.buffer.ByteBuf; import static com.velocitypowered.proxy.protocol.ProtocolConstants.MINECRAFT_1_13; +import static com.velocitypowered.proxy.protocol.ProtocolConstants.MINECRAFT_1_9; public class TabCompleteRequest implements MinecraftPacket { private int transactionId; @@ -72,7 +73,9 @@ public class TabCompleteRequest implements MinecraftPacket { this.command = ProtocolUtils.readString(buf); } else { this.command = ProtocolUtils.readString(buf); - this.assumeCommand = buf.readBoolean(); + if (protocolVersion >= MINECRAFT_1_9) { + this.assumeCommand = buf.readBoolean(); + } this.hasPosition = buf.readBoolean(); if (hasPosition) { this.position = buf.readLong(); @@ -87,7 +90,9 @@ public class TabCompleteRequest implements MinecraftPacket { ProtocolUtils.writeString(buf, command); } else { ProtocolUtils.writeString(buf, command); - buf.writeBoolean(assumeCommand); + if (protocolVersion >= MINECRAFT_1_9) { + buf.writeBoolean(assumeCommand); + } buf.writeBoolean(hasPosition); if (hasPosition) { buf.writeLong(position);