Constrain dimension to String|Integer

Fixes 1.8 server switch issues
This commit is contained in:
md_5 2020-06-24 12:56:31 +10:00
parent 739b496bf6
commit b41e9be4c9
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
3 changed files with 7 additions and 7 deletions

View File

@ -74,7 +74,7 @@ public class Login extends DefinedPacket
dimension = buf.readInt();
} else
{
dimension = buf.readByte();
dimension = (int) buf.readByte();
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
{
@ -138,10 +138,10 @@ public class Login extends DefinedPacket
writeString( worldName, buf );
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
{
buf.writeInt( ( (Number) dimension ).intValue() );
buf.writeInt( (Integer) dimension );
} else
{
buf.writeByte( ( (Number) dimension ).byteValue() );
buf.writeByte( (Integer) dimension );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
{

View File

@ -68,7 +68,7 @@ public class Respawn extends DefinedPacket
writeString( worldName, buf );
} else
{
buf.writeInt( ( (Number) dimension ).intValue() );
buf.writeInt( ( (Integer) dimension ) );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
{

View File

@ -263,12 +263,12 @@ public class ServerConnector extends PacketHandler
{
Object newDim;
String worldName = login.getWorldName();
if ( login.getDimension() instanceof Number )
if ( login.getDimension() instanceof Integer )
{
newDim = ( ( (Number) login.getDimension() ).intValue() >= 0 ? -1 : 0 );
newDim = ( (Integer) login.getDimension() >= 0 ? -1 : 0 );
} else
{
newDim = worldName = ( "minecraft:overworld".equals( login.getDimension() ) ) ? "minecraft:the_nether" : "minecraft:overworld";
newDim = worldName = ( "minecraft:overworld".equals( (String) login.getDimension() ) ) ? "minecraft:the_nether" : "minecraft:overworld";
}
user.unsafe().sendPacket( new Respawn( newDim, worldName, login.getSeed(), login.getDifficulty(), login.getGameMode(), login.getPreviousGameMode(), login.getLevelType(), login.isDebug(), login.isFlat(), false ) );