Skip to content

Commit

Permalink
Less ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlasticPotato committed Dec 17, 2024
1 parent a3e51eb commit 26c1a58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,6 @@ private void originalCheckInside(final AABBd aABB) {
private void preGetEyePosition(final float partialTicks, final CallbackInfoReturnable<Vec3> cir) {
final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(Entity.class.cast(this), partialTicks);
if (shipMountedToData == null) {
if (Entity.class.cast(this) instanceof final ServerPlayer sPlayer && sPlayer instanceof final IEntityDraggingInformationProvider dragProvider) {
if (dragProvider.getDraggingInformation().isEntityBeingDraggedByAShip() && dragProvider.getDraggingInformation().getServerRelativePlayerPosition() != null) {
final Ship shipDraggedBy = VSGameUtilsKt.getAllShips(level).getById(dragProvider.getDraggingInformation().getLastShipStoodOn());
if (shipDraggedBy != null) {
final Vector3dc worldPos = shipDraggedBy.getShipToWorld().transformPosition(dragProvider.getDraggingInformation().getServerRelativePlayerPosition(), new Vector3d());
cir.setReturnValue(new Vec3(worldPos.x(), worldPos.y(), worldPos.z()));
}
}
}
return;
}
final LoadedShip shipMountedTo = shipMountedToData.getShipMountedTo();
Expand All @@ -143,15 +134,6 @@ private void preGetEyePosition(final float partialTicks, final CallbackInfoRetur
private void preGetEyePositionServer(final CallbackInfoReturnable<Vec3> cir) {
final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(Entity.class.cast(this), null);
if (shipMountedToData == null) {
if (Entity.class.cast(this) instanceof final ServerPlayer sPlayer && sPlayer instanceof final IEntityDraggingInformationProvider dragProvider) {
if (dragProvider.getDraggingInformation().isEntityBeingDraggedByAShip() && dragProvider.getDraggingInformation().getServerRelativePlayerPosition() != null) {
final Ship shipDraggedBy = VSGameUtilsKt.getAllShips(level).getById(dragProvider.getDraggingInformation().getLastShipStoodOn());
if (shipDraggedBy != null) {
final Vector3dc worldPos = shipDraggedBy.getShipToWorld().transformPosition(dragProvider.getDraggingInformation().getServerRelativePlayerPosition(), new Vector3d());
cir.setReturnValue(new Vec3(worldPos.x(), worldPos.y(), worldPos.z()));
}
}
}
return;
}
final LoadedShip shipMountedTo = shipMountedToData.getShipMountedTo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.valkyrienskies.core.impl.chunk_tracking.ShipActiveChunksSet
import org.valkyrienskies.mod.common.dimensionId
import org.valkyrienskies.mod.common.getShipObjectManagingPos
import org.valkyrienskies.mod.common.shipObjectWorld
import org.valkyrienskies.mod.common.toWorldCoordinates
import org.valkyrienskies.mod.common.util.toJOML
import org.valkyrienskies.mod.common.util.toMinecraft

Expand All @@ -34,14 +35,6 @@ object POIChunkSearcher {
}

fun PoiRecord.getWorldPos(level: Level): Vec3 {
val blockPos = this.pos
val vecPos = Vec3(blockPos.x.toDouble(), blockPos.y.toDouble(), blockPos.z.toDouble())
if (level.shipObjectWorld.isBlockInShipyard(blockPos.x, blockPos.y, blockPos.z, level.dimensionId)) {
val ship = level.getShipObjectManagingPos(blockPos)
if (ship != null) {
return ship.shipToWorld.transformPosition(vecPos.toJOML()).toMinecraft()
}
}
return vecPos
return level.toWorldCoordinates(Vec3(this.pos.x.toDouble(), this.pos.y.toDouble(), this.pos.z.toDouble()))
}
}

0 comments on commit 26c1a58

Please sign in to comment.