From 4cccf53775fc88b008e102bfd6d0cdcc7a044ac0 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 11 Dec 2019 08:00:00 +1100 Subject: [PATCH] Minecraft 1.15 support --- api/pom.xml | 4 +- bootstrap/pom.xml | 4 +- chat/pom.xml | 4 +- config/pom.xml | 4 +- event/pom.xml | 4 +- log/pom.xml | 4 +- module/cmd-alert/pom.xml | 4 +- module/cmd-find/pom.xml | 4 +- module/cmd-list/pom.xml | 4 +- module/cmd-send/pom.xml | 4 +- module/cmd-server/pom.xml | 4 +- module/pom.xml | 4 +- module/reconnect-yaml/pom.xml | 4 +- native/pom.xml | 4 +- pom.xml | 2 +- protocol/pom.xml | 4 +- .../net/md_5/bungee/protocol/Protocol.java | 54 +++-- .../bungee/protocol/ProtocolConstants.java | 7 +- .../md_5/bungee/protocol/packet/Login.java | 18 ++ .../md_5/bungee/protocol/packet/Respawn.java | 9 + proxy/pom.xml | 4 +- .../java/net/md_5/bungee/PacketConstants.java | 4 +- .../java/net/md_5/bungee/ServerConnector.java | 8 +- .../net/md_5/bungee/entitymap/EntityMap.java | 2 + .../md_5/bungee/entitymap/EntityMap_1_15.java | 186 ++++++++++++++++++ query/pom.xml | 4 +- 26 files changed, 297 insertions(+), 61 deletions(-) create mode 100644 proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java diff --git a/api/pom.xml b/api/pom.xml index 79d2d367..30eef5dc 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-api - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-API diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index acc6aa97..9a11e65a 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-bootstrap - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Bootstrap diff --git a/chat/pom.xml b/chat/pom.xml index 5f87b60d..4ca669f9 100644 --- a/chat/pom.xml +++ b/chat/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-chat - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Chat diff --git a/config/pom.xml b/config/pom.xml index 83c36691..4b44d27e 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-config - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Config diff --git a/event/pom.xml b/event/pom.xml index 2de6603c..e86d9887 100644 --- a/event/pom.xml +++ b/event/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-event - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Event diff --git a/log/pom.xml b/log/pom.xml index 05c5f2c9..59beca1b 100644 --- a/log/pom.xml +++ b/log/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-log - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Log diff --git a/module/cmd-alert/pom.xml b/module/cmd-alert/pom.xml index 1c4f643f..36a7bca2 100644 --- a/module/cmd-alert/pom.xml +++ b/module/cmd-alert/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-alert - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar cmd_alert diff --git a/module/cmd-find/pom.xml b/module/cmd-find/pom.xml index 3e43c9ae..3dc2fe1e 100644 --- a/module/cmd-find/pom.xml +++ b/module/cmd-find/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-find - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar cmd_find diff --git a/module/cmd-list/pom.xml b/module/cmd-list/pom.xml index 99d6da26..3077f1b7 100644 --- a/module/cmd-list/pom.xml +++ b/module/cmd-list/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-list - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar cmd_list diff --git a/module/cmd-send/pom.xml b/module/cmd-send/pom.xml index 4472f373..54cbc090 100644 --- a/module/cmd-send/pom.xml +++ b/module/cmd-send/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-send - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar cmd_send diff --git a/module/cmd-server/pom.xml b/module/cmd-server/pom.xml index 9be58576..875e8eb1 100644 --- a/module/cmd-server/pom.xml +++ b/module/cmd-server/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-cmd-server - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar cmd_server diff --git a/module/pom.xml b/module/pom.xml index 5255b34f..7c81fe86 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT pom BungeeCord Modules diff --git a/module/reconnect-yaml/pom.xml b/module/reconnect-yaml/pom.xml index c68041d3..a6cc954d 100644 --- a/module/reconnect-yaml/pom.xml +++ b/module/reconnect-yaml/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-module - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-module-reconnect-yaml - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar reconnect_yaml diff --git a/native/pom.xml b/native/pom.xml index 959aae03..f11cad04 100644 --- a/native/pom.xml +++ b/native/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-native - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Native diff --git a/pom.xml b/pom.xml index 27d46c41..8ea1f089 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT pom BungeeCord-Parent diff --git a/protocol/pom.xml b/protocol/pom.xml index 61fedc71..e11af008 100644 --- a/protocol/pom.xml +++ b/protocol/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-protocol - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Protocol diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java index 0e6cac95..8c99ee85 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java @@ -65,19 +65,22 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_8, 0x00 ), map( ProtocolConstants.MINECRAFT_1_9, 0x1F ), map( ProtocolConstants.MINECRAFT_1_13, 0x21 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x20 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x20 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x21 ) ); TO_CLIENT.registerPacket( Login.class, map( ProtocolConstants.MINECRAFT_1_8, 0x01 ), map( ProtocolConstants.MINECRAFT_1_9, 0x23 ), - map( ProtocolConstants.MINECRAFT_1_13, 0x25 ) + map( ProtocolConstants.MINECRAFT_1_13, 0x25 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x26 ) ); TO_CLIENT.registerPacket( Chat.class, map( ProtocolConstants.MINECRAFT_1_8, 0x02 ), map( ProtocolConstants.MINECRAFT_1_9, 0x0F ), - map( ProtocolConstants.MINECRAFT_1_13, 0x0E ) + map( ProtocolConstants.MINECRAFT_1_13, 0x0E ), + map( ProtocolConstants.MINECRAFT_1_15, 0x0F ) ); TO_CLIENT.registerPacket( Respawn.class, @@ -86,11 +89,13 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x34 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ), map( ProtocolConstants.MINECRAFT_1_13, 0x38 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x3A ) + map( ProtocolConstants.MINECRAFT_1_14, 0x3A ), + map( ProtocolConstants.MINECRAFT_1_15, 0x3B ) ); TO_CLIENT.registerPacket( BossBar.class, - map( ProtocolConstants.MINECRAFT_1_9, 0x0C ) + map( ProtocolConstants.MINECRAFT_1_9, 0x0C ), + map( ProtocolConstants.MINECRAFT_1_15, 0x0D ) ); TO_CLIENT.registerPacket( PlayerListItem.class, // PlayerInfo @@ -98,13 +103,15 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_9, 0x2D ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ), map( ProtocolConstants.MINECRAFT_1_13, 0x30 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x33 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x33 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x34 ) ); TO_CLIENT.registerPacket( TabCompleteResponse.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3A ), map( ProtocolConstants.MINECRAFT_1_9, 0x0E ), - map( ProtocolConstants.MINECRAFT_1_13, 0x10 ) + map( ProtocolConstants.MINECRAFT_1_13, 0x10 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x11 ) ); TO_CLIENT.registerPacket( ScoreboardObjective.class, @@ -113,7 +120,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x41 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ), map( ProtocolConstants.MINECRAFT_1_13, 0x45 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x49 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x49 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x4A ) ); TO_CLIENT.registerPacket( ScoreboardScore.class, @@ -122,7 +130,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x44 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ), map( ProtocolConstants.MINECRAFT_1_13, 0x48 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x4C ) + map( ProtocolConstants.MINECRAFT_1_14, 0x4C ), + map( ProtocolConstants.MINECRAFT_1_15, 0x4D ) ); TO_CLIENT.registerPacket( ScoreboardDisplay.class, @@ -131,7 +140,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x3A ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ), map( ProtocolConstants.MINECRAFT_1_13, 0x3E ), - map( ProtocolConstants.MINECRAFT_1_14, 0x42 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x42 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x43 ) ); TO_CLIENT.registerPacket( Team.class, @@ -140,21 +150,24 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x43 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ), map( ProtocolConstants.MINECRAFT_1_13, 0x47 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x4B ) + map( ProtocolConstants.MINECRAFT_1_14, 0x4B ), + map( ProtocolConstants.MINECRAFT_1_15, 0x4C ) ); TO_CLIENT.registerPacket( PluginMessage.class, map( ProtocolConstants.MINECRAFT_1_8, 0x3F ), map( ProtocolConstants.MINECRAFT_1_9, 0x18 ), map( ProtocolConstants.MINECRAFT_1_13, 0x19 ), - map( ProtocolConstants.MINECRAFT_1_14, 0x18 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x18 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x19 ) ); TO_CLIENT.registerPacket( Kick.class, map( ProtocolConstants.MINECRAFT_1_8, 0x40 ), map( ProtocolConstants.MINECRAFT_1_9, 0x1A ), map( ProtocolConstants.MINECRAFT_1_13, 0x1B ), - map( ProtocolConstants.MINECRAFT_1_14, 0x1A ) + map( ProtocolConstants.MINECRAFT_1_14, 0x1A ), + map( ProtocolConstants.MINECRAFT_1_15, 0x1B ) ); TO_CLIENT.registerPacket( Title.class, @@ -162,7 +175,8 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x47 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ), map( ProtocolConstants.MINECRAFT_1_13, 0x4B ), - map( ProtocolConstants.MINECRAFT_1_14, 0x4F ) + map( ProtocolConstants.MINECRAFT_1_14, 0x4F ), + map( ProtocolConstants.MINECRAFT_1_15, 0x50 ) ); TO_CLIENT.registerPacket( PlayerListHeaderFooter.class, @@ -172,22 +186,26 @@ public enum Protocol map( ProtocolConstants.MINECRAFT_1_12, 0x49 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ), map( ProtocolConstants.MINECRAFT_1_13, 0x4E ), - map( ProtocolConstants.MINECRAFT_1_14, 0x53 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x53 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x54 ) ); TO_CLIENT.registerPacket( EntityStatus.class, map( ProtocolConstants.MINECRAFT_1_8, 0x1A ), map( ProtocolConstants.MINECRAFT_1_9, 0x1B ), map( ProtocolConstants.MINECRAFT_1_13, 0x1C ), - map( ProtocolConstants.MINECRAFT_1_14, 0x1B ) + map( ProtocolConstants.MINECRAFT_1_14, 0x1B ), + map( ProtocolConstants.MINECRAFT_1_15, 0x1C ) ); TO_CLIENT.registerPacket( Commands.class, - map( ProtocolConstants.MINECRAFT_1_13, 0x11 ) + map( ProtocolConstants.MINECRAFT_1_13, 0x11 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x12 ) ); TO_CLIENT.registerPacket( ViewDistance.class, - map( ProtocolConstants.MINECRAFT_1_14, 0x41 ) + map( ProtocolConstants.MINECRAFT_1_14, 0x41 ), + map( ProtocolConstants.MINECRAFT_1_15, 0x42 ) ); TO_SERVER.registerPacket( diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index 5d0a3f65..4ba561a4 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -25,6 +25,7 @@ public class ProtocolConstants public static final int MINECRAFT_1_14_2 = 485; public static final int MINECRAFT_1_14_3 = 490; public static final int MINECRAFT_1_14_4 = 498; + public static final int MINECRAFT_1_15 = 573; public static final List SUPPORTED_VERSIONS = Arrays.asList( "1.8.x", "1.9.x", @@ -32,7 +33,8 @@ public class ProtocolConstants "1.11.x", "1.12.x", "1.13.x", - "1.14.x" + "1.14.x", + "1.15.x" ); public static final List SUPPORTED_VERSION_IDS = Arrays.asList( ProtocolConstants.MINECRAFT_1_8, @@ -53,7 +55,8 @@ public class ProtocolConstants ProtocolConstants.MINECRAFT_1_14_1, ProtocolConstants.MINECRAFT_1_14_2, ProtocolConstants.MINECRAFT_1_14_3, - ProtocolConstants.MINECRAFT_1_14_4 + ProtocolConstants.MINECRAFT_1_14_4, + ProtocolConstants.MINECRAFT_1_15 ); public enum Direction diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java index b914cb3f..e0cdf82e 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java @@ -19,11 +19,13 @@ public class Login extends DefinedPacket private int entityId; private short gameMode; private int dimension; + private long seed; private short difficulty; private short maxPlayers; private String levelType; private int viewDistance; private boolean reducedDebugInfo; + private boolean normalRespawn; @Override public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) @@ -37,6 +39,10 @@ public class Login extends DefinedPacket { dimension = buf.readByte(); } + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + seed = buf.readLong(); + } if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 ) { difficulty = buf.readUnsignedByte(); @@ -51,6 +57,10 @@ public class Login extends DefinedPacket { reducedDebugInfo = buf.readBoolean(); } + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + normalRespawn = buf.readBoolean(); + } } @Override @@ -65,6 +75,10 @@ public class Login extends DefinedPacket { buf.writeByte( dimension ); } + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + buf.writeLong( seed ); + } if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 ) { buf.writeByte( difficulty ); @@ -79,6 +93,10 @@ public class Login extends DefinedPacket { buf.writeBoolean( reducedDebugInfo ); } + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + buf.writeBoolean( normalRespawn ); + } } @Override diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java index dbb24e22..1f544f26 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Respawn.java @@ -17,6 +17,7 @@ public class Respawn extends DefinedPacket { private int dimension; + private long seed; private short difficulty; private short gameMode; private String levelType; @@ -25,6 +26,10 @@ public class Respawn extends DefinedPacket public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { dimension = buf.readInt(); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + seed = buf.readLong(); + } if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 ) { difficulty = buf.readUnsignedByte(); @@ -37,6 +42,10 @@ public class Respawn extends DefinedPacket public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { buf.writeInt( dimension ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 ) + { + buf.writeLong( seed ); + } if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 ) { buf.writeByte( difficulty ); diff --git a/proxy/pom.xml b/proxy/pom.xml index c6bb8fe3..97a75125 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-proxy - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Proxy diff --git a/proxy/src/main/java/net/md_5/bungee/PacketConstants.java b/proxy/src/main/java/net/md_5/bungee/PacketConstants.java index ea6aa6a8..000c450e 100644 --- a/proxy/src/main/java/net/md_5/bungee/PacketConstants.java +++ b/proxy/src/main/java/net/md_5/bungee/PacketConstants.java @@ -7,8 +7,8 @@ import net.md_5.bungee.protocol.packet.Respawn; public class PacketConstants { - public static final Respawn DIM1_SWITCH = new Respawn( (byte) 1, (byte) 0, (byte) 0, "default" ); - public static final Respawn DIM2_SWITCH = new Respawn( (byte) -1, (byte) 0, (byte) 0, "default" ); + public static final Respawn DIM1_SWITCH = new Respawn( (byte) 1, 0, (byte) 0, (byte) 0, "default" ); + public static final Respawn DIM2_SWITCH = new Respawn( (byte) -1, 0, (byte) 0, (byte) 0, "default" ); public static final ClientStatus CLIENT_LOGIN = new ClientStatus( (byte) 0 ); public static final PluginMessage FORGE_MOD_REQUEST = new PluginMessage( "FML", new byte[] { diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 552af4fc..cc171600 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -210,8 +210,8 @@ public class ServerConnector extends PacketHandler user.setServerEntityId( login.getEntityId() ); // Set tab list size, TODO: what shall we do about packet mutability - Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(), - (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo() ); + Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getSeed(), login.getDifficulty(), + (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo(), login.isNormalRespawn() ); user.unsafe().sendPacket( modLogin ); @@ -254,11 +254,11 @@ public class ServerConnector extends PacketHandler user.setDimensionChange( true ); if ( login.getDimension() == user.getDimension() ) { - user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); + user.unsafe().sendPacket( new Respawn( ( login.getDimension() >= 0 ? -1 : 0 ), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); } user.setServerEntityId( login.getEntityId() ); - user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); + user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getLevelType() ) ); if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 ) { user.unsafe().sendPacket( new ViewDistance( login.getViewDistance() ) ); diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java index 3b469ab9..ff59c824 100644 --- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java @@ -57,6 +57,8 @@ public abstract class EntityMap case ProtocolConstants.MINECRAFT_1_14_3: case ProtocolConstants.MINECRAFT_1_14_4: return EntityMap_1_14.INSTANCE; + case ProtocolConstants.MINECRAFT_1_15: + return EntityMap_1_15.INSTANCE; } throw new RuntimeException( "Version " + version + " has no entity map" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java new file mode 100644 index 00000000..e9e19c0d --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_15.java @@ -0,0 +1,186 @@ +package net.md_5.bungee.entitymap; + +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import io.netty.buffer.ByteBuf; +import java.util.UUID; +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.UserConnection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.protocol.DefinedPacket; +import net.md_5.bungee.protocol.ProtocolConstants; + +class EntityMap_1_15 extends EntityMap +{ + + static final EntityMap_1_15 INSTANCE = new EntityMap_1_15(); + + EntityMap_1_15() + { + addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity + addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb + addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving + addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting + addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn + addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation + addRewrite( 0x09, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation + addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus + addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove + addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook + addRewrite( 0x2B, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook + addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity + addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect + addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation + addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera + addRewrite( 0x44, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata + addRewrite( 0x45, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity + addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity + addRewrite( 0x47, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment + addRewrite( 0x4B, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount + addRewrite( 0x56, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect + addRewrite( 0x57, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport + addRewrite( 0x59, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes + addRewrite( 0x5A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect + + addRewrite( 0x0E, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity + addRewrite( 0x1B, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction + } + + @Override + @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") + public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) + { + super.rewriteClientbound( packet, oldId, newId ); + + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + int jumpIndex = packet.readerIndex(); + switch ( packetId ) + { + case 0x45 /* Attach Entity : PacketPlayOutAttachEntity */: + rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 ); + break; + case 0x56 /* Collect Item : PacketPlayOutCollect */: + DefinedPacket.readVarInt( packet ); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + break; + case 0x4B /* Set Passengers : PacketPlayOutMount */: + DefinedPacket.readVarInt( packet ); + jumpIndex = packet.readerIndex(); + // Fall through on purpose to int array of IDs + case 0x38 /* Destroy Entities : PacketPlayOutEntityDestroy */: + int count = DefinedPacket.readVarInt( packet ); + int[] ids = new int[ count ]; + for ( int i = 0; i < count; i++ ) + { + ids[i] = DefinedPacket.readVarInt( packet ); + } + packet.readerIndex( jumpIndex ); + packet.writerIndex( jumpIndex ); + DefinedPacket.writeVarInt( count, packet ); + for ( int id : ids ) + { + if ( id == oldId ) + { + id = newId; + } else if ( id == newId ) + { + id = oldId; + } + DefinedPacket.writeVarInt( id, packet ); + } + break; + case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */: + DefinedPacket.readVarInt( packet ); + DefinedPacket.readUUID( packet ); + int type = DefinedPacket.readVarInt( packet ); + + if ( type == 2 || type == 101 || type == 71 ) // arrow, fishing_bobber or spectral_arrow + { + if ( type == 2 || type == 71 ) // arrow or spectral_arrow + { + oldId = oldId + 1; + newId = newId + 1; + } + + packet.skipBytes( 26 ); // double, double, double, byte, byte + int position = packet.readerIndex(); + int readId = packet.readInt(); + if ( readId == oldId ) + { + packet.setInt( position, newId ); + } else if ( readId == newId ) + { + packet.setInt( position, oldId ); + } + } + break; + case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */: + DefinedPacket.readVarInt( packet ); // Entity ID + int idLength = packet.readerIndex() - readerIndex - packetIdLength; + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength + idLength ); + DefinedPacket.writeUUID( player.getUniqueId(), packet ); + packet.writerIndex( previous ); + } + break; + case 0x33 /* Combat Event : PacketPlayOutCombatEvent */: + int event = packet.readUnsignedByte(); + if ( event == 1 /* End Combat*/ ) + { + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } else if ( event == 2 /* Entity Dead */ ) + { + int position = packet.readerIndex(); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + packet.readerIndex( position ); + DefinedPacket.readVarInt( packet ); + rewriteInt( packet, oldId, newId, packet.readerIndex() ); + } + break; + case 0x44 /* EntityMetadata : PacketPlayOutEntityMetadata */: + DefinedPacket.readVarInt( packet ); // Entity ID + rewriteMetaVarInt( packet, oldId + 1, newId + 1, 7, protocolVersion ); // fishing hook + rewriteMetaVarInt( packet, oldId, newId, 8, protocolVersion ); // fireworks (et al) + break; + case 0x51 /* Entity Sound Effect : PacketPlayOutEntitySound */: + DefinedPacket.readVarInt( packet ); + DefinedPacket.readVarInt( packet ); + rewriteVarInt( packet, oldId, newId, packet.readerIndex() ); + break; + } + packet.readerIndex( readerIndex ); + } + + @Override + public void rewriteServerbound(ByteBuf packet, int oldId, int newId) + { + super.rewriteServerbound( packet, oldId, newId ); + // Special cases + int readerIndex = packet.readerIndex(); + int packetId = DefinedPacket.readVarInt( packet ); + int packetIdLength = packet.readerIndex() - readerIndex; + + if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() ) + { + UUID uuid = DefinedPacket.readUUID( packet ); + ProxiedPlayer player; + if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null ) + { + int previous = packet.writerIndex(); + packet.readerIndex( readerIndex ); + packet.writerIndex( readerIndex + packetIdLength ); + DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet ); + packet.writerIndex( previous ); + } + } + packet.readerIndex( readerIndex ); + } +} diff --git a/query/pom.xml b/query/pom.xml index 9cc2f80b..9c7d6f5a 100644 --- a/query/pom.xml +++ b/query/pom.xml @@ -6,13 +6,13 @@ net.md-5 bungeecord-parent - 1.14-SNAPSHOT + 1.15-SNAPSHOT ../pom.xml net.md-5 bungeecord-query - 1.14-SNAPSHOT + 1.15-SNAPSHOT jar BungeeCord-Query