How to get a ship
Learn how to get an instance of Ship using a shipyard position, world position, or ship id.
Before you start
Make sure that:
Using a shipyard position
Get the ship whose unique chunk claim in the shipyard contains a specific block or chunk, if it exists.
Get the ship managing a block position
import org.valkyrienskies.mod.api.getShipManagingBlock
val level: Level = ...
val ship: Ship? = level.getShipManagingBlock(x, y, z)
import org.valkyrienskies.mod.api.ValkyrienSkies
Level level = ...
@Nullable Ship ship = ValkyrienSkies.getShipManagingBlock(level, x, y, z);
Get the ship managing a chunk position
import org.valkyrienskies.mod.api.getShipManagingChunk
val level: Level = ...
val ship: Ship? = level.getShipManagingChunk(chunkX, chunkZ)
import org.valkyrienskies.mod.api.ValkyrienSkies
Level level = ...
@Nullable Ship ship = ValkyrienSkies.getShipManagingChunk(level, chunkX, chunkZ);
Using a world position
Get ships containing a position
Get all the ships with bounding boxes that contain a given position. It's possible for multiple ships to contain the same position, so these methods return an Iterable<Ship>.
val level: Level = ...
val ships: Iterable<Ship> = level.getShipsIntersecting(x, y, z)
Level level = ...
Iterable<Ships> ships = ValkyrienSkies.getShipsIntersecting(level, x, y, z);
Get the ships intersecting a bounding box
Get all the ships with bounding boxes that intersect a given bounding box.
val level: Level = ...
val aabb: AABB = ...
val ships: Iterable<Ship> = level.getShipsIntersecting(aabb)
Level level = ...
AABB aabb = ...
Iterable<Ships> ships = ValkyrienSkies.getShipsIntersecting(level, aabb);
Using the ship's ID
Get the ship with the specified ID, if it exists.
val level: Level = ...
val id: ShipId = ...
val ship: Ship? = level.getShipById(id)
Level level = ...
long id = ...
@Nullable Ship ship = ValkyrienSkies.getShipById(level, id);
Last modified: 03 June 2026