fix: dodge compatibility with BetterThirdPerson#386
Open
Farenheith wants to merge 3 commits intoalRex-U:mainfrom
Open
fix: dodge compatibility with BetterThirdPerson#386Farenheith wants to merge 3 commits intoalRex-U:mainfrom
Farenheith wants to merge 3 commits intoalRex-U:mainfrom
Conversation
a763f4d to
746c506
Compare
ea4e6e2 to
2ab93cb
Compare
Contributor
Author
|
@alRex-U this is ready for review! Thank you for the discussion in the issue! It really helped me to find a way to solve the problem. |
2ab93cb to
a3218be
Compare
a3218be to
5df7957
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solves #383
MovementInputMixin captures keyboard movement input at its most raw moment, and serves the purpose of accessing its values before any transformation Minecraft or BetterThirdPerson do. It'll always provide a movement vector not even aligned with world coordinates.
The InputUpdateEvent is the second entry point for movement events, which will serve the purpose of capturing movements done by gamepads. An if is made to ignore the event if a keyboard movement input has not been consumed yet. Why? Because BetterThirdPerson captures both moments and manipulates the vector in both of them, we need to do the same in order not to access already transformed inputs.
When the captured vector is consumed, an alignment to the current camera is done so it'll correspond to the direction the player wants. The camera can be defined by BetterThirdPerson, ShoulderSurfing, or the vanilla one, depending on which option the player is using. The alignment is only done during the getLastMoveVector call as it'll be called by the Dodge action once it confirms a dodge must be done, so we avoid doing unneeded calculations at each input, and we give a chance to the camera mods to do their thing with the perspective.
This way, we solve keyboard and gamepad users, and they have a working dodge with BetterThirdPerson.
This approach has also been tested with ShoulderSurfing and Vanilla Camera, and it works equally with every one of them.
I haven't tested it with Controlify, though, as it doesn't support Minecraft 1.16.5 or Forge. I'll revisit the topic once this PR is accepted and the modification is ported to a compatible version. I tested it only with controllable.Also tested with controlify (see #390)