diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java index e81068d6..869eb371 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/entity/MixinEntity.java @@ -170,7 +170,7 @@ private void preCalculateViewVector(final float xRot, final float yRot, final Ca if (dragProvider.getDraggingInformation().isEntityBeingDraggedByAShip() && dragProvider.getDraggingInformation().getServerRelativePlayerYaw() != null) { final Ship shipDraggedBy = VSGameUtilsKt.getAllShips(level).getById(dragProvider.getDraggingInformation().getLastShipStoodOn()); if (shipDraggedBy != null) { - final float realYRot = (float) EntityDragger.INSTANCE.serversideEyeRotationOrDefault(sPlayer, yRot); + final float realYRot = (float) EntityDragger.INSTANCE.serversideWorldEyeRotationOrDefault(sPlayer, shipDraggedBy, yRot); final float f = xRot * (float) (Math.PI / 180.0); final float g = -realYRot * (float) (Math.PI / 180.0); final float h = Mth.cos(g); diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt index c5cb860b..0036e7ff 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt @@ -10,7 +10,10 @@ import net.minecraft.world.phys.Vec3 import org.joml.Vector3d import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.ClientShip +import org.valkyrienskies.core.api.ships.ServerShip +import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.EntityLerper.yawToWorld import kotlin.math.asin import kotlin.math.atan2 import kotlin.math.cos @@ -188,4 +191,14 @@ object EntityDragger { } return default } + + + fun Entity.serversideWorldEyeRotationOrDefault(ship: Ship, default: Double): Double { + if (this is ServerPlayer && this is IEntityDraggingInformationProvider && this.draggingInformation.isEntityBeingDraggedByAShip()) { + if (this.draggingInformation.serverRelativePlayerYaw != null) { + return yawToWorld(ship, this.draggingInformation.serverRelativePlayerYaw!!) + } + } + return default + } }