fix: stop freecam from sinking when toggle sneak is enabled - #599
reusteur73 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Thanks for the fix!
1.4.1 is currently on release candidate, so I'll land this after 1.4.1 has released.
In the mean time, could you switch from an Accessor Mixin to an Access Widener entry and add a change file to .changeset?
(also re #598, you don't need to close/open new PRs. It's perfectly fine to force-push to the existing PR)
(also, I've been doing some CI changes today, so you'll need to rebase on our latest main to run the correct 'required checks')
|
I took a few minutes to address my earlier feedback, so next time you work on this you'll need to overwrite your local branch with what I force-pushed to your GitHub fork. Details
git stash
git fetch --all
git reset --hard @{u}
git stash popNote: Only run I noticed in testing that using the sneak key while in freecam will cause toggle-sneak to togglne upon exiting freecam. Ideally, we'd fix that too. |
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
|
Thanks for the feedback, I hadn't noticed that bug. I tried to implement a fix in |
|
Looking at the diff you pushed up, that should work. Tracking state is never my preferred option, though. Perhaps it's possible for a mixin to prevent the key event propagating to the toggle-sneak binding while If that proves too messy or too fragile, the current solution should be ok. |
MattSturgeon
left a comment
There was a problem hiding this comment.
My instinct is that there's a cleaner approach than storing/restoring remembered initial sneak state, likely involving a mixin.
I suspect we'll also need to give some consideration to the "freecam is active, but in 'control player' mode" scenario.
| private static TripodSlot activeTripod = TripodSlot.NONE; | ||
| private static FreeCamera freeCamera; | ||
| private static CameraType rememberedF5 = null; | ||
| private static boolean sneakStateOnEnable = false; |
There was a problem hiding this comment.
nit(style): Not super important, but maybe we should use the same style as rememberedF5:
| private static boolean sneakStateOnEnable = false; | |
| private static boolean rememberedSneakState = false; |
Also: is there any value in making it nullable? I don't think it is possible to get into a situation where we disable freecam before the remembered state has been populated.
private static Boolean rememberedSneakState = null;| private static void onEnable() { | ||
| MC.smartCull = false; | ||
| outlineEnabled = ModConfig.get().shouldOutlinePlayer(); | ||
| sneakStateOnEnable = MC.options.keyShift.isDown(); |
There was a problem hiding this comment.
If going down the "store state" approach, I think we'll also have to update it if the state changes during "control player" mode; Freecam has an option to toggle control of the player vs the camera while freecam is active.
When Toggle Sneak is enabled (Options > Controls), the sneak
keybind becomes a toggle instead of a hold. Freecam's descend movement reads
that key's
isDown()directly, so if sneak happened to be toggled on, thecamera would just sink forever with no way to stop it besides pressing sneak
again which also toggled the real player's crouch or by pressing jump key.
This makes freecam poll the sneak key's actual physical state instead,
independent of the toggle setting. Descending now works like holding jump to
ascend: only active while the key is actually held down.
Tested on Fabric 26.2. Compiles fine on the other supported versions too
(1.17.1 through 26.1, NeoForge 26.2), but I didn't run those in-game.