Gaider10 / GravityChanger

A fabric mod and api that lets you change player gravity direction
MIT License
20 stars 13 forks source link

Weirdness of movement handling #19

Closed qouteall closed 2 years ago

qouteall commented 2 years ago

I found that this mod handles movement in a weird way, causing the velocity to be "wrong". When the player's gravity direction is up and the player is moving towards positive x direction, the velocity's x value is negative. This will cause many issues because the velocity is deemed as in the world coordinate, not the player's self coordinate. With this, Immersive Portals mod cannot transform velocity correctly if the player crosses a portal with rotation transformation.

I see that you are modifying the argument in Entity#move. https://github.com/Gaider10/GravityChanger/blob/master/src/main/java/me/andrew/gravitychanger/mixin/EntityMixin.java#L210 The better way is to not change move but change the velocity update code Entity#updateVelocity.

qouteall commented 2 years ago

I can do a temporary workaround for that but it's not the optimal solution.

Gaider10 commented 2 years ago

I know about this, but both ways of doing it have their drawbacks. If I store world relative velocity I need to mixin into almost every single place that changes player velocity, making it much harder to work with, and if other mods try to update player velocity in a way that needs to be relative to the player it will be wrong. If I store player relative velocity I need much less mixins, but if other mods try to use the velocity relative to the world it will be wrong. I decided to go with the easier option, as in either case there will be incompatibilities, and i'm still surprised that the mod even works in some big mobpacks

qouteall commented 2 years ago

I see. If you use the world coordinate velocity, a lot of knockback code, jumping code, flying code need to be redirected. But it also eliminates your explosion-related mixin https://github.com/Gaider10/GravityChanger/blob/master/src/main/java/me/andrew/gravitychanger/mixin/ExplosionMixin.java About mod compatibility:

Can you provide a set of API for getting the world coordinate velocity and setting the world coordinate velocity?

Gaider10 commented 2 years ago

Added these 77d22f4f63b4c9453d397d47082e79716fc2c822

qouteall commented 2 years ago

ok