Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/me/m56738/smoothcoasters/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<Vec3> 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<Vec3> info) {
((GameRendererMixinInterface) Minecraft.getInstance().gameRenderer)
.smoothcoasters$applyLocalRotation((Entity) (Object) this);
}
}