From c641f02d7e590a51cff997304ff0fbba07da3bf3 Mon Sep 17 00:00:00 2001 From: Myles Date: Mon, 29 Feb 2016 18:49:31 +0000 Subject: [PATCH] Implement remaining packets, comment out debug info. --- src/main/java/us/myles/ViaVersion/Core.java | 2 +- .../myles/ViaVersion/packets/PacketType.java | 2 +- .../transformers/IncomingTransformer.java | 8 ++--- .../transformers/OutgoingTransformer.java | 31 +++++++++++++++++-- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/Core.java b/src/main/java/us/myles/ViaVersion/Core.java index 8a114e0f2..64471f032 100644 --- a/src/main/java/us/myles/ViaVersion/Core.java +++ b/src/main/java/us/myles/ViaVersion/Core.java @@ -24,7 +24,7 @@ public class Core extends JavaPlugin { try { injectPacketHandler(); } catch (Exception e) { - System.out.println("Unable to inject handlers, this version only supports 1.8.8."); + System.out.println("Unable to inject handlers, are you on 1.8?"); e.printStackTrace(); } } diff --git a/src/main/java/us/myles/ViaVersion/packets/PacketType.java b/src/main/java/us/myles/ViaVersion/packets/PacketType.java index eb596044e..c515b5a0e 100644 --- a/src/main/java/us/myles/ViaVersion/packets/PacketType.java +++ b/src/main/java/us/myles/ViaVersion/packets/PacketType.java @@ -114,7 +114,7 @@ public enum PacketType { PLAY_UPDATE_HEALTH(State.PLAY, Direction.OUTGOING, 0x06, 0x3E), PLAY_SCOREBOARD_OBJ(State.PLAY, Direction.OUTGOING, 0x3B, 0x3F), PLAY_SET_PASSENGERS(State.PLAY, Direction.OUTGOING, -1, 0x40), - PLAY_TEAMS(State.PLAY, Direction.OUTGOING, 0x3E, 0x41), + PLAY_TEAM(State.PLAY, Direction.OUTGOING, 0x3E, 0x41), PLAY_UPDATE_SCORE(State.PLAY, Direction.OUTGOING, 0x3C, 0x42), PLAY_SPAWN_POSITION(State.PLAY, Direction.OUTGOING, 0x05, 0x43), PLAY_TIME_UPDATE(State.PLAY, Direction.OUTGOING, 0x03, 0x44), diff --git a/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java index 6368a7464..dc90d56ba 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/IncomingTransformer.java @@ -33,9 +33,9 @@ public class IncomingTransformer { if (packet.getPacketID() != -1) { packetID = packet.getPacketID(); } - if (packet != PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST && packet != PacketType.PLAY_KEEP_ALIVE_REQUEST && packet != PacketType.PLAY_PLAYER_POSITION_REQUEST && packet != PacketType.PLAY_PLAYER_LOOK_REQUEST) { - System.out.println("Packet Type: " + packet + " New ID: " + packetID + " Original: " + original); - } +// if (packet != PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST && packet != PacketType.PLAY_KEEP_ALIVE_REQUEST && packet != PacketType.PLAY_PLAYER_POSITION_REQUEST && packet != PacketType.PLAY_PLAYER_LOOK_REQUEST) { +// System.out.println("Packet Type: " + packet + " New ID: " + packetID + " Original: " + original); +// } if (packet == PacketType.PLAY_TP_CONFIRM) { throw new CancelException(); } @@ -167,7 +167,7 @@ public class IncomingTransformer { int face = PacketUtil.readVarInt(input); output.writeByte(face); int hand = PacketUtil.readVarInt(input); - + ItemStack inHand = Core.getHandItem(info); Object item = null; try { diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index cd9e0cfbf..135519c25 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -45,8 +45,8 @@ public class OutgoingTransformer { if (packet == null) { throw new RuntimeException("Outgoing Packet not found? " + packetID + " State: " + info.getState() + " Version: " + info.getProtocol()); } - if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE && !packet.name().toLowerCase().contains("entity")) - System.out.println("Packet Type: " + packet + " Original ID: " + packetID + " State:" + info.getState()); +// if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE && !packet.name().toLowerCase().contains("entity")) +// System.out.println("Packet Type: " + packet + " Original ID: " + packetID + " State:" + info.getState()); if (packet.getPacketID() != -1) { packetID = packet.getNewPacketID(); } @@ -301,6 +301,33 @@ public class OutgoingTransformer { return; } + if(packet == PacketType.PLAY_MAP) { + int damage = PacketUtil.readVarInt(input); + PacketUtil.writeVarInt(damage, output); + byte scale = input.readByte(); + output.writeByte(scale); + input.readBoolean(); + output.writeBytes(input); + return; + } + if(packet == PacketType.PLAY_TEAM) { + String teamName = PacketUtil.readString(input); + PacketUtil.writeString(teamName, output); + byte mode = input.readByte(); + output.writeByte(mode); + if(mode == 0 || mode == 2){ + PacketUtil.writeString(PacketUtil.readString(input), output); + PacketUtil.writeString(PacketUtil.readString(input), output); + PacketUtil.writeString(PacketUtil.readString(input), output); + + output.writeByte(input.readByte()); + PacketUtil.writeString(PacketUtil.readString(input), output); + + PacketUtil.readString(input); // collission rule :) + } + output.writeBytes(input); + return; + } if (packet == PacketType.PLAY_CHUNK_DATA) { // We need to catch unloading chunk packets as defined by wiki.vg // To unload chunks, send this packet with Ground-Up Continuous=true and no 16^3 chunks (eg. Primary Bit Mask=0)