1.9.1 support

This commit is contained in:
md_5 2016-03-16 16:53:19 +11:00 committed by Thinkofname
parent 891ad8711d
commit 6b4e285186
6 changed files with 29 additions and 10 deletions

View File

@ -108,7 +108,8 @@ public enum Protocol
public static final int MAX_PACKET_ID = 0xFF; public static final int MAX_PACKET_ID = 0xFF;
public static List<Integer> supportedVersions = Arrays.asList( public static List<Integer> supportedVersions = Arrays.asList(
ProtocolConstants.MINECRAFT_1_8, ProtocolConstants.MINECRAFT_1_8,
ProtocolConstants.MINECRAFT_1_9 ProtocolConstants.MINECRAFT_1_9,
ProtocolConstants.MINECRAFT_1_9_1
); );
/*========================================================================*/ /*========================================================================*/
public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER ); public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER );
@ -131,8 +132,10 @@ public enum Protocol
{ {
packetRemap.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() ); packetRemap.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() );
packetRemapInv.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() ); packetRemapInv.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() );
packetRemap.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); packetRemap.put( ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() );
packetRemapInv.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() ); packetRemapInv.put( ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() );
packetRemap.put( ProtocolConstants.MINECRAFT_1_9_1, packetRemap.get( ProtocolConstants.MINECRAFT_1_9 ) );
packetRemapInv.put( ProtocolConstants.MINECRAFT_1_9_1, packetRemapInv.get( ProtocolConstants.MINECRAFT_1_9 ) );
} }
public final DefinedPacket createPacket(int id, int protocol) public final DefinedPacket createPacket(int id, int protocol)

View File

@ -5,11 +5,14 @@ import java.util.List;
public class ProtocolConstants public class ProtocolConstants
{ {
public static final int MINECRAFT_1_8 = 47; public static final int MINECRAFT_1_8 = 47;
public static final int MINECRAFT_1_9 = 107; public static final int MINECRAFT_1_9 = 107;
public static final int MINECRAFT_1_9_1 = 108;
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList( public static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
"1.8.x", "1.8.x",
"1.9" "1.9",
"1.9.1"
); );
public enum Direction public enum Direction

View File

@ -24,8 +24,8 @@ public class EncryptionRequest extends DefinedPacket
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
serverId = readString( buf ); serverId = readString( buf );
publicKey = readArray( buf ); publicKey = readArray( buf, 128 );
verifyToken = readArray( buf ); verifyToken = readArray( buf, 128 );
} }
@Override @Override

View File

@ -22,8 +22,8 @@ public class EncryptionResponse extends DefinedPacket
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
sharedSecret = readArray( buf, 256 ); sharedSecret = readArray( buf, 128 );
verifyToken = readArray( buf, 256 ); verifyToken = readArray( buf, 128 );
} }
@Override @Override

View File

@ -29,7 +29,13 @@ public class Login extends DefinedPacket
{ {
entityId = buf.readInt(); entityId = buf.readInt();
gameMode = buf.readUnsignedByte(); gameMode = buf.readUnsignedByte();
if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
{
dimension = buf.readInt();
} else
{
dimension = buf.readByte(); dimension = buf.readByte();
}
difficulty = buf.readUnsignedByte(); difficulty = buf.readUnsignedByte();
maxPlayers = buf.readUnsignedByte(); maxPlayers = buf.readUnsignedByte();
levelType = readString( buf ); levelType = readString( buf );
@ -44,7 +50,13 @@ public class Login extends DefinedPacket
{ {
buf.writeInt( entityId ); buf.writeInt( entityId );
buf.writeByte( gameMode ); buf.writeByte( gameMode );
if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
{
buf.writeInt( dimension );
} else
{
buf.writeByte( dimension ); buf.writeByte( dimension );
}
buf.writeByte( difficulty ); buf.writeByte( difficulty );
buf.writeByte( maxPlayers ); buf.writeByte( maxPlayers );
writeString( levelType, buf ); writeString( levelType, buf );

View File

@ -28,6 +28,7 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_8: case ProtocolConstants.MINECRAFT_1_8:
return EntityMap_1_8.INSTANCE; return EntityMap_1_8.INSTANCE;
case ProtocolConstants.MINECRAFT_1_9: case ProtocolConstants.MINECRAFT_1_9:
case ProtocolConstants.MINECRAFT_1_9_1:
return EntityMap_1_9.INSTANCE; return EntityMap_1_9.INSTANCE;
} }
throw new RuntimeException( "Version " + version + " has no entity map" ); throw new RuntimeException( "Version " + version + " has no entity map" );