diff --git a/src/main/java/me/m56738/smoothcoasters/mixin/EntityMixin.java b/src/main/java/me/m56738/smoothcoasters/mixin/EntityMixin.java index 983f935..1169375 100644 --- a/src/main/java/me/m56738/smoothcoasters/mixin/EntityMixin.java +++ b/src/main/java/me/m56738/smoothcoasters/mixin/EntityMixin.java @@ -5,10 +5,12 @@ import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(Entity.class) @Environment(EnvType.CLIENT) @@ -36,4 +38,18 @@ private void turnTail(double cursorDeltaX, double cursorDeltaY, CallbackInfo inf ((GameRendererMixinInterface) Minecraft.getInstance().gameRenderer) .smoothcoasters$applyLocalRotation((Entity) (Object) this); } + + @Inject(method = "getVehicleAttachmentPoint", at = @At("HEAD")) + private void getVehicleAttachmentPointHead(Entity vehicle, CallbackInfoReturnable info) { + // Attachment points must use the local look direction. The composed + // coaster yaw can otherwise offset the player during vehicle movement. + ((GameRendererMixinInterface) Minecraft.getInstance().gameRenderer) + .smoothcoasters$loadLocalRotation((Entity) (Object) this); + } + + @Inject(method = "getVehicleAttachmentPoint", at = @At("RETURN")) + private void getVehicleAttachmentPointTail(Entity vehicle, CallbackInfoReturnable info) { + ((GameRendererMixinInterface) Minecraft.getInstance().gameRenderer) + .smoothcoasters$applyLocalRotation((Entity) (Object) this); + } }