pub trait WorldHandle {
// Required methods
fn get_block(&self, x: i32, y: i32, z: i32) -> u16;
fn set_block(&self, x: i32, y: i32, z: i32, state: u16);
fn get_block_entity(&self, x: i32, y: i32, z: i32) -> Option<BlockEntity>;
fn set_block_entity(&self, x: i32, y: i32, z: i32, entity: BlockEntity);
fn mark_chunk_dirty(&self, cx: i32, cz: i32);
fn persist_chunk(&self, cx: i32, cz: i32);
fn dirty_chunks(&self) -> Vec<(i32, i32)>;
fn check_overlap(&self, aabb: &Aabb) -> bool;
fn ray_cast(
&self,
origin: (f64, f64, f64),
direction: (f64, f64, f64),
max_distance: f64,
) -> Option<RayHit>;
fn resolve_movement(
&self,
aabb: &Aabb,
dx: f64,
dy: f64,
dz: f64,
) -> (f64, f64, f64);
}Expand description
Long-lived handle to the world runtime.
Pure read/write operations only – no response queueing (see
WorldContext for that).
Concrete types stored in Arc for cross-thread sharing (e.g.
Arc<World>) already implement Send + Sync. The trait itself
does not require them so that per-dispatch types like
ServerContext (which uses RefCell) can implement it too.
Required Methods§
Sourcefn get_block(&self, x: i32, y: i32, z: i32) -> u16
fn get_block(&self, x: i32, y: i32, z: i32) -> u16
Returns the block state at the given position.
Generates or loads the chunk if it is not cached. Returns 0
(air) for positions outside the valid Y range.
Sourcefn set_block(&self, x: i32, y: i32, z: i32, state: u16)
fn set_block(&self, x: i32, y: i32, z: i32, state: u16)
Sets a block state at the given position.
Generates or loads the chunk if it is not cached. Marks the containing chunk as dirty for persistence.
Sourcefn get_block_entity(&self, x: i32, y: i32, z: i32) -> Option<BlockEntity>
fn get_block_entity(&self, x: i32, y: i32, z: i32) -> Option<BlockEntity>
Returns a cloned block entity at the given position, if any.
Sourcefn set_block_entity(&self, x: i32, y: i32, z: i32, entity: BlockEntity)
fn set_block_entity(&self, x: i32, y: i32, z: i32, entity: BlockEntity)
Sets a block entity at the given position. Marks the chunk dirty.
Sourcefn mark_chunk_dirty(&self, cx: i32, cz: i32)
fn mark_chunk_dirty(&self, cx: i32, cz: i32)
Marks a chunk as dirty so the persistence system flushes it on the next batch.
Sourcefn persist_chunk(&self, cx: i32, cz: i32)
fn persist_chunk(&self, cx: i32, cz: i32)
Forces immediate persistence of the chunk to disk (synchronous).
Most callers should prefer mark_chunk_dirty
to let the batch persistence path handle it.
Sourcefn dirty_chunks(&self) -> Vec<(i32, i32)>
fn dirty_chunks(&self) -> Vec<(i32, i32)>
Returns the coordinates of all chunks currently marked dirty.
Sourcefn check_overlap(&self, aabb: &Aabb) -> bool
fn check_overlap(&self, aabb: &Aabb) -> bool
Returns true if the AABB overlaps any solid block.