#3727: 24w34a snapshot support

This commit is contained in:
Outfluencer 2024-08-25 09:15:03 +10:00 committed by md_5
parent e1d4b6adc7
commit d32eedd333
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
10 changed files with 115 additions and 36 deletions

View File

@ -146,7 +146,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x47 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x47 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x48 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
BossBar.class, BossBar.class,
@ -206,7 +207,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x5E ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x5E ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x60 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardScore.class, ScoreboardScore.class,
@ -224,13 +226,15 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x61 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x61 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x64 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardScoreReset.class, ScoreboardScoreReset.class,
ScoreboardScoreReset::new, ScoreboardScoreReset::new,
map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x44 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x44 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x45 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardDisplay.class, ScoreboardDisplay.class,
@ -248,7 +252,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x57 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x57 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x58 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Team.class, Team.class,
@ -266,7 +271,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x60 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x60 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x63 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PluginMessage.class, PluginMessage.class,
@ -321,7 +327,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x65 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x65 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x68 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ClearTitles.class, ClearTitles.class,
@ -342,7 +349,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x63 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x63 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x66 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
TitleTimes.class, TitleTimes.class,
@ -354,7 +362,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x66 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x66 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x69 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
SystemChat.class, SystemChat.class,
@ -365,7 +374,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6C ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x6C ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6F )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListHeaderFooter.class, PlayerListHeaderFooter.class,
@ -387,7 +397,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6D ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x6D ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x70 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
EntityStatus.class, EntityStatus.class,
@ -458,7 +469,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x4B ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x4B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x4C )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListItemRemove.class, PlayerListItemRemove.class,
@ -466,7 +478,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3D ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x3D ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x3E )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListItemUpdate.class, PlayerListItemUpdate.class,
@ -474,14 +487,16 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3E ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x3E ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x3F )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
StartConfiguration.class, StartConfiguration.class,
StartConfiguration::new, StartConfiguration::new,
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x69 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x69 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6C )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
CookieRequest.class, CookieRequest.class,
@ -491,22 +506,26 @@ public enum Protocol
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
StoreCookie.class, StoreCookie.class,
StoreCookie::new, StoreCookie::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6B ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x6B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6E )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Transfer.class, Transfer.class,
Transfer::new, Transfer::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x76 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
DisconnectReportDetails.class, DisconnectReportDetails.class,
DisconnectReportDetails::new, DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7A ) map( ProtocolConstants.MINECRAFT_1_21, 0x7A ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ServerLinks.class, ServerLinks.class,
ServerLinks::new, ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7B ) map( ProtocolConstants.MINECRAFT_1_21, 0x7B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7E )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
@ -526,7 +545,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1A )
); );
TO_SERVER.registerPacket( Chat.class, TO_SERVER.registerPacket( Chat.class,
Chat::new, Chat::new,
@ -542,19 +562,23 @@ public enum Protocol
ClientCommand::new, ClientCommand::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ), map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x06 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
UnsignedClientCommand.class, UnsignedClientCommand.class,
UnsignedClientCommand::new, UnsignedClientCommand::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x05 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
ClientChat.class, ClientChat.class,
ClientChat::new, ClientChat::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ), map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x07 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
TabCompleteRequest.class, TabCompleteRequest.class,
@ -570,7 +594,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0D )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
ClientSettings.class, ClientSettings.class,
@ -585,7 +610,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ), map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0C )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
PluginMessage.class, PluginMessage.class,
@ -603,18 +629,21 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ), map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ), map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x14 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
StartConfiguration.class, StartConfiguration.class,
StartConfiguration::new, StartConfiguration::new,
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B ), map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0C ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x0C ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0E )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
CookieResponse.class, CookieResponse.class,
CookieResponse::new, CookieResponse::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x13 )
); );
} }
}, },

View File

