Skip to content

Commit

Permalink
Minecraft 24w07a support
Browse files Browse the repository at this point in the history
  • Loading branch information
md-5 committed Feb 27, 2024
1 parent 3e9a7e4 commit 7606d44
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS;

Expand Down
16 changes: 14 additions & 2 deletions protocol/src/main/java/net/md_5/bungee/protocol/packet/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
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();
Expand Down Expand Up @@ -254,7 +260,13 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
{
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
Expand Down Expand Up @@ -92,7 +95,10 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
{
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
Expand Down
2 changes: 1 addition & 1 deletion proxy/src/main/java/net/md_5/bungee/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnec
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() );
Expand Down

0 comments on commit 7606d44

Please sign in to comment.