From 958f853c0f63e072c7b29153653954d18cf4ccaa Mon Sep 17 00:00:00 2001 From: 4gname Date: Sat, 15 Jan 2022 18:33:38 +0700 Subject: [PATCH] fix scroll (cherry picked from commit f3bb27cf7a6e685f3bc5b60936e75616fff99f83) --- .../github/vfyjxf/nee/client/GuiHandler.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java b/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java index 80881a5..93e1975 100644 --- a/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/client/GuiHandler.java @@ -47,20 +47,22 @@ public class GuiHandler implements INEIGuiHandler { public void onRenderTick(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { Minecraft mc = Minecraft.getMinecraft(); - int dWheel = Mouse.getDWheel(); boolean isPatternTerm = mc.currentScreen instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(mc.currentScreen); boolean isInterface = mc.currentScreen instanceof GuiInterface; - if (dWheel != 0 && (isPatternTerm || isInterface)) { - int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth; - int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1; - Slot currentSlot = ((GuiContainer) mc.currentScreen).getSlotAtPosition(x, y); - if (currentSlot instanceof SlotFake && currentSlot.getHasStack()) { - //try to change current itemstack to next ingredient; - if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.ingredient")) && GuiUtils.isCraftingSlot(currentSlot)) { - handleRecipeIngredientChange((GuiContainer) mc.currentScreen, currentSlot, dWheel); - } else if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.count"))) { - int changeCount = dWheel / 120; - NEENetworkHandler.getInstance().sendToServer(new PacketStackCountChange(currentSlot.slotNumber, changeCount)); + if (isPatternTerm || isInterface) { + int dWheel = Mouse.getDWheel(); + if (dWheel != 0) { + int x = Mouse.getEventX() * mc.currentScreen.width / mc.displayWidth; + int y = mc.currentScreen.height - Mouse.getEventY() * mc.currentScreen.height / mc.displayHeight - 1; + Slot currentSlot = ((GuiContainer) mc.currentScreen).getSlotAtPosition(x, y); + if (currentSlot instanceof SlotFake && currentSlot.getHasStack()) { + //try to change current itemstack to next ingredient; + if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.ingredient")) && GuiUtils.isCraftingSlot(currentSlot)) { + handleRecipeIngredientChange((GuiContainer) mc.currentScreen, currentSlot, dWheel); + } else if (Keyboard.isKeyDown(NEIClientConfig.getKeyBinding("nee.count"))) { + int changeCount = dWheel / 120; + NEENetworkHandler.getInstance().sendToServer(new PacketStackCountChange(currentSlot.slotNumber, changeCount)); + } } } }