@ -47,6 +47,7 @@ public class ProtocolConstants
public static final int MINECRAFT_1_20_3 = 765; public static final int MINECRAFT_1_20_3 = 765;
public static final int MINECRAFT_1_20_5 = 766; public static final int MINECRAFT_1_20_5 = 766;
public static final int MINECRAFT_1_21 = 767; public static final int MINECRAFT_1_21 = 767;
public static final int MINECRAFT_1_21_2 = 1073742030;
public static final List<String> SUPPORTED_VERSIONS; public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS; public static final List<Integer> SUPPORTED_VERSION_IDS;
@ -114,7 +115,7 @@ public class ProtocolConstants
if ( SNAPSHOT_SUPPORT ) if ( SNAPSHOT_SUPPORT )
{ {
// supportedVersions.add( "1.21.x" ); // supportedVersions.add( "1.21.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21 ); supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21_2 );
} }
SUPPORTED_VERSIONS = supportedVersions.build(); SUPPORTED_VERSIONS = supportedVersions.build();

View File

@ -25,6 +25,7 @@ public class ClientSettings extends DefinedPacket
private int mainHand; private int mainHand;
private boolean disableTextFiltering; private boolean disableTextFiltering;
private boolean allowServerListing; private boolean allowServerListing;
private ParticleStatus particleStatus;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -46,6 +47,10 @@ public class ClientSettings extends DefinedPacket
{ {
allowServerListing = buf.readBoolean(); allowServerListing = buf.readBoolean();
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
particleStatus = ParticleStatus.values()[readVarInt( buf )];
}
} }
@Override @Override
@ -74,6 +79,10 @@ public class ClientSettings extends DefinedPacket
{ {
buf.writeBoolean( allowServerListing ); buf.writeBoolean( allowServerListing );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( particleStatus.ordinal(), buf );
}
} }
@Override @Override
@ -81,4 +90,11 @@ public class ClientSettings extends DefinedPacket
{ {
handler.handle( this ); handler.handle( this );
} }
public enum ParticleStatus
{
ALL,
DECREASED,
MINIMAL;
}
} }

View File

@ -41,6 +41,7 @@ public class Login extends DefinedPacket
private boolean flat; private boolean flat;
private Location deathLocation; private Location deathLocation;
private int portalCooldown; private int portalCooldown;
private int seaLevel;
private boolean secureProfile; private boolean secureProfile;
@Override @Override
@ -161,7 +162,10 @@ public class Login extends DefinedPacket
{ {
portalCooldown = readVarInt( buf ); portalCooldown = readVarInt( buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
seaLevel = readVarInt( buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
{ {
secureProfile = buf.readBoolean(); secureProfile = buf.readBoolean();
@ -293,7 +297,10 @@ public class Login extends DefinedPacket
{ {
writeVarInt( portalCooldown, buf ); writeVarInt( portalCooldown, buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( seaLevel, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
{ {
buf.writeBoolean( secureProfile ); buf.writeBoolean( secureProfile );

View File

@ -145,5 +145,8 @@ public class PlayerListItem extends DefinedPacket
// ADD_PLAYER & UPDATE_DISPLAY_NAME // ADD_PLAYER & UPDATE_DISPLAY_NAME
BaseComponent displayName; BaseComponent displayName;
// UPDATE_LIST_ORDER 1.21.2
Integer listOrder;
} }
} }

View File

@ -61,6 +61,9 @@ public class PlayerListItemUpdate extends DefinedPacket
item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion ); item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion );
} }
break; break;
case UPDATE_LIST_ORDER:
item.listOrder = DefinedPacket.readVarInt( buf );
break;
} }
} }
} }
@ -109,6 +112,9 @@ public class PlayerListItemUpdate extends DefinedPacket
DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion ); DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion );
} }
break; break;
case UPDATE_LIST_ORDER:
DefinedPacket.writeVarInt( item.listOrder, buf );
break;
} }
} }
} }
@ -128,6 +134,7 @@ public class PlayerListItemUpdate extends DefinedPacket
UPDATE_GAMEMODE, UPDATE_GAMEMODE,
UPDATE_LISTED, UPDATE_LISTED,
UPDATE_LATENCY, UPDATE_LATENCY,
UPDATE_DISPLAY_NAME; UPDATE_DISPLAY_NAME,
UPDATE_LIST_ORDER;
} }
} }

View File

