MikhailTapio / FlightHud

Minecraft mod that displays a flight styled HUD while flying with elytra.
GNU General Public License v3.0
7 stars 3 forks source link

Incorrect tilt of artificial horizon #5

Open pengi opened 5 months ago

pengi commented 5 months ago

Cool gimmick mod, that I would like to try.

However, the artificial horizon should stick solid and aligned with the real horizon, even if it would result in little bit less visual changes.

Using it together with for example the mod "do a barrel roll" would make the "correct" horizon more useful even.

Maybe as a setting?

MikhailTapio commented 4 months ago

Currently have no idea how to implement :( Btw the relevant code is third-handed.

MikhailTapio commented 4 months ago

Fabric-1.21-1.1.3 halved the angle of the roll.

pengi commented 4 months ago

I'm unfortunately not used to this development environment, so would take me some time to set up and learn to get a patch myself unfortunately... :/

I agree with halved angle of the roll. Looking at this screenshot 2024-06-24_16 03 52

I think it should be negative too. Otherwise I think it should be correct.

Note that this is together with the "do a barrel roll" mod, which alters the behavior of the flight, and sticks the camera to the player, so it acts a bit like an airplane flight.

When not having the "do a barrel roll" mod enabled, I think it may look better as is.

So I think what needs to be done is to have an option (possibly in a configuration file) that multiplies the roll with -2 compared to the previous version. Or maybe have a parameter that specifies a constant for how much to multiply the roll with.

pengi commented 4 months ago

To clarify the screenshot:

I want the horizon line in hud to follow the horizon of the world (if the world would stretch to infinity)

At this screenshot, the horizon line should be just above the actual horizon, since the player is at altitude and the world is just loaded a bit away, the apparent horizon is lower.

horizon-line

MikhailTapio commented 4 months ago

To clarify the screenshot:

I want the horizon line in hud to follow the horizon of the world (if the world would stretch to infinity)

At this screenshot, the horizon line should be just above the actual horizon, since the player is at altitude and the world is just loaded a bit away, the apparent horizon is lower.

horizon-line

I'll implement a "rollCoefficient" for that

BezShkvark0 commented 3 months ago

Hi there! I've got same "issue", but horizon line in the hud is almost following actual horizon, I am right now trying to mess with its setting in the confing.

P.s. I'm using Cool Elytra Roll mod (( https://modrinth.com/mod/cool-elytra-roll ))

HuJK commented 2 months ago

The correct effect should be like this: https://www.youtube.com/watch?v=WlWCB49DieU

This is a fix but not no get merged to the mainline. https://github.com/HuJK/FlightHUD-Do-a-Barrel-Roll-Fix

This fix removes all estimation of roll angle, it just inject to RenderSystem and retrive the value getInverseViewRotationMatrix().
So, no matter how other mods rotates the view, it will always be perfict align to the player ViewRotation.

Maybe we can port this patch to FlightHud Reborn, too? But I'm busy recently, may need other guys to to this.

HuJK commented 2 months ago

WIP migration, but get stucked now, https://github.com/MikhailTapio/FlightHud/compare/fabric-dev...HuJK-Data:FlightHud-Reborn:fabric-dev

This patch changes how this HUD works, it inject to net.minecraft.client.render.GameRenderer directly https://github.com/HuJK-Data/FlightHud-Reborn/blob/43a036235e17f42660beedc29f6d719f55b283fa/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java

But this code is from 1.18.2, I got some error says package net.minecraft.client.render does not exist, need some help.

> Task :compileJava
/workspaces/FlightHud-Reborn/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java:17: error: Mixin has no targets
@Mixin(GameRenderer.class)
^
/workspaces/FlightHud-Reborn/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java:5: error: package net.minecraft.client.render does not exist
import net.minecraft.client.render.GameRenderer;
                                  ^
/workspaces/FlightHud-Reborn/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java:6: error: package net.minecraft.client.util.math does not exist
import net.minecraft.client.util.math.MatrixStack;
                                     ^
/workspaces/FlightHud-Reborn/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java:34: error: cannot find symbol
            MatrixStack matrices,
            ^
  symbol:   class MatrixStack
  location: class GameRendererMixin
/workspaces/FlightHud-Reborn/src/main/java/com/plr/flighthud/mixin/GameRendererMixin.java:17: error: cannot find symbol
@Mixin(GameRenderer.class)
       ^
  symbol: class GameRenderer
5 errors
HuJK commented 2 months ago

Found the reason. getInverseViewRotationMatrix() get removed.

I've been port this fix to 1.18.2~1.20.4 here: https://github.com/HuJK/FlightHUD-Do-a-Barrel-Roll-Fix/releases

But the RenderSystem.getInverseViewRotationMatrix() has been removed at 1.20.5 Now I'm get stucked here.

HuJK commented 2 months ago

Found a solution for this issue you can checkout my code https://github.com/HuJK/FlightHUD-Do-a-Barrel-Roll-Fix/commit/851e355e7fa75cda5c48f2268838471a1ab0c886

HuJK commented 2 months ago

Update: Port to 1.21 done.

You can checkout my code and port to FlightHUD Reborn.
Source code: Injection part and Calculation Part

My fix injects to RenderSystem and get the user view from camera.getRotation(), then calculate the roll based on it. So that it will always be perfict align to the player ViewRotation.

pengi commented 2 months ago

I just checked that version, and it looks way better.

Had some minor patches to it too, but since this repo doesn't contain the source, I made a PR to HuJKs fork, to get all the patches together.

https://github.com/HuJK/FlightHUD-Do-a-Barrel-Roll-Fix/pull/1