kennytv / kennytvs-epic-force-close-loading-screen-mod-for-fabric

https://modrinth.com/mod/forcecloseworldloadingscreen
MIT License
56 stars 5 forks source link

fix sprinting resets after respawning #35

Closed MrKinau closed 4 months ago

MrKinau commented 6 months ago

What?

Fixes https://github.com/kennytv/kennytvs-epic-force-close-loading-screen-mod-for-fabric/issues/34.

Where does the issue come from?

The main issue appears to be, that keys aren't properly updated on death. Vanilla seems to update them if the current screen closes (setScreen(null)), but only if a screen was present (!mouseGrabbed) MouseHandler#grabMouse, which will be called whenever a Minecraft.setScreen(null) is called, unfortunately as the mouse was still grabbed, because the screen got skipped the function to re-check pressed keys is not called.

How to fix?

I fixed it by calling the KeyMapping.setAll() inside MouseHandler#grabMouse() if the mouseGrabbed is true, that way it's guaranteed to be called. Actually just calling if it is not Minecraft.ON_OSX, ig this bug did not happen on OSX. Dunno if this is a valid approach, but it works (on my machine), may be incompatible with #33