@ -30,6 +30,7 @@ public class Respawn extends DefinedPacket
private byte copyMeta; private byte copyMeta;
private Location deathLocation; private Location deathLocation;
private int portalCooldown; private int portalCooldown;
private int seaLevel;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -84,6 +85,10 @@ public class Respawn extends DefinedPacket
{ {
portalCooldown = readVarInt( buf ); portalCooldown = readVarInt( buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
seaLevel = readVarInt( buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
{ {
copyMeta = buf.readByte(); copyMeta = buf.readByte();
@ -148,6 +153,10 @@ public class Respawn extends DefinedPacket
{ {
writeVarInt( portalCooldown, buf ); writeVarInt( portalCooldown, buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( seaLevel, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
{ {
buf.writeByte( copyMeta ); buf.writeByte( copyMeta );

View File

@ -252,7 +252,7 @@ public class ServerConnector extends PacketHandler
// Set tab list size, TODO: what shall we do about packet mutability // Set tab list size, TODO: what shall we do about packet mutability
Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), Login modLogin = new Login( login.getEntityId(), login.isHardcore(), login.getGameMode(), login.getPreviousGameMode(), login.getWorldNames(), login.getDimensions(), login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(),
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(), (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isLimitedCrafting(), login.isDebug(), login.isFlat(), login.getDeathLocation(),
login.getPortalCooldown(), login.isSecureProfile() ); login.getPortalCooldown(), login.getSeaLevel(), login.isSecureProfile() );
user.unsafe().sendPacket( modLogin ); user.unsafe().sendPacket( modLogin );
@ -270,7 +270,7 @@ public class ServerConnector extends PacketHandler
user.getSentBossBars().clear(); user.getSentBossBars().clear();
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), (byte) 0, login.getDeathLocation(), user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), (byte) 0, login.getDeathLocation(),
login.getPortalCooldown() ) ); login.getPortalCooldown(), login.getSeaLevel() ) );
} else } else
{ {
user.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) ); user.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) );
@ -332,12 +332,12 @@ public class ServerConnector extends PacketHandler
if ( login.getDimension() == user.getDimension() ) if ( login.getDimension() == user.getDimension() )
{ {
user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), user.unsafe().sendPacket( new Respawn( (Integer) login.getDimension() >= 0 ? -1 : 0, login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) ); (byte) 0, login.getDeathLocation(), login.getPortalCooldown(), login.getSeaLevel() ) );
} }
user.setServerEntityId( login.getEntityId() ); user.setServerEntityId( login.getEntityId() );
user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), user.unsafe().sendPacket( new Respawn( login.getDimension(), login.getWorldName(), login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(),
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) ); (byte) 0, login.getDeathLocation(), login.getPortalCooldown(), login.getSeaLevel() ) );
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 ) if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
{ {
user.unsafe().sendPacket( new ViewDistance( login.getViewDistance() ) ); user.unsafe().sendPacket( new ViewDistance( login.getViewDistance() ) );

View File

@ -89,6 +89,8 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_20_5: case ProtocolConstants.MINECRAFT_1_20_5:
case ProtocolConstants.MINECRAFT_1_21: case ProtocolConstants.MINECRAFT_1_21:
return EntityMap_1_16_2.INSTANCE_1_20_5; return EntityMap_1_16_2.INSTANCE_1_20_5;
case ProtocolConstants.MINECRAFT_1_21_2:
return EntityMap_1_16_2.INSTANCE_1_21_2;
} }
throw new RuntimeException( "Version " + version + " has no entity map" ); throw new RuntimeException( "Version " + version + " has no entity map" );
} }

View File

@ -23,6 +23,7 @@ class EntityMap_1_16_2 extends EntityMap
static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 ); static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 );
static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 ); static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 );
static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 0x37 ); static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 0x37 );
static final EntityMap_1_16_2 INSTANCE_1_21_2 = new EntityMap_1_16_2( -1, 0x39 );
// //
private final int spawnPlayerId; private final int spawnPlayerId;
private final int spectateId; private final int spectateId;
@ -31,6 +32,10 @@ class EntityMap_1_16_2 extends EntityMap
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion) public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
{ {
if ( spawnPlayerId == -1 )
{
return;
}
// Special cases // Special cases
int readerIndex = packet.readerIndex(); int readerIndex = packet.readerIndex();
int packetId = DefinedPacket.readVarInt( packet ); int packetId = DefinedPacket.readVarInt( packet );