From 42dd7e3fb5a7abed6f2afce0b7858f7e91c278d2 Mon Sep 17 00:00:00 2001 From: Pxx500 <81298696+Pxx500@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:08:28 +0200 Subject: [PATCH] fix compartments with tool station (#116) --- .../minecraft/control/ControlSlot.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlot.java b/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlot.java index 56372484..d2985d16 100644 --- a/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlot.java +++ b/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlot.java @@ -20,10 +20,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.IIcon; +import org.lwjgl.input.Mouse; + import binnie.core.craftgui.CraftGUI; import binnie.core.craftgui.IWidget; import binnie.core.craftgui.Tooltip; import binnie.core.craftgui.events.EventMouse; +import binnie.core.craftgui.events.EventWidget; import binnie.core.craftgui.geometry.IArea; import binnie.core.craftgui.geometry.IPoint; import binnie.core.craftgui.minecraft.CustomSlot; @@ -61,22 +64,17 @@ public class ControlSlot extends ControlSlotBase { @Override public void onEvent(EventMouse.Down event) { - if (slot == null) { - return; - } + clickSlot(event.getButton()); + } + }); + addSelfEventHandler(new EventWidget.StartMouseOver.Handler() { - PlayerControllerMP playerController = ((Window) getSuperParent()).getGui() - .getMinecraft().playerController; - int windowId = ((Window) getSuperParent()).getContainer().windowId; - int slotNumber = slot.slotNumber; - int button = event.getButton(); - Window.get(getWidget()).getGui(); - playerController.windowClick( - windowId, - slotNumber, - button, - GuiScreen.isShiftKeyDown() ? 1 : 0, - ((Window) getSuperParent()).getGui().getMinecraft().thePlayer); + @Override + public void onEvent(EventWidget.StartMouseOver event) { + if (GuiScreen.isShiftKeyDown() && Mouse.isButtonDown(0) + && Window.get(ControlSlot.this).getDraggedWidget() instanceof ControlSlot) { + clickSlot(0); + } } }); } @@ -92,6 +90,19 @@ public class ControlSlot extends ControlSlotBase { return this; } + private void clickSlot(int button) { + if (slot == null) return; + + Window window = (Window) getSuperParent(); + PlayerControllerMP playerController = window.getGui().getMinecraft().playerController; + playerController.windowClick( + window.getContainer().windowId, + slot.slotNumber, + button, + GuiScreen.isShiftKeyDown() ? 1 : 0, + window.getGui().getMinecraft().thePlayer); + } + @Override public void onRenderBackground() { CraftGUI.render.texture(slotTexture, IPoint.ZERO);