Class WorldHandle
java.lang.Object
nl.pim16aap2.lightkeeper.framework.WorldHandle
Handle to a world in the running test server.
-
Method Summary
Modifier and TypeMethodDescriptionGets a live reference to the block at a position.blockTypeAt(BlockPos position) Retrieves the block type at a position.entities()Gets a live, composable entity query for this world.booleanisChunkLoaded(int chunkX, int chunkZ) Checks if a chunk is loaded.loadChunk(int chunkX, int chunkZ) Loads a chunk, generating it if it does not exist yet.name()Gets the world name.voidsetBlockAt(BlockPos position, String material) Sets the block type at a position.voidsetBlockAt(BlockPos position, BlockSpec spec) Sets the block at a position from a block spec, applying type and state properties atomically.unloadChunk(int chunkX, int chunkZ) Unloads a chunk.
-
Method Details
-
name
Gets the world name.- Returns:
- World name.
-
entities
Gets a live, composable entity query for this world.- Returns:
- An unfiltered entity query; add filters via
EntityQuery.ofType(java.lang.String)andEntityQuery.within(nl.pim16aap2.lightkeeper.framework.BlockPos, nl.pim16aap2.lightkeeper.framework.BlockPos).
-
blockAt
Gets a live reference to the block at a position.The reference stores only the address; every read through it re-queries the server.
- Parameters:
position- The block position.- Returns:
- A live block reference.
-
setBlockAt
Sets the block at a position from a block spec, applying type and state properties atomically.Placement applies a physics update: attachable or gravity-affected blocks (levers, torches, sand) need a valid supporting block in place first, or they break or fall immediately.
- Parameters:
position- The block position.spec- The block spec, e.g.BlockSpec.parse("minecraft:lever[face=floor,powered=true]").
-
blockTypeAt
Retrieves the block type at a position.- Parameters:
position- Block coordinates.- Returns:
- The block material name.
-
setBlockAt
Sets the block type at a position.- Parameters:
position- Block coordinates.material- Material name.
-
loadChunk
Loads a chunk, generating it if it does not exist yet.- Parameters:
chunkX- Chunk X coordinate.chunkZ- Chunk Z coordinate.- Returns:
- This handle for fluent chaining.
- Throws:
IllegalStateException- If the server failed to load the chunk.
-
unloadChunk
Unloads a chunk.- Parameters:
chunkX- Chunk X coordinate.chunkZ- Chunk Z coordinate.- Returns:
- This handle for fluent chaining.
- Throws:
IllegalStateException- If the server refused to unload the chunk (e.g. because it is still in use).
-
isChunkLoaded
public boolean isChunkLoaded(int chunkX, int chunkZ) Checks if a chunk is loaded.- Parameters:
chunkX- Chunk X coordinate.chunkZ- Chunk Z coordinate.- Returns:
- True if the chunk is loaded.
-