aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java
blob: d5ad44b1df2a90990e0e4dcd5398443485cc9d64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package io.polyfrost.oneconfig.utils;

import net.minecraft.client.Minecraft;
import org.lwjgl.input.Mouse;

public class InputUtils {
    /**
     * function to determine weather the mouse is currently over a specific region. Uses the current nvgScale to fix to any scale.
     * @return true if mouse is over region, false if not.
     */
    public static boolean isAreaHovered(int x, int y, int width, int height) {
        int mouseX = Mouse.getX();
        int mouseY = Minecraft.getMinecraft().displayHeight - Math.abs(Mouse.getY());
        return mouseX > x && mouseY > y && mouseX < x + width && mouseY < y + height;       // TODO add scaling info
    }
}