Class WorldHandle

java.lang.Object
nl.pim16aap2.lightkeeper.framework.WorldHandle

public final class WorldHandle extends Object
Handle to a world in the running test server.
  • Method Details

    • name

      public String name()
      Gets the world name.
      Returns:
      World name.
    • entities

      public EntityQuery entities()
      Gets a live, composable entity query for this world.
      Returns:
      An unfiltered entity query; add filters via EntityQuery.ofType(java.lang.String) and EntityQuery.within(nl.pim16aap2.lightkeeper.framework.BlockPos, nl.pim16aap2.lightkeeper.framework.BlockPos).
    • blockAt

      public BlockRef blockAt(BlockPos position)
      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

      public void setBlockAt(BlockPos position, BlockSpec spec)
      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

      public String blockTypeAt(BlockPos position)
      Retrieves the block type at a position.
      Parameters:
      position - Block coordinates.
      Returns:
      The block material name.
    • setBlockAt

      public void setBlockAt(BlockPos position, String material)
      Sets the block type at a position.
      Parameters:
      position - Block coordinates.
      material - Material name.
    • loadChunk

      public WorldHandle loadChunk(int chunkX, int chunkZ)
      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

      public WorldHandle unloadChunk(int chunkX, int chunkZ)
      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.