From 3f4995466cc461bef21c83d571795f6176016798 Mon Sep 17 00:00:00 2001 From: Eclipse-Sol Date: Fri, 24 Jul 2026 21:50:46 -0400 Subject: [PATCH] Fix scrollbar not following mouse (#1961) * Fix scrollbar not following mouse * add /*deobfName*/ --- .../coderbot/iris/gui/element/IrisGuiSlot.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/coderbot/iris/gui/element/IrisGuiSlot.java b/src/main/java/net/coderbot/iris/gui/element/IrisGuiSlot.java index 1a955253b..ef4490781 100644 --- a/src/main/java/net/coderbot/iris/gui/element/IrisGuiSlot.java +++ b/src/main/java/net/coderbot/iris/gui/element/IrisGuiSlot.java @@ -94,6 +94,21 @@ public abstract class IrisGuiSlot extends GuiSlot { if (leftMouseDown && mouseX >= scrollBarX && mouseX <= rightEdge) { scrolling = true; this.initialClickY = (float) mouseY; + + int contentOverflow = this.func_148135_f/*getMaxScroll*/(); + if (contentOverflow < 1) { + contentOverflow = 1; + } + + int scrollPosSize = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); + if (scrollPosSize < 32) { + scrollPosSize = 32; + } + if (scrollPosSize > this.bottom - this.top - 8) { + scrollPosSize = this.bottom - this.top - 8; + } + + this.scrollMultiplier = -1.0F / ((float) (this.bottom - this.top - scrollPosSize) / (float) contentOverflow); } else if ((leftMouseDown || rightMouseDown)) { final int index = relativeY / this.slotHeight; @@ -128,7 +143,7 @@ public abstract class IrisGuiSlot extends GuiSlot { // Scrollbar nonsense if (scrolling) { - this.amountScrolled += ((float) mouseY - this.initialClickY); + this.amountScrolled -= ((float) mouseY - this.initialClickY) * this.scrollMultiplier; this.initialClickY = mouseY; } else if (this.mc.currentScreen != null ){ while (!this.mc.gameSettings.touchscreen && Mouse.next()) {