From 93d21efd3deae232a8f728ab695569f269a14f09 Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Wed, 29 Apr 2020 21:10:05 +0200 Subject: [PATCH] fix enchantments in enchanting table for 1.16 --- .../packets/InventoryPackets.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 d0660f95a..3fd86c30a 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 @@ -21,6 +21,26 @@ public class InventoryPackets { public static void register(Protocol protocol) { ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); + //Window Property + protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.UNSIGNED_BYTE); // Window id + map(Type.SHORT); // Property + map(Type.SHORT); // Value + + handler(wrapper -> { + short property = wrapper.get(Type.SHORT, 0); + if (property >= 4 && property <= 6) { // Enchantment id + short enchantmentId = wrapper.get(Type.SHORT, 1); + if (enchantmentId >= 11) { // soul_speed added with id 11 + wrapper.set(Type.SHORT, 1, ++enchantmentId); + } + } + }); + } + }); + // Set cooldown itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId);