Skip to content

Improvements to the current Flick Stick implementation #626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: multiversion/dev
Choose a base branch
from

Conversation

Lokito23
Copy link

@Lokito23 Lokito23 commented Jul 5, 2025

Description

This Pull Request is made to attempt to fix some of the issues that the current implementation of the Flick Stick has.

I could try to add other additions, but I would probably need help implementing some. Comment if you have ideas for another feature for the Flick Stick.


Progress

Status

Currently everything is implemented, but needs testing. I have tested it with Fabric 1.21.7 and it works. Old versions should work too, but since I can't compile all the versions, I can't test that.

@Lokito23
Copy link
Author

Lokito23 commented Jul 5, 2025

I would prefer if when turning the Animation timer into 1 it displayed "None" or something akin to that, but I do not know how to implement that.

@Lokito23
Copy link
Author

Lokito23 commented Jul 6, 2025

I can't seem to find a way to get the camera's yaw. I'm guessing it would be within the minecraft.player class, but I can't seem to find where.

Or it could be within minecraft.camera, but I'm unsure if importing it is a good idea.

@isXander
Copy link
Owner

isXander commented Jul 6, 2025

yaw in yRot in mojmap

@isXander
Copy link
Owner

isXander commented Jul 6, 2025

I would prefer if when turning the Animation timer into 1 it displayed "None" or something akin to that, but I do not know how to implement that.

.formatValue on the controller

@Lokito23
Copy link
Author

Lokito23 commented Jul 6, 2025

I would prefer if when turning the Animation timer into 1 it displayed "None" or something akin to that, but I do not know how to implement that.

.formatValue on the controller

I'll try using ticksToMillis, but that requires me to implement a check that turns off the animation when it is 0, since 1 tick is 50ms.

@Lokito23
Copy link
Author

Lokito23 commented Jul 6, 2025

Got the toggle working properly, now it's just getting the flick stick working as planned.

EDIT: And changing the strings, since they mention ticks.

@Lokito23
Copy link
Author

Lokito23 commented Jul 6, 2025

yaw in yRot in mojmap

I'm guessing the camera's yRot? The player also has one, being inherited from entity, but I'm unsure as to which...

@Lokito23
Copy link
Author

Lokito23 commented Jul 10, 2025

I have found Camera.getYRot() but I can't seem to be able to use it.

As for the variable yawOrigin, I'm not sure if the value would persist on each call, so it probably needs to be declared outside.

Also, does digitalNow() respect the deadzones? I plan to use it in order to detect when the stick first moved, in order to assign the value to yawOrigin.

@Lokito23
Copy link
Author

I'm really not sure as to how to get the player's camera, since

import net.minecraft.client.Camera
// Other imports

public class InGameInputHandler {
  private final Camera camera
  ...

Doesn't seem to work. I'm guessing I have to initialize the camera to something, like most of the things inside the function public InGameInputHandler, but I don't know to what.

@Lokito23
Copy link
Author

As for the variable yawOrigin, I'm not sure if the value would persist on each call, so it probably needs to be declared outside.

It indeed needed to be declared outside.

I am currently trying to test what happens if I use the player's yHeadRot instead...
My guess is that it might work, but would break Free-Look like mods (Better Third Person, for instance).

@Lokito23
Copy link
Author

I am currently trying to test what happens if I use the player's yHeadRot instead... My guess is that it might work, but would break Free-Look like mods (Better Third Person, for instance).

About that... It breaks the stick orientation fix (AKA the + 90f in flickAngle). Can't seem to find a way to fix that, since the current method is taking the flick stick's direction as an actual angle.

The current method described probably doesn't work for that reason, so I'll edit that out.

@Lokito23
Copy link
Author

So, that means we would need a way to get the original yaw, and use it as an anchor in order to turn based on flickAngle, without messing up the orientation fix.

@Lokito23
Copy link
Author

Lokito23 commented Jul 27, 2025

So, that means we would need a way to get the original yaw, and use it as an anchor in order to turn based on flickAngle, without messing up the orientation fix.

Found the solution, turns out I was doing the calculations wrong... (oops)

The formula in order to calculate the angle where the camera should be would be:

(yawOrigin + flickAngle) - yawCurrent

Combined with a call to `Mth.wrapDegrees()`, it would end up looking like this: This is in order to stop the camera from doing a 360 flick when switching from back-left to back-right and vice versa

float yawTurn = Mth.wrapDegrees((float) (yawOrigin + flickAngle) - yawCurrent);

@Lokito23
Copy link
Author

Lokito23 commented Jul 27, 2025

As for implementing it, I still have a doubt:

I figured out that the camera divides the movement by 15º increments, hence having to divide by 0.15, in order to disable that.

TL;DR: I was right with it being a Vanilla animation.

1. What does the / 0.15 do within the player.turn() calls do? I'm guessing it's done in an attempt to get the flick stick to snap into 90 degree angles, instead of having it flick you into the angle you held. It also disables an animation, which I am guessing is coming from Vanilla?
How could I get the camera's yRot? I know that the Camera class has the `getYRot()` function for that, but I don't know how to import the camera object. See the previous comment for more context.

Beyond that doubt, I'm pretty sure I can implement it to this PR.

@Lokito23
Copy link
Author

Lokito23 commented Jul 27, 2025

I am currently trying to test what happens if I use the player's yHeadRot instead... My guess is that it might work, but would break Free-Look like mods (Better Third Person, for instance).

Sure enough, using the player's yHeadRot, obtained with player.getYHeadRot() breaks Better Third Person. 90º flicks work strange when combined with BTP, sometimes doing a full spin before settling on the angle.

@Lokito23
Copy link
Author

Got it, figured out that you needed to import GameRenderer in order to be able to use getMainCamera().

Still needs testing, but it works on Fabric 1.21.7, and it works somewhat with Better Third Person (Sometimes the flick stick turns the player, but that isn't that bad). The animation also is somewhat glitchy, skipping every so often.

@Lokito23
Copy link
Author

Should fix #506 and #484

@Lokito23
Copy link
Author

Might be interesting to add the Steam Input-like Flick Stick as an option instead of replacing the old method.

@Lokito23
Copy link
Author

Lokito23 commented Aug 14, 2025

I'm not sure as to how to proceed...

I've already stated that it might be interesting to add an option to re-enable the old method of Flick Stick.

As for the animation glitches, those are beyond my modding knowledge, and I would need help in order to fix them.

In the case of the testing, I would need to know how to compile for a single version that is older than what's within the versions/current file.
EDIT: Just noticed that the Stonecutter CI is now working, I'll close the issue I've made. That fixes this point.

What are your opinions in these matters, @isXander?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants