From 0acc2f95fb76a34b6c863444fb195ba030b085be Mon Sep 17 00:00:00 2001 From: Hugo Kerstens Date: Thu, 31 Mar 2016 15:08:19 +0200 Subject: [PATCH 1/2] Remove unneeded code --- .../protocol1_9to1_8/packets/PlayerPackets.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java index 41d090d8b..0349a6374 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/PlayerPackets.java @@ -150,6 +150,7 @@ public class PlayerPackets { int entityID = wrapper.get(Type.INT, 0); EntityTracker tracker = wrapper.user().get(EntityTracker.class); tracker.getClientEntityTypes().put(entityID, EntityType.PLAYER); + tracker.setEntityID(entityID); } }); map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode @@ -158,15 +159,6 @@ public class PlayerPackets { map(Type.UNSIGNED_BYTE); // 4 - Max Players (Tab) map(Type.STRING); // 5 - Level Type map(Type.BOOLEAN); // 6 - Reduced Debug info - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int myID = wrapper.get(Type.INT, 0); - EntityTracker tracker = wrapper.user().get(EntityTracker.class); - tracker.setEntityID(myID); - } - }); } }); From 41d5144b57b6a185e3720028848fcabfe09d5ab4 Mon Sep 17 00:00:00 2001 From: Matsv Date: Thu, 31 Mar 2016 16:28:56 +0200 Subject: [PATCH 2/2] Handle discontinued player item in hand, fixes #299 --- .../packets/SpawnPackets.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java index d8c4bad11..5261423e9 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/SpawnPackets.java @@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets; import org.bukkit.entity.EntityType; import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; @@ -253,7 +254,24 @@ public class SpawnPackets { map(Type.BYTE); // 5 - Yaw map(Type.BYTE); // 6 - Pitch - map(Type.SHORT, Type.NOTHING); // Current Item is discontinued + handler(new PacketHandler() { //Handle discontinued player hand item + @Override + public void handle(PacketWrapper wrapper) throws Exception { + short item = wrapper.read(Type.SHORT); + System.out.println(item); + if (item != 0) { + PacketWrapper packet = new PacketWrapper(0x3C, null, wrapper.user()); + packet.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0)); + packet.write(Type.VAR_INT, 1); + packet.write(Type.ITEM, new Item(item, (byte) 1, (short) 0, null)); + try { + packet.send(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + }); map(Protocol1_9TO1_8.METADATA_LIST);