Skip to main content

WorldContext

Trait WorldContext 

Source
pub trait WorldContext: WorldHandle {
    // Required methods
    fn send_block_ack(&self, sequence: i32);
    fn stream_chunks(&self, cx: i32, cz: i32);
    fn queue_persist_chunk(&self, cx: i32, cz: i32);
    fn destroy_block_entity(&self, x: i32, y: i32, z: i32);
}
Expand description

Per-dispatch context for world-related operations.

Extends WorldHandle with methods that queue deferred responses (chunk streaming, block acknowledgements, block-entity destruction events). The pure world ops (get_block, set_block, check_overlap, …) come from WorldHandle and are not redeclared here.

Persistence is split between the two traits: WorldHandle::persist_chunk is synchronous, while queue_persist_chunk queues a Response::PersistChunk for async I/O-thread routing. The distinct names prevent E0034 ambiguity on &dyn WorldContext.

Required Methods§

Source

fn send_block_ack(&self, sequence: i32)

Sends a block action acknowledgement to the current player.

Source

fn stream_chunks(&self, cx: i32, cz: i32)

Streams chunks around the given chunk coordinates.

Source

fn queue_persist_chunk(&self, cx: i32, cz: i32)

Schedules a chunk for asynchronous persistence on the I/O thread.

Named queue_persist_chunk to avoid ambiguity with WorldHandle::persist_chunk (synchronous, calls World::persist_chunk directly). This version queues a Response::PersistChunk for the game loop to route to the I/O thread asynchronously.

Source

fn destroy_block_entity(&self, x: i32, y: i32, z: i32)

Removes a block entity at the given position and fires a BlockEntityDestroyedEvent carrying the last state.

No-op if no block entity exists at the position. Plugins use this from a BlockBrokenEvent Post handler to drive the destroy → drop-items chain through the event pipeline.

Implementors§