PointHelper.java 803 B

123456789101112131415161718192021222324
  1. package me.shedaniel.math.impl;
  2. import me.shedaniel.math.Point;
  3. import net.fabricmc.api.EnvType;
  4. import net.fabricmc.api.Environment;
  5. import net.minecraft.client.Minecraft;
  6. @Environment(EnvType.CLIENT)
  7. public class PointHelper {
  8. public static Point ofMouse() {
  9. Minecraft client = Minecraft.getInstance();
  10. double mx = client.mouseHandler.xpos() * (double) client.getWindow().getGuiScaledWidth() / (double) client.getWindow().getScreenWidth();
  11. double my = client.mouseHandler.ypos() * (double) client.getWindow().getGuiScaledHeight() / (double) client.getWindow().getScreenHeight();
  12. return new Point(mx, my);
  13. }
  14. public static int getMouseX() {
  15. return ofMouse().x;
  16. }
  17. public static int getMouseY() {
  18. return ofMouse().y;
  19. }
  20. }