#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
10 changed files with 115 additions and 36 deletions

View File

@@ -252,7 +252,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.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 );
@@ -270,7 +270,7 @@ public class ServerConnector extends PacketHandler
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(),
login.getPortalCooldown() ) );
login.getPortalCooldown(), login.getSeaLevel() ) );
} else
{
user.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) );
@@ -332,12 +332,12 @@ public class ServerConnector extends PacketHandler
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(),
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
(byte) 0, login.getDeathLocation(), login.getPortalCooldown(), login.getSeaLevel() ) );
}
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(),
(byte) 0, login.getDeathLocation(), login.getPortalCooldown() ) );
(byte) 0, login.getDeathLocation(), login.getPortalCooldown(), login.getSeaLevel() ) );
if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_14 )
{
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_21:
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" );
}

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_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_21_2 = new EntityMap_1_16_2( -1, 0x39 );
//
private final int spawnPlayerId;
private final int spectateId;
@@ -31,6 +32,10 @@ class EntityMap_1_16_2 extends EntityMap
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
{
if ( spawnPlayerId == -1 )
{
return;
}
// Special cases
int readerIndex = packet.readerIndex();
int packetId = DefinedPacket.readVarInt( packet );