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
Make PreMotionEvent and PostMotionEvent work with vehicles (fixes #475) #476
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes a small bug effectively.
Out of curiosity (and unfamiliarity with Fabric API) how does this fix work? |
For reference, the relevant code looks something like: super.tick();
if (this.hasVehicle()) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(this.getYaw(), this.getPitch(), this.onGround));
this.networkHandler.sendPacket(new PlayerInputC2SPacket(this.sidewaysSpeed, this.forwardSpeed, this.input.jumping, this.input.sneaking));
final Entity aqa2 = this.getRootVehicle();
if (aqa2 != this && aqa2.isLogicalSideForUpdatingMovement()) {
this.networkHandler.sendPacket(new VehicleMoveC2SPacket(aqa2));
}
}
else {
this.sendMovementPackets();
} The problem is that sendMovementPackets() is never called if we are riding a vehicle. The first part is: @Inject(at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;tick()V",
ordinal = 0,
shift = Shift.AFTER), method = "tick()V") This injects our code right after the "super.tick()" call. The second part is: @Inject(at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendMovementPackets()V",
ordinal = 0,
shift = Shift.BY,
by = 2), method = "tick()V") This injects our code 2 instructions after the "this.sendMovementPackets()" call, outside of the "else" block. |
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks. Pull requests should be closed if:
|
Still relevant. A lot of mods don't work on vehicles (like KillAura), and this mod fixes this. |
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks. Pull requests should be closed if:
|
This should fix issue #475.