From 7606d4437b3cb13a42c834fd42dc8066a9380e5e Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 27 Feb 2024 21:36:16 +1100 Subject: [PATCH] Minecraft 24w07a support --- .../md_5/bungee/protocol/ProtocolConstants.java | 2 +- .../net/md_5/bungee/protocol/packet/Login.java | 16 ++++++++++++++-- .../net/md_5/bungee/protocol/packet/Respawn.java | 10 ++++++++-- .../java/net/md_5/bungee/ServerConnector.java | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) 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 fdfa1480..5502b620 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 @@ -45,7 +45,7 @@ public class ProtocolConstants public static final int MINECRAFT_1_20 = 763; public static final int MINECRAFT_1_20_2 = 764; public static final int MINECRAFT_1_20_3 = 765; - public static final int MINECRAFT_1_20_5 = 1073742000; + public static final int MINECRAFT_1_20_5 = 1073742001; public static final List SUPPORTED_VERSIONS; public static final List SUPPORTED_VERSION_IDS; 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 c3ca42d7..a4e804e1 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 @@ -133,7 +133,13 @@ public class Login extends DefinedPacket if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 ) { limitedCrafting = buf.readBoolean(); - dimension = readString( buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + dimension = readVarInt( buf ); + } else + { + dimension = readString( buf ); + } worldName = readString( buf ); seed = buf.readLong(); gameMode = buf.readUnsignedByte(); @@ -254,7 +260,13 @@ public class Login extends DefinedPacket if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 ) { buf.writeBoolean( limitedCrafting ); - writeString( (String) dimension, buf ); + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + writeVarInt( (Integer) dimension, buf ); + } else + { + writeString( (String) dimension, buf ); + } writeString( worldName, buf ); buf.writeLong( seed ); buf.writeByte( gameMode ); 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 e6b1b0c9..46859e63 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 @@ -36,7 +36,10 @@ public class Respawn extends DefinedPacket { if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 ) { - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + dimension = readVarInt( buf ); + } else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 ) { dimension = readTag( buf, protocolVersion ); } else @@ -92,7 +95,10 @@ public class Respawn extends DefinedPacket { if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 ) { - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + { + writeVarInt( (Integer) dimension, buf ); + } else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 ) { writeTag( (Tag) dimension, buf, protocolVersion ); } else 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 47e06dcd..abdbfd1d 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -243,7 +243,7 @@ public class ServerConnector extends PacketHandler user.getForgeClientHandler().setHandshakeComplete(); } - if ( user.getServer() == null || !( login.getDimension() instanceof Integer ) ) + if ( user.getServer() == null || user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_16 ) { // Once again, first connection user.setClientEntityId( login.getEntityId() );