Skip to content

Commit

Permalink
#3727: 24w34a snapshot support
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer authored and md-5 committed Aug 24, 2024
1 parent e1d4b6a commit d32eedd
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 36 deletions.
85 changes: 57 additions & 28 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 ),
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(
BossBar.class,
Expand Down Expand Up @@ -206,7 +207,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A ),
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(
ScoreboardScore.class,
Expand All @@ -224,13 +226,15 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D ),
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(
ScoreboardScoreReset.class,
ScoreboardScoreReset::new,
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(
ScoreboardDisplay.class,
Expand All @@ -248,7 +252,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 ),
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(
Team.class,
Expand All @@ -266,7 +271,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C ),
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(
PluginMessage.class,
Expand Down Expand Up @@ -321,7 +327,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 ),
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(
ClearTitles.class,
Expand All @@ -342,7 +349,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F ),
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(
TitleTimes.class,
Expand All @@ -354,7 +362,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 ),
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(
SystemChat.class,
Expand All @@ -365,7 +374,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 ),
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(
PlayerListHeaderFooter.class,
Expand All @@ -387,7 +397,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 ),
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(
EntityStatus.class,
Expand Down Expand Up @@ -458,30 +469,34 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 ),
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(
PlayerListItemRemove.class,
PlayerListItemRemove::new,
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ),
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(
PlayerListItemUpdate.class,
PlayerListItemUpdate::new,
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ),
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(
StartConfiguration.class,
StartConfiguration::new,
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 ),
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(
CookieRequest.class,
Expand All @@ -491,22 +506,26 @@ public enum Protocol
TO_CLIENT.registerPacket(
StoreCookie.class,
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(
Transfer.class,
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(
DisconnectReportDetails.class,
DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7A )
map( ProtocolConstants.MINECRAFT_1_21, 0x7A ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7D )
);
TO_CLIENT.registerPacket(
ServerLinks.class,
ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7B )
map( ProtocolConstants.MINECRAFT_1_21, 0x7B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7E )
);

TO_SERVER.registerPacket(
Expand All @@ -526,7 +545,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
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,
Chat::new,
Expand All @@ -542,19 +562,23 @@ public enum Protocol
ClientCommand::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
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(
UnsignedClientCommand.class,
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(
ClientChat.class,
ClientChat::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
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(
TabCompleteRequest.class,
Expand All @@ -570,7 +594,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
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(
ClientSettings.class,
Expand All @@ -585,7 +610,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
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(
PluginMessage.class,
Expand All @@ -603,18 +629,21 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
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(
StartConfiguration.class,
StartConfiguration::new,
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(
CookieResponse.class,
CookieResponse::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x13 )
);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class ProtocolConstants
public static final int MINECRAFT_1_20_3 = 765;
public static final int MINECRAFT_1_20_5 = 766;
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<Integer> SUPPORTED_VERSION_IDS;

Expand Down Expand Up @@ -114,7 +115,7 @@ public class ProtocolConstants
if ( SNAPSHOT_SUPPORT )
{
// supportedVersions.add( "1.21.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21 );
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21_2 );
}

SUPPORTED_VERSIONS = supportedVersions.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ClientSettings extends DefinedPacket
private int mainHand;
private boolean disableTextFiltering;
private boolean allowServerListing;
private ParticleStatus particleStatus;

@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
Expand All @@ -46,6 +47,10 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
{
allowServerListing = buf.readBoolean();
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
particleStatus = ParticleStatus.values()[readVarInt( buf )];
}
}

@Override
Expand Down Expand Up @@ -74,11 +79,22 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
{
buf.writeBoolean( allowServerListing );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( particleStatus.ordinal(), buf );
}
}

@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}

public enum ParticleStatus
{
ALL,
DECREASED,
MINIMAL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class Login extends DefinedPacket
private boolean flat;
private Location deathLocation;
private int portalCooldown;
private int seaLevel;
private boolean secureProfile;

@Override
Expand Down Expand Up @@ -161,7 +162,10 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
{
portalCooldown = readVarInt( buf );
}

if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
seaLevel = readVarInt( buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
{
secureProfile = buf.readBoolean();
Expand Down Expand Up @@ -293,7 +297,10 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
{
writeVarInt( portalCooldown, buf );
}

if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( seaLevel, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
{
buf.writeBoolean( secureProfile );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,8 @@ public static class Item
// ADD_PLAYER & UPDATE_DISPLAY_NAME
BaseComponent displayName;

// UPDATE_LIST_ORDER 1.21.2
Integer listOrder;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
item.displayName = DefinedPacket.readBaseComponent( buf, protocolVersion );
}
break;
case UPDATE_LIST_ORDER:
item.listOrder = DefinedPacket.readVarInt( buf );
break;
}
}
}
Expand Down Expand Up @@ -109,6 +112,9 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
DefinedPacket.writeBaseComponent( item.displayName, buf, protocolVersion );
}
break;
case UPDATE_LIST_ORDER:
DefinedPacket.writeVarInt( item.listOrder, buf );
break;
}
}
}
Expand All @@ -128,6 +134,7 @@ public static enum Action
UPDATE_GAMEMODE,
UPDATE_LISTED,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME;
UPDATE_DISPLAY_NAME,
UPDATE_LIST_ORDER;
}
}
Loading

0 comments on commit d32eedd

Please sign in to comment.