From 0576a7f5304565bb58a499b8ccdcda31ed587dc4 Mon Sep 17 00:00:00 2001 From: Appability Date: Sun, 23 Oct 2022 12:00:05 -0700 Subject: ping command and display --- src/main/kotlin/com/ambientaddons/gui/MoveGui.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/com/ambientaddons/gui/MoveGui.kt') diff --git a/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt b/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt index 33c96e7..61bb41b 100644 --- a/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt +++ b/src/main/kotlin/com/ambientaddons/gui/MoveGui.kt @@ -11,6 +11,7 @@ import net.minecraft.client.renderer.GlStateManager import org.lwjgl.input.Mouse import org.lwjgl.opengl.Display import java.awt.Color +import kotlin.math.sign class MoveGui : GuiScreen() { private var currentElement: GuiElement? = null @@ -53,12 +54,12 @@ class MoveGui : GuiScreen() { override fun handleMouseInput() { super.handleMouseInput() val (mouseX, mouseY) = getMouseCoordinates() + val dScroll = (Mouse.getEventDWheel().sign * 0.1).takeIf { it != 0.0 } ?: return currentElement = guiElements.find { it.isInsideElement(mouseX, mouseY) }?.apply { clickOffsetX = mouseX - position.x clickOffsetY = mouseY - position.y - val scrollAmount = Mouse.getEventDWheel() val oldScale = position.scale - val newScale = (position.scale + scrollAmount / 7200.0).coerceAtLeast(0.1) + val newScale = (position.scale + dScroll).coerceAtLeast(0.1) position.x = mouseX + (newScale / oldScale) * (position.x - mouseX) position.y = mouseY + (newScale / oldScale) * (position.y - mouseY) position.scale = newScale -- cgit