From c4b447f7b6bd486e0a3e5ceda1c90fe807930a9d Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sat, 8 Feb 2020 21:33:44 +0100 Subject: [PATCH] Handle items in cooldown packet --- .../Protocol1_13_1To1_13.java | 16 ---------------- .../packets/InventoryPackets.java | 3 +++ .../packets/InventoryPackets.java | 1 - .../Protocol1_13To1_12_2.java | 2 ++ .../Protocol1_14To1_13_2.java | 2 -- .../packets/InventoryPackets.java | 3 +++ .../Protocol1_15To1_14_4.java | 1 - .../packets/InventoryPackets.java | 3 +++ .../packets/InventoryPackets.java | 3 +++ 9 files changed, 14 insertions(+), 20 deletions(-) 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 14895b5e6..69f57e38b 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 @@ -93,22 +93,6 @@ 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_13_1to1_13/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java index e7408b318..17815507f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_1to1_13/packets/InventoryPackets.java @@ -14,6 +14,9 @@ public class InventoryPackets { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); + // Set cooldown + itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId); + // Set slot packet itemRewriter.registerSetSlot(Type.FLAT_ITEM, 0x17, 0x17); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java index 750f75eba..65382aab6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/packets/InventoryPackets.java @@ -137,5 +137,4 @@ public class InventoryPackets { } ); } - } 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 974ee6fb4..1d63b7c9a 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 @@ -339,9 +339,11 @@ public class Protocol1_13To1_12_2 extends Protocol { }); } }); + // InventoryPackets 0x14 -> 0x15 // InventoryPackets 0x15 -> 0x16 // InventoryPackets 0x16 -> 0x17 + // Set cooldown registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java index af06b4a17..b1c30ef2f 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java @@ -34,8 +34,6 @@ public class Protocol1_14To1_13_2 extends Protocol { registerOutgoing(State.PLAY, 0x16, 0x15); - registerOutgoing(State.PLAY, 0x18, 0x17); - registerOutgoing(State.PLAY, 0x1A, 0x19); registerOutgoing(State.PLAY, 0x1B, 0x1A); registerOutgoing(State.PLAY, 0x1C, 0x1B); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java index 348d3b3bc..8b00344d1 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java @@ -28,6 +28,9 @@ public class InventoryPackets { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); + // Set cooldown + itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId); + // Open Inventory protocol.registerOutgoing(State.PLAY, 0x14, -1, new PacketRemapper() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java index 244b3c7e3..080c41459 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java @@ -171,7 +171,6 @@ public class Protocol1_15To1_14_4 extends Protocol { registerOutgoing(State.PLAY, 0x15, 0x16); - registerOutgoing(State.PLAY, 0x17, 0x18); registerOutgoing(State.PLAY, 0x18, 0x19); registerOutgoing(State.PLAY, 0x19, 0x1A); registerOutgoing(State.PLAY, 0x1A, 0x1B); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java index b05901268..39753bf10 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/packets/InventoryPackets.java @@ -16,6 +16,9 @@ public class InventoryPackets { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); + // Set cooldown + itemRewriter.registerSetCooldown(0x17, 0x18, InventoryPackets::getNewItemId); + // Window items packet itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java index f28148db7..f0cf65cdf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/InventoryPackets.java @@ -14,6 +14,9 @@ public class InventoryPackets { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); + // Set cooldown + itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId); + // Window items packet itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x15);