![Gravity Changer](https://media.forgecdn.net/avatars/thumbnails/445/926/256/256/637702638820232319.png)
Weirdness of movement handling
qouteall opened this issue ยท 5 comments
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
.
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
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:
- For a mod that adds jetpack, your method works
- For a mod that adds a bouncing block or conveyer belt, your method does not work
Can you provide a set of API for getting the world coordinate velocity and setting the world coordinate velocity?
Added these 77d22f4