From 408bd491202b9c11294ad2a7d45e37f07b6e173b Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sat, 10 Nov 2018 08:41:22 -0200 Subject: [PATCH] fix set cooldown --- .../Protocol1_13_1To1_13.java | 16 ++++++++ .../Protocol1_13To1_12_2.java | 40 ++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java index ff162030d..e06278f9d 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/Protocol1_13_1To1_13.java @@ -90,6 +90,22 @@ public class Protocol1_13_1To1_13 extends Protocol { } }); + // Set cooldown + registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // Item + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + wrapper.set(Type.VAR_INT, 0, + InventoryPackets.getNewItemId(wrapper.get(Type.VAR_INT, 0)) + ); + } + }); + } + }); + // Boss bar registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index de7d4e8c0..dc44c6688 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -223,7 +223,45 @@ public class Protocol1_13To1_12_2 extends Protocol { // InventoryPackets 0x14 -> 0x15 // InventoryPackets 0x15 -> 0x16 // InventoryPackets 0x16 -> 0x17 - registerOutgoing(State.PLAY, 0x17, 0x18); + // Set cooldown + registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int item = wrapper.read(Type.VAR_INT); + int ticks = wrapper.read(Type.VAR_INT); + wrapper.cancel(); + if (item == 383) { // Spawn egg + for (int i = 0; i < 44; i++) { + Integer newItem = MappingData.oldToNewItems.get(item << 16 | i); + if (newItem != null) { + PacketWrapper packet = wrapper.create(0x18); + packet.write(Type.VAR_INT, newItem); + packet.write(Type.VAR_INT, ticks); + packet.send(Protocol1_13To1_12_2.class); + } else { + break; + } + } + } else { + for (int i = 0; i < 16; i++) { + Integer newItem = MappingData.oldToNewItems.get(item << 4 | i); + if (newItem != null) { + PacketWrapper packet = wrapper.create(0x18); + packet.write(Type.VAR_INT, newItem); + packet.write(Type.VAR_INT, ticks); + packet.send(Protocol1_13To1_12_2.class); + } else { + break; + } + } + } + } + }); + } + }); // WorldPackets 0x18 -> 0x19 registerOutgoing(State.PLAY, 0x1A, 0x1B); registerOutgoing(State.PLAY, 0x1B, 0x1C);