From 1296783d9bd9ce13dfcd665935e7c28f8bf43ba1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 1 Jul 2013 13:19:18 +1000 Subject: [PATCH] Update to Minecraft 1.6.1 --- .../java/net/md_5/bungee/protocol/OpCode.java | 2 +- .../net/md_5/bungee/protocol/Vanilla.java | 23 ++++---- .../packet/AbstractPacketHandler.java | 4 ++ .../packet/Packet2CEntityProperties.java | 52 +++++++++++++++++++ .../bungee/protocol/skip/Instruction.java | 1 + .../bungee/protocol/skip/OptionalWindow.java | 21 ++++++++ .../main/java/net/md_5/bungee/BungeeCord.java | 3 +- .../java/net/md_5/bungee/UserConnection.java | 3 +- 8 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet2CEntityProperties.java create mode 100644 protocol/src/main/java/net/md_5/bungee/protocol/skip/OptionalWindow.java diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/OpCode.java b/protocol/src/main/java/net/md_5/bungee/protocol/OpCode.java index 29d6db3e6..e201c5c82 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/OpCode.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/OpCode.java @@ -3,5 +3,5 @@ package net.md_5.bungee.protocol; public enum OpCode { - BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, USHORT_BYTE + BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, USHORT_BYTE, OPTIONAL_WINDOW } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Vanilla.java b/protocol/src/main/java/net/md_5/bungee/protocol/Vanilla.java index 49c678b8b..ad32dda13 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Vanilla.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Vanilla.java @@ -1,7 +1,6 @@ package net.md_5.bungee.protocol; import io.netty.buffer.ByteBuf; -import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import lombok.Getter; @@ -9,6 +8,7 @@ import static net.md_5.bungee.protocol.OpCode.*; import net.md_5.bungee.protocol.packet.DefinedPacket; import net.md_5.bungee.protocol.packet.Packet0KeepAlive; import net.md_5.bungee.protocol.packet.Packet1Login; +import net.md_5.bungee.protocol.packet.Packet2CEntityProperties; import net.md_5.bungee.protocol.packet.Packet2Handshake; import net.md_5.bungee.protocol.packet.Packet3Chat; import net.md_5.bungee.protocol.packet.Packet9Respawn; @@ -29,8 +29,8 @@ import net.md_5.bungee.protocol.skip.PacketReader; public class Vanilla implements Protocol { - public static final byte PROTOCOL_VERSION = 61; - public static final String GAME_VERSION = "1.5.2"; + public static final byte PROTOCOL_VERSION = 73; + public static final String GAME_VERSION = "1.6.1"; @Getter private static final Vanilla instance = new Vanilla(); /*========================================================================*/ @@ -54,6 +54,7 @@ public class Vanilla implements Protocol classes[0x03] = Packet3Chat.class; classes[0x09] = Packet9Respawn.class; classes[0xC9] = PacketC9PlayerListItem.class; + classes[0x2C] = Packet2CEntityProperties.class; classes[0xCC] = PacketCCSettings.class; classes[0xCD] = PacketCDClientStatus.class; classes[0xCE] = PacketCEScoreboardObjective.class; @@ -141,7 +142,7 @@ public class Vanilla implements Protocol }; opCodes[0x08] = new OpCode[] { - SHORT, SHORT, FLOAT + FLOAT, SHORT, FLOAT }; opCodes[0x0A] = new OpCode[] { @@ -181,7 +182,7 @@ public class Vanilla implements Protocol }; opCodes[0x13] = new OpCode[] { - INT, BYTE + INT, BYTE, INT }; opCodes[0x14] = new OpCode[] { @@ -207,6 +208,10 @@ public class Vanilla implements Protocol { INT, INT, INT, INT, SHORT }; + opCodes[0x1B] = new OpCode[] + { + FLOAT, FLOAT, BOOLEAN, BOOLEAN + }; opCodes[0x1C] = new OpCode[] { INT, SHORT, SHORT, SHORT @@ -245,7 +250,7 @@ public class Vanilla implements Protocol }; opCodes[0x27] = new OpCode[] { - INT, INT + INT, INT, BOOLEAN }; opCodes[0x28] = new OpCode[] { @@ -313,7 +318,7 @@ public class Vanilla implements Protocol }; opCodes[0x64] = new OpCode[] { - BYTE, BYTE, STRING, BYTE, BOOLEAN + OPTIONAL_WINDOW }; opCodes[0x65] = new OpCode[] { @@ -365,11 +370,11 @@ public class Vanilla implements Protocol }; opCodes[0xC8] = new OpCode[] { - INT, BYTE + INT, INT }; opCodes[0xCA] = new OpCode[] { - BYTE, BYTE, BYTE + BYTE, FLOAT, FLOAT }; opCodes[0xCB] = new OpCode[] { diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/AbstractPacketHandler.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/AbstractPacketHandler.java index 9b859bc60..795661f22 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/AbstractPacketHandler.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/AbstractPacketHandler.java @@ -23,6 +23,10 @@ public abstract class AbstractPacketHandler { } + public void handle(Packet2CEntityProperties properties) throws Exception + { + } + public void handle(PacketC9PlayerListItem playerList) throws Exception { } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet2CEntityProperties.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet2CEntityProperties.java new file mode 100644 index 000000000..3a253bab2 --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Packet2CEntityProperties.java @@ -0,0 +1,52 @@ +package net.md_5.bungee.protocol.packet; + +import io.netty.buffer.ByteBuf; +import java.util.HashMap; +import java.util.Map; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +@Getter +@ToString +@EqualsAndHashCode(callSuper = false) +public class Packet2CEntityProperties extends DefinedPacket +{ + + private int entityId; + private Map data = new HashMap<>(); + + public Packet2CEntityProperties() + { + super( 0x2C ); + } + + @Override + public void read(ByteBuf buf) + { + entityId = buf.readInt(); + int recordCount = buf.readInt(); + for ( int i = 0; i < recordCount; i++ ) + { + data.put( readString( buf ), buf.readDouble() ); + } + } + + @Override + public void write(ByteBuf buf) + { + buf.writeInt( entityId ); + buf.writeInt( data.size() ); + for ( Map.Entry entry : data.entrySet() ) + { + writeString( entry.getKey(), buf ); + buf.writeDouble( entry.getValue() ); + } + } + + @Override + public void handle(AbstractPacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/skip/Instruction.java b/protocol/src/main/java/net/md_5/bungee/protocol/skip/Instruction.java index 801b48b96..b85feeeb5 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/skip/Instruction.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/skip/Instruction.java @@ -23,6 +23,7 @@ abstract class Instruction static final Instruction SHORT_ITEM = new ShortHeader( ITEM ); static final Instruction STRING = new ShortHeader( new Jump( 2 ) ); static final Instruction USHORT_BYTE = new UnsignedShortByte(); + static final Instruction OPTIONAL_WINDOW = new OptionalWindow(); // Illegal forward references below this line static final Instruction BYTE_INT = new ByteHeader( INT ); // Custom instructions diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/skip/OptionalWindow.java b/protocol/src/main/java/net/md_5/bungee/protocol/skip/OptionalWindow.java new file mode 100644 index 000000000..1fc71340c --- /dev/null +++ b/protocol/src/main/java/net/md_5/bungee/protocol/skip/OptionalWindow.java @@ -0,0 +1,21 @@ +package net.md_5.bungee.protocol.skip; + +import io.netty.buffer.ByteBuf; + +public class OptionalWindow extends Instruction +{ + + @Override + void read(ByteBuf in) + { + BYTE.read( in ); + byte type = in.readByte(); + STRING.read( in ); + BYTE.read( in ); + BOOLEAN.read( in ); + if ( type == 11 ) + { + INT.read( in ); + } + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 9e86e754c..bd727d7df 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -487,7 +487,8 @@ public class BungeeCord extends ProxyServer public void broadcast(String message) { getConsole().sendMessage( message ); - broadcast( new Packet3Chat( message ) ); + // TODO: Here too + broadcast( new Packet3Chat( "{\"text\":\"" + message + "\"}" )); } public void addConnection(UserConnection con) diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 2b6807c7a..2c4c80a4c 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -265,7 +265,8 @@ public final class UserConnection implements ProxiedPlayer @Override public void sendMessage(String message) { - unsafe().sendPacket( new Packet3Chat( message ) ); + // TODO: Fix this + unsafe().sendPacket( new Packet3Chat( "{\"text\":\"" + message + "\"}" ) ); } @Override