Add optional 1.18 (21w40a) snapshot protocol support

Accessible via the net.md_5.bungee.protocol.snapshot JVM property.
This commit is contained in:
md_5 2021-10-09 09:25:28 +11:00
parent c5a90475af
commit f26f7d8809
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
6 changed files with 24 additions and 7 deletions

View File

@ -226,7 +226,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x4F ),
map( ProtocolConstants.MINECRAFT_1_15, 0x50 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x4F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x59 )
map( ProtocolConstants.MINECRAFT_1_17, 0x59 ),
map( ProtocolConstants.MINECRAFT_1_18, 0x5A )
);
TO_CLIENT.registerPacket(
ClearTitles.class,
@ -236,12 +237,14 @@ public enum Protocol
TO_CLIENT.registerPacket(
Subtitle.class,
Subtitle::new,
map( ProtocolConstants.MINECRAFT_1_17, 0x57 )
map( ProtocolConstants.MINECRAFT_1_17, 0x57 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x58 )
);
TO_CLIENT.registerPacket(
TitleTimes.class,
TitleTimes::new,
map( ProtocolConstants.MINECRAFT_1_17, 0x5A )
map( ProtocolConstants.MINECRAFT_1_17, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_17, 0x5B )
);
TO_CLIENT.registerPacket(
PlayerListHeaderFooter.class,
@ -255,7 +258,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x54 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x5E )
map( ProtocolConstants.MINECRAFT_1_17, 0x5E ),
map( ProtocolConstants.MINECRAFT_1_17, 0x5F )
);
TO_CLIENT.registerPacket(
EntityStatus.class,

View File

@ -36,6 +36,7 @@ public class ProtocolConstants
public static final int MINECRAFT_1_16_4 = 754;
public static final int MINECRAFT_1_17 = 755;
public static final int MINECRAFT_1_17_1 = 756;
public static final int MINECRAFT_1_18 = 1073741868;
public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS;
@ -87,8 +88,8 @@ public class ProtocolConstants
if ( SNAPSHOT_SUPPORT )
{
// supportedVersions.add( "1.17.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_17 );
supportedVersions.add( "1.18.x" );
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_18 );
}
SUPPORTED_VERSIONS = supportedVersions.build();

View File

@ -32,6 +32,7 @@ public class Login extends DefinedPacket
private int maxPlayers;
private String levelType;
private int viewDistance;
private int simulationDistance;
private boolean reducedDebugInfo;
private boolean normalRespawn;
private boolean debug;
@ -100,6 +101,10 @@ public class Login extends DefinedPacket
{
viewDistance = readVarInt( buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
{
simulationDistance = readVarInt( buf );
}
if ( protocolVersion >= 29 )
{
reducedDebugInfo = buf.readBoolean();
@ -177,6 +182,10 @@ public class Login extends DefinedPacket
{
writeVarInt( viewDistance, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
{
writeVarInt( simulationDistance, buf );
}
if ( protocolVersion >= 29 )
{
buf.writeBoolean( reducedDebugInfo );

View File

@ -216,7 +216,7 @@ public class ServerConnector extends PacketHandler
// 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(),
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat() );
(byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.getViewDistance(), login.getSimulationDistance(), login.isReducedDebugInfo(), login.isNormalRespawn(), login.isDebug(), login.isFlat() );
user.unsafe().sendPacket( modLogin );

View File

@ -71,6 +71,8 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_17:
case ProtocolConstants.MINECRAFT_1_17_1:
return EntityMap_1_16_2.INSTANCE_1_17;
case ProtocolConstants.MINECRAFT_1_18:
return EntityMap_1_16_2.INSTANCE_1_18;
}
throw new RuntimeException( "Version " + version + " has no entity map" );
}

View File

@ -16,6 +16,7 @@ class EntityMap_1_16_2 extends EntityMap
static final EntityMap_1_16_2 INSTANCE_1_16_2 = new EntityMap_1_16_2( 0x04, 0x2D );
static final EntityMap_1_16_2 INSTANCE_1_17 = new EntityMap_1_16_2( 0x04, 0x2D );
static final EntityMap_1_16_2 INSTANCE_1_18 = new EntityMap_1_16_2( 0x04, 0x2D );
//
private final int spawnPlayerId;
private final int spectateId;