PointHelper.java 680 B

123456789101112131415161718192021
  1. package me.shedaniel.math.impl;
  2. import me.shedaniel.math.api.Point;
  3. import net.minecraft.client.MinecraftClient;
  4. public class PointHelper {
  5. public static Point fromMouse() {
  6. MinecraftClient client = MinecraftClient.getInstance();
  7. double mx = client.mouse.getX() * (double) client.window.getScaledWidth() / (double) client.window.getWidth();
  8. double my = client.mouse.getY() * (double) client.window.getScaledHeight() / (double) client.window.getHeight();
  9. return new Point(mx, my);
  10. }
  11. public static int getMouseX() {
  12. return fromMouse().x;
  13. }
  14. public static int getMouseY() {
  15. return fromMouse().y;
  16. }
  17. }