Update to Minecraft 1.9

This commit is contained in:
md_5
2016-03-01 09:13:13 +11:00
parent 12a7b7afc3
commit 05de455a9c
34 changed files with 335 additions and 485 deletions

View File

@@ -54,27 +54,26 @@ public enum Protocol
{
{
TO_CLIENT.registerPacket( 0x00, KeepAlive.class );
TO_CLIENT.registerPacket( 0x01, Login.class );
TO_CLIENT.registerPacket( 0x02, Chat.class );
TO_CLIENT.registerPacket( 0x07, Respawn.class );
TO_CLIENT.registerPacket( 0x38, PlayerListItem.class );
TO_CLIENT.registerPacket( 0x3A, TabCompleteResponse.class );
TO_CLIENT.registerPacket( 0x3B, ScoreboardObjective.class );
TO_CLIENT.registerPacket( 0x3C, ScoreboardScore.class );
TO_CLIENT.registerPacket( 0x3D, ScoreboardDisplay.class );
TO_CLIENT.registerPacket( 0x3E, Team.class );
TO_CLIENT.registerPacket( 0x3F, PluginMessage.class );
TO_CLIENT.registerPacket( 0x40, Kick.class );
TO_CLIENT.registerPacket( 0x45, Title.class );
TO_CLIENT.registerPacket( 0x46, SetCompression.class );
TO_CLIENT.registerPacket( 0x47, PlayerListHeaderFooter.class );
TO_CLIENT.registerPacket( 0x00, 0x1F, KeepAlive.class );
TO_CLIENT.registerPacket( 0x01, 0x23, Login.class );
TO_CLIENT.registerPacket( 0x02, 0x0F, Chat.class );
TO_CLIENT.registerPacket( 0x07, 0x33, Respawn.class );
TO_CLIENT.registerPacket( 0x38, 0x2D, PlayerListItem.class ); // PlayerInfo
TO_CLIENT.registerPacket( 0x3A, 0x0E, TabCompleteResponse.class );
TO_CLIENT.registerPacket( 0x3B, 0x3F, ScoreboardObjective.class );
TO_CLIENT.registerPacket( 0x3C, 0x42, ScoreboardScore.class );
TO_CLIENT.registerPacket( 0x3D, 0x38, ScoreboardDisplay.class );
TO_CLIENT.registerPacket( 0x3E, 0x41, Team.class );
TO_CLIENT.registerPacket( 0x3F, 0x18, PluginMessage.class );
TO_CLIENT.registerPacket( 0x40, 0x1A, Kick.class );
TO_CLIENT.registerPacket( 0x45, 0x45, Title.class );
TO_CLIENT.registerPacket( 0x47, 0x48, PlayerListHeaderFooter.class );
TO_SERVER.registerPacket( 0x00, KeepAlive.class );
TO_SERVER.registerPacket( 0x01, Chat.class );
TO_SERVER.registerPacket( 0x14, 0x15, TabCompleteRequest.class );
TO_SERVER.registerPacket( 0x15, 0x16, ClientSettings.class );
TO_SERVER.registerPacket( 0x17, 0x18, PluginMessage.class );
TO_SERVER.registerPacket( 0x00, 0x0B, KeepAlive.class );
TO_SERVER.registerPacket( 0x01, 0x02, Chat.class );
TO_SERVER.registerPacket( 0x14, 0x01, TabCompleteRequest.class );
TO_SERVER.registerPacket( 0x15, 0x04, ClientSettings.class );
TO_SERVER.registerPacket( 0x17, 0x09, PluginMessage.class );
}
},
// 1
@@ -107,7 +106,7 @@ public enum Protocol
public static final int MAX_PACKET_ID = 0xFF;
public static List<Integer> supportedVersions = Arrays.asList(
ProtocolConstants.MINECRAFT_1_8,
ProtocolConstants.MINECRAFT_SNAPSHOT
ProtocolConstants.MINECRAFT_1_9
);
/*========================================================================*/
public final DirectionData TO_SERVER = new DirectionData( ProtocolConstants.Direction.TO_SERVER );
@@ -126,11 +125,12 @@ public enum Protocol
private final TIntObjectMap<TIntIntMap> packetRemap = new TIntObjectHashMap<>();
private final TIntObjectMap<TIntIntMap> packetRemapInv = new TIntObjectHashMap<>();
{
packetRemap.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() );
packetRemapInv.put( ProtocolConstants.MINECRAFT_1_8, new TIntIntHashMap() );
packetRemap.put( ProtocolConstants.MINECRAFT_SNAPSHOT, new TIntIntHashMap() );
packetRemapInv.put( ProtocolConstants.MINECRAFT_SNAPSHOT, new TIntIntHashMap() );
packetRemap.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() );
packetRemapInv.put(ProtocolConstants.MINECRAFT_1_9, new TIntIntHashMap() );
}
public final DefinedPacket createPacket(int id, int protocol)
@@ -140,7 +140,7 @@ public enum Protocol
{
if ( !remap.containsKey( id ) )
{
throw new BadPacketException( "No packet with id " + id );
return null;
}
id = remap.get( id );
}
@@ -177,9 +177,9 @@ public enum Protocol
packetMap.put( packetClass, id );
packetRemap.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_8 ).put(id, id);
packetRemap.get( ProtocolConstants.MINECRAFT_SNAPSHOT ).put( newId, id );
packetRemapInv.get( ProtocolConstants.MINECRAFT_SNAPSHOT ).put( id, newId );
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_8 ).put( id, id );
packetRemap.get( ProtocolConstants.MINECRAFT_1_9 ).put( newId, id );
packetRemapInv.get( ProtocolConstants.MINECRAFT_1_9 ).put( id, newId );
}
protected final void unregisterPacket(int id)
@@ -191,7 +191,7 @@ public enum Protocol
final int getId(Class<? extends DefinedPacket> packet, int protocol)
{
Preconditions.checkArgument(packetMap.containsKey(packet), "Cannot get ID for packet " + packet);
Preconditions.checkArgument( packetMap.containsKey( packet ), "Cannot get ID for packet " + packet );
int id = packetMap.get( packet );
TIntIntMap remap = packetRemapInv.get( protocol );

View File

@@ -6,10 +6,10 @@ import java.util.List;
public class ProtocolConstants
{
public static final int MINECRAFT_1_8 = 47;
public static final int MINECRAFT_SNAPSHOT = 57;
public static final int MINECRAFT_1_9 = 107;
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
"1.8.X",
"15w33c"
"1.8.x",
"1.9"
);
public enum Direction

View File

@@ -51,7 +51,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
if ( !DIRECT_WARNING )
{
DIRECT_WARNING = true;
System.err.println( "Netty is not using direct IO buffers." );
System.out.println( "Netty is not using direct IO buffers." );
}
// See https://github.com/SpigotMC/BungeeCord/issues/1717

View File

@@ -29,10 +29,10 @@ public class ClientSettings extends DefinedPacket
{
locale = readString( buf );
viewDistance = buf.readByte();
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_SNAPSHOT ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
chatColours = buf.readBoolean();
skinParts = buf.readByte();
if ( protocolVersion >= ProtocolConstants.MINECRAFT_SNAPSHOT )
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
mainHand = DefinedPacket.readVarInt( buf );
}
@@ -43,7 +43,7 @@ public class ClientSettings extends DefinedPacket
{
writeString( locale, buf );
buf.writeByte( viewDistance );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_SNAPSHOT )
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
DefinedPacket.writeVarInt( chatFlags, buf );
} else
@@ -52,7 +52,7 @@ public class ClientSettings extends DefinedPacket
}
buf.writeBoolean( chatColours );
buf.writeByte( skinParts );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_SNAPSHOT )
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
DefinedPacket.writeVarInt(mainHand, buf);
}

View File

@@ -1,38 +1,38 @@
package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class KeepAlive extends DefinedPacket
{
private int randomId;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
randomId = readVarInt( buf );
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeVarInt( randomId, buf );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}
package net.md_5.bungee.protocol.packet;
import net.md_5.bungee.protocol.DefinedPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class KeepAlive extends DefinedPacket
{
private int randomId;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
randomId = readVarInt( buf );
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeVarInt( randomId, buf );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@@ -17,6 +17,7 @@ public class TabCompleteRequest extends DefinedPacket
{
private String cursor;
private boolean assumeCommand;
private boolean hasPositon;
private long position;
@@ -24,6 +25,11 @@ public class TabCompleteRequest extends DefinedPacket
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
cursor = readString( buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
assumeCommand = buf.readBoolean();
}
if ( hasPositon = buf.readBoolean() )
{
position = buf.readLong();
@@ -34,6 +40,11 @@ public class TabCompleteRequest extends DefinedPacket
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeString( cursor, buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
buf.writeBoolean( assumeCommand );
}
buf.writeBoolean( hasPositon );
if ( hasPositon )
{

View File

@@ -25,6 +25,7 @@ public class Team extends DefinedPacket
private String prefix;
private String suffix;
private String nameTagVisibility;
private String collisionRule;
private byte color;
private byte friendlyFire;
private String[] players;
@@ -34,7 +35,6 @@ public class Team extends DefinedPacket
*/
public Team(String name)
{
this();
this.name = name;
this.mode = 1;
}
@@ -51,6 +51,10 @@ public class Team extends DefinedPacket
suffix = readString( buf );
friendlyFire = buf.readByte();
nameTagVisibility = readString( buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
collisionRule = readString(buf);
}
color = buf.readByte();
}
if ( mode == 0 || mode == 3 || mode == 4 )
@@ -76,6 +80,10 @@ public class Team extends DefinedPacket
writeString( suffix, buf );
buf.writeByte( friendlyFire );
writeString( nameTagVisibility, buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
writeString( collisionRule, buf);
}
buf.writeByte( color );
}
if ( mode == 0 || mode == 3 || mode == 4 )