pub trait LevelAccessor: ScheduledTickAccess {
// Required methods
fn set_block_state(
&self,
pos: BlockPos,
state: BlockStateId,
flags: UpdateFlags,
) -> bool;
fn destroy_block(&self, pos: BlockPos, drop_items: bool) -> bool;
// Provided methods
fn can_write_to_chunk(&self, _chunk_x: i32, _chunk_z: i32) -> bool { ... }
fn requires_live_write_preflight(&self) -> bool { ... }
fn play_block_sound(
&self,
sound: SoundEventRef,
pos: BlockPos,
volume: f32,
pitch: f32,
exclude: Option<i32>,
) { ... }
fn game_event(
&self,
event: GameEventRef,
pos: BlockPos,
context: &GameEventContext<'_>,
) { ... }
}Expand description
Mutable level access needed by vanilla LevelAccessor block hooks.
Required Methods§
Sourcefn set_block_state(
&self,
pos: BlockPos,
state: BlockStateId,
flags: UpdateFlags,
) -> bool
fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool
Sets a block state with vanilla update flags.
Sourcefn destroy_block(&self, pos: BlockPos, drop_items: bool) -> bool
fn destroy_block(&self, pos: BlockPos, drop_items: bool) -> bool
Destroys a block and optionally drops its resources.
Provided Methods§
Sourcefn can_write_to_chunk(&self, _chunk_x: i32, _chunk_z: i32) -> bool
fn can_write_to_chunk(&self, _chunk_x: i32, _chunk_z: i32) -> bool
Returns whether this surface accepts writes into the given chunk.
Sourcefn requires_live_write_preflight(&self) -> bool
fn requires_live_write_preflight(&self) -> bool
Returns whether multi-block placements must be dry-run before committing.
Sourcefn play_block_sound(
&self,
sound: SoundEventRef,
pos: BlockPos,
volume: f32,
pitch: f32,
exclude: Option<i32>,
)
fn play_block_sound( &self, sound: SoundEventRef, pos: BlockPos, volume: f32, pitch: f32, exclude: Option<i32>, )
Plays a block sound when this level surface supports runtime side effects.
Sourcefn game_event(
&self,
event: GameEventRef,
pos: BlockPos,
context: &GameEventContext<'_>,
)
fn game_event( &self, event: GameEventRef, pos: BlockPos, context: &GameEventContext<'_>, )
Dispatches a game event when this level surface supports runtime listeners.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".