fantahund / VoxelMap

24 stars 7 forks source link

Mislocated highlight/waypoint when setting via mouse click on MacOS #30

Open blonkers opened 4 months ago

blonkers commented 4 months ago

Hello!

When you click on the map on MacOS to highlight or set a waypoint, the resulting indicator is off. After some debugging it seems that the mouse-to-GUI translation is slightly off (waypoints are indeed positioned correctly on the coordinates the mouse handler provides).

I traced the issue back to these lines.

In my testing, it seems that due to MacOS display 2x scaling, the value returned by VoxelConstants.getMinecraft().mouse.getX() is 2x that of the value directly from the listener, mouseX.

Down the line, these coord values end up being off, since this.centerX (which uses the supplied width, scaled down appropriately), but is given an unscaled mouseDirectToMap, so the value ends up being off, and always up and to the left).

Theoretically, I think you could get away with just using the provided mouseX/mouseY values (untested on Windows though), but I'm not sure if you had a specific reason for pulling from the client instead.

Video example: https://github.com/fantahund/VoxelMap/assets/173017178/b3f0a2e2-01d7-447e-b434-4b9e63e358b1

fantahund commented 4 months ago

Hey, I tried it like you suggested. I'm not sure if I understood it correctly. If you are so kind you can send us a pull request and we will take a closer look at it

xane256 commented 3 months ago

I have an option in Sodium called "Reduce Resolution on MacOS" which I think fixes this. I also have Reese's Sodium Options and Sodium Extra so I'm not 100% sure which one adds that feature. But it greatly improves FPS performance on retina displays.