Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
37 lines
1.2 KiB
Java
Executable File
37 lines
1.2 KiB
Java
Executable File
package eu.crushedpixel.replaymod.utils;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.ScaledResolution;
|
|
import org.lwjgl.input.Mouse;
|
|
import org.lwjgl.util.Point;
|
|
|
|
public class MouseUtils {
|
|
|
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
public static Point getMousePos() {
|
|
Point scaled = getScaledDimensions();
|
|
int width = scaled.getX();
|
|
int height = scaled.getY();
|
|
|
|
final int mouseX = (Mouse.getX() * width / mc.displayWidth);
|
|
final int mouseY = (height - Mouse.getY() * height / mc.displayHeight);
|
|
|
|
return new Point(mouseX, mouseY);
|
|
}
|
|
|
|
public static Point getScaledDimensions() {
|
|
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
|
final int width = sr.getScaledWidth();
|
|
final int heigth = sr.getScaledHeight();
|
|
|
|
return new Point(width, heigth);
|
|
}
|
|
|
|
public static boolean isMouseWithinBounds(int minX, int minY, int width, int height) {
|
|
Point mousePos = getMousePos();
|
|
return mousePos.getX() >= minX && mousePos.getX() <= minX + width
|
|
&& mousePos.getY() >= minY && mousePos.getY() <= minY + height;
|
|
}
|
|
}
|