Skip to main content

LevelAccessor

Trait LevelAccessor 

Source
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§

Source

fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool

Sets a block state with vanilla update flags.

Source

fn destroy_block(&self, pos: BlockPos, drop_items: bool) -> bool

Destroys a block and optionally drops its resources.

Provided Methods§

Source

fn can_write_to_chunk(&self, _chunk_x: i32, _chunk_z: i32) -> bool

Returns whether this surface accepts writes into the given chunk.

Source

fn requires_live_write_preflight(&self) -> bool

Returns whether multi-block placements must be dry-run before committing.

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl LevelAccessor for Arc<World>

Source§

fn set_block_state( &self, pos: BlockPos, state: BlockStateId, flags: UpdateFlags, ) -> bool

Source§

fn can_write_to_chunk(&self, chunk_x: i32, chunk_z: i32) -> bool

Source§

fn requires_live_write_preflight(&self) -> bool

Source§

fn destroy_block(&self, pos: BlockPos, drop_items: bool) -> bool

Source§

fn play_block_sound( &self, sound: SoundEventRef, pos: BlockPos, volume: f32, pitch: f32, exclude: Option<i32>, )

Source§

fn game_event( &self, event: GameEventRef, pos: BlockPos, context: &GameEventContext<'_>, )

Implementors§