From 47bea89146cd46186e8d19fb2da9b9e344655a1f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 30 Jul 2018 19:35:16 -0400 Subject: [PATCH] Support Minecraft 1.10 --- .../backend/BackendPlaySessionHandler.java | 2 - .../client/StatusSessionHandler.java | 2 +- .../proxy/protocol/ProtocolConstants.java | 6 ++- .../proxy/protocol/StateRegistry.java | 37 ++++++++++--------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index fc603c26..46ef748a 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -85,8 +85,6 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { ClientPlaySessionHandler playerHandler = (ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler(); return message.getChannel().startsWith("MC|") || - message.getChannel().startsWith("FML") || - message.getChannel().equals("FORGE") || playerHandler.getClientPluginMsgChannels().contains(message.getChannel()); } } diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index e1a6a5f8..278ed24e 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -36,7 +36,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler { // Status request ServerPing ping = new ServerPing( - new ServerPing.Version(340, "1.12.2"), + new ServerPing.Version(connection.getProtocolVersion(), "Velocity 1.10-1.12.2"), new ServerPing.Players(0, configuration.getShowMaxPlayers()), configuration.getMotdComponent(), null diff --git a/src/main/java/com/velocitypowered/proxy/protocol/ProtocolConstants.java b/src/main/java/com/velocitypowered/proxy/protocol/ProtocolConstants.java index edbf3c80..e2de9cc2 100644 --- a/src/main/java/com/velocitypowered/proxy/protocol/ProtocolConstants.java +++ b/src/main/java/com/velocitypowered/proxy/protocol/ProtocolConstants.java @@ -4,16 +4,18 @@ import java.util.Arrays; public enum ProtocolConstants { ; public static final int MINECRAFT_1_7_2 = 4; + public static final int MINECRAFT_1_10 = 210; public static final int MINECRAFT_1_11 = 315; public static final int MINECRAFT_1_11_1 = 316; public static final int MINECRAFT_1_12 = 335; public static final int MINECRAFT_1_12_1 = 338; public static final int MINECRAFT_1_12_2 = 340; - public static final int MINIMUM_VERSION_SUPPORTED = MINECRAFT_1_11; - public static final int MINIMUM_GENERIC_VERSION = MINECRAFT_1_11; + public static final int MINIMUM_VERSION_SUPPORTED = MINECRAFT_1_10; + public static final int MINIMUM_GENERIC_VERSION = MINECRAFT_1_10; public static final int[] SUPPORTED_VERSIONS = new int[] { + MINECRAFT_1_10, MINECRAFT_1_11, MINECRAFT_1_11_1, MINECRAFT_1_12, diff --git a/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java index 1532c9f0..f318af64 100644 --- a/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -32,52 +32,52 @@ public enum StateRegistry { PLAY { { SERVERBOUND.register(Chat.class, Chat::new, - map(0x02, MINECRAFT_1_11), + map(0x02, MINECRAFT_1_10), map(0x03, MINECRAFT_1_12), map(0x02, MINECRAFT_1_12_2)); + SERVERBOUND.register(ClientSettings.class, ClientSettings::new, + map(0x04, MINECRAFT_1_10), + map(0x05, MINECRAFT_1_12), + map(0x04, MINECRAFT_1_12_1)); SERVERBOUND.register(PluginMessage.class, PluginMessage::new, - map(0x09, MINECRAFT_1_11), + map(0x09, MINECRAFT_1_10), map(0x0A, MINECRAFT_1_12), map(0x09, MINECRAFT_1_12_1)); SERVERBOUND.register(KeepAlive.class, KeepAlive::new, - map(0x0B, MINECRAFT_1_11), + map(0x0B, MINECRAFT_1_10), map(0x0C, MINECRAFT_1_12), map(0x0B, MINECRAFT_1_12_1)); - SERVERBOUND.register(ClientSettings.class, ClientSettings::new, - map(0x04, MINECRAFT_1_11), - map(0x05, MINECRAFT_1_12), - map(0x04, MINECRAFT_1_12_1)); CLIENTBOUND.register(BossBar.class, BossBar::new, - map(0x0C, MINECRAFT_1_11)); + map(0x0C, MINECRAFT_1_10)); CLIENTBOUND.register(Chat.class, Chat::new, - map(0x0F, MINECRAFT_1_11)); + map(0x0F, MINECRAFT_1_10)); CLIENTBOUND.register(PluginMessage.class, PluginMessage::new, - map(0x18, MINECRAFT_1_11)); + map(0x18, MINECRAFT_1_10)); CLIENTBOUND.register(Disconnect.class, Disconnect::new, - map(0x1A, MINECRAFT_1_11)); + map(0x1A, MINECRAFT_1_10)); CLIENTBOUND.register(KeepAlive.class, KeepAlive::new, - map(0x1F, MINECRAFT_1_11)); + map(0x1F, MINECRAFT_1_10)); CLIENTBOUND.register(JoinGame.class, JoinGame::new, - map(0x23, MINECRAFT_1_11)); + map(0x23, MINECRAFT_1_10)); CLIENTBOUND.register(Respawn.class, Respawn::new, - map(0x33, MINECRAFT_1_11), + map(0x33, MINECRAFT_1_10), map(0x34, MINECRAFT_1_12), map(0x35, MINECRAFT_1_12_2)); CLIENTBOUND.register(ScoreboardDisplay.class, ScoreboardDisplay::new, - map(0x38, MINECRAFT_1_11), + map(0x38, MINECRAFT_1_10), map(0x3A, MINECRAFT_1_12), map(0x3B, MINECRAFT_1_12_1)); CLIENTBOUND.register(ScoreboardObjective.class, ScoreboardObjective::new, - map(0x3F, MINECRAFT_1_11), + map(0x3F, MINECRAFT_1_10), map(0x41, MINECRAFT_1_12), map(0x42, MINECRAFT_1_12_1)); CLIENTBOUND.register(ScoreboardTeam.class, ScoreboardTeam::new, - map(0x41, MINECRAFT_1_11), + map(0x41, MINECRAFT_1_10), map(0x43, MINECRAFT_1_12), map(0x44, MINECRAFT_1_12_1)); CLIENTBOUND.register(ScoreboardSetScore.class, ScoreboardSetScore::new, - map(0x42, MINECRAFT_1_11), + map(0x42, MINECRAFT_1_10), map(0x44, MINECRAFT_1_12), map(0x45, MINECRAFT_1_12_1)); } @@ -107,6 +107,7 @@ public enum StateRegistry { private static final IntObjectMap LINKED_PROTOCOL_VERSIONS = new IntObjectHashMap<>(); static { + LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_10, new int[] { MINECRAFT_1_11 }); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_11, new int[] { MINECRAFT_1_11_1, MINECRAFT_1_12 }); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, new int[] { MINECRAFT_1_12_1 }); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, new int[] { MINECRAFT_1_12_2 });