Skip to content

Commit

Permalink
Fixed incorrect yaw transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlasticPotato committed Jan 6, 2025
1 parent 3d9cedc commit e81c025
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

0 comments on commit e81c025

Please sign in to comment.