Skip to main content

LevelReader

Trait LevelReader 

Source
pub trait LevelReader {
Show 17 methods // Required methods fn get_block_state(&self, pos: BlockPos) -> BlockStateId; fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8; fn min_y(&self) -> i32; fn height(&self) -> i32; fn sea_level(&self) -> i32; // Provided methods fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity> { ... } fn is_face_sturdy( &self, state: BlockStateId, pos: BlockPos, direction: Direction, ) -> bool { ... } fn is_face_sturdy_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool { ... } fn sky_darkening(&self) -> u8 { ... } fn can_see_sky(&self, pos: BlockPos) -> bool { ... } fn ambient_light(&self) -> f32 { ... } fn height_at(&self, _heightmap_type: HeightmapType, _x: i32, _z: i32) -> i32 { ... } fn max_y_exclusive(&self) -> i32 { ... } fn is_outside_build_height(&self, y: i32) -> bool { ... } fn max_local_raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8 { ... } fn light_level_dependent_magic_value(&self, pos: BlockPos) -> f32 { ... } fn pathfinding_cost_from_light_levels(&self, pos: BlockPos) -> f32 { ... }
}
Expand description

Read-only level access needed by block behavior and worldgen predicates.

Required Methods§

Source

fn get_block_state(&self, pos: BlockPos) -> BlockStateId

Gets the block state at a position.

Source

fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8

Returns vanilla raw brightness at a position after sky darkening.

Source

fn min_y(&self) -> i32

Returns the minimum build height.

Source

fn height(&self) -> i32

Returns the build height.

Source

fn sea_level(&self) -> i32

Returns the dimension’s sea level.

Provided Methods§

Source

fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>

Gets the block entity at a position when this level surface supports it

Source

fn is_face_sturdy( &self, state: BlockStateId, pos: BlockPos, direction: Direction, ) -> bool

Mirrors vanilla BlockState.isFaceSturdy with full-face support.

Source

fn is_face_sturdy_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool

Mirrors vanilla BlockState.isFaceSturdy for a specific support type.

Lightweight and worldgen views default to extracted support shapes. Live views override this to dispatch through block behavior for dynamic world-dependent shapes.

Source

fn sky_darkening(&self) -> u8

Sky darkening (15 - SKY_LIGHT_LEVEL). Worldgen defaults to zero; live worlds use the environment attribute.

Source

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

Whether sky light is full. Lightweight views approximate from raw brightness; live worlds read the sky-light layer directly.

Source

fn ambient_light(&self) -> f32

Returns this dimension’s vanilla ambient light factor.

Source

fn height_at(&self, _heightmap_type: HeightmapType, _x: i32, _z: i32) -> i32

Returns the vanilla heightmap value at a column.

Source

fn max_y_exclusive(&self) -> i32

Returns the exclusive maximum build height.

Source

fn is_outside_build_height(&self, y: i32) -> bool

Checks if a Y coordinate is outside build height.

Source

fn max_local_raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8

Returns raw brightness at a position, treating positions outside the world’s horizontal bounds as fully lit.

Source

fn light_level_dependent_magic_value(&self, pos: BlockPos) -> f32

Converts brightness after current sky darkening to the curved light value.

Source

fn pathfinding_cost_from_light_levels(&self, pos: BlockPos) -> f32

Returns the light-based cost modifier used by mob pathfinding, derived from the light-curved brightness at a position.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl LevelReader for Arc<World>

Source§

fn get_block_state(&self, pos: BlockPos) -> BlockStateId

Source§

fn get_block_entity(&self, pos: BlockPos) -> Option<SharedBlockEntity>

Source§

fn is_face_sturdy_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool

Source§

fn sky_darkening(&self) -> u8

Source§

fn raw_brightness(&self, pos: BlockPos, sky_darkening: u8) -> u8

Source§

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

Source§

fn ambient_light(&self) -> f32

Source§

fn height_at(&self, heightmap_type: HeightmapType, x: i32, z: i32) -> i32

Source§

fn min_y(&self) -> i32

Source§

fn height(&self) -> i32

Source§

fn sea_level(&self) -> i32

Implementors§