From 3d083cf463843902e94d1115789b6b62ca7a2774 Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Mon, 17 Jun 2024 16:39:01 +0200 Subject: [PATCH] Add handleMenuType function to ItemRewriter (#3953) --- .../viaversion/rewriter/ItemRewriter.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java index ea8e9427e..ab0d70f2d 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -112,20 +112,22 @@ public class ItemRewriter { - final int windowType = wrapper.read(Types.VAR_INT); - final int mappedId = protocol.getMappingData().getMenuMappings().getNewId(windowType); - if (mappedId == -1) { - wrapper.cancel(); - return; - } - - wrapper.write(Types.VAR_INT, mappedId); - }); + handler(wrapper -> handleMenuType(wrapper)); } }); } + public void handleMenuType(final PacketWrapper wrapper) { + final int windowType = wrapper.read(Types.VAR_INT); + final int mappedId = protocol.getMappingData().getMenuMappings().getNewId(windowType); + if (mappedId == -1) { + wrapper.cancel(); + return; + } + + wrapper.write(Types.VAR_INT, mappedId); + } + public void registerSetSlot(C packetType) { protocol.registerClientbound(packetType, new PacketHandlers() { @Override