diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt index d0d3948c3..9168f41f7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/DiscreteScrollBarPanel.kt @@ -21,7 +21,7 @@ open class DiscreteScrollBarPanel( override fun innerRender(stack: PoseStack, mouseX: Float, mouseY: Float, partialTick: Float) { if (isScrolling) { ScrollBarConstants.scrollBarButtonPress.render(stack, 0f, 0f) - } else if (isHovered) { + } else if (isHovered && maxScroll.invoke(this@DiscreteScrollBarPanel) > 0) { ScrollBarConstants.scrollBarButtonHover.render(stack, 0f, 0f) } else { ScrollBarConstants.scrollBarButton.render(stack, 0f, 0f) @@ -32,6 +32,10 @@ open class DiscreteScrollBarPanel( private var rememberY = 0.0 override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { + if (maxScroll.invoke(this@DiscreteScrollBarPanel) <= 0) { + return true + } + if (button == InputConstants.MOUSE_BUTTON_LEFT) { isScrolling = true trapMouseInput = true @@ -104,8 +108,15 @@ open class DiscreteScrollBarPanel( } open fun updateScrollButtonPosition() { + val maxScroll = this.maxScroll.invoke(this) + + if (maxScroll <= 0) { + scrollButton.y = 1f + return + } + val availableHeight = height - scrollButton.height - 2f - scrollButton.y = 1f + availableHeight * (scroll.toFloat() / maxScroll.invoke(this)) + scrollButton.y = 1f + availableHeight * (scroll.toFloat() / maxScroll) } open fun scrollChanged(oldScroll: Int, newScroll: Int) {