Skip to main content

World

Struct World 

Source
pub struct World {
Show 30 fields pub chunk_map: Arc<ChunkMap>, pub players: PlayerMap, pub player_area_map: PlayerAreaMap, pub key: Identifier, pub dimension_type: DimensionTypeRef, pub level_data: SyncRwLock<LevelDataManager>, pub(crate) saved_data: SavedDataManager, world_border: SyncMutex<WorldBorder>, pub view_distance: u8, pub simulation_distance: u8, pub compression: Option<CompressionInfo>, pub is_flat: bool, pub sea_level: i32, pub default_gamemode: GameType, tick_runs_normally: AtomicBool, handling_tick: AtomicBool, block_events: SyncMutex<BlockEventQueue>, neighbor_updater: CollectingNeighborUpdater, entity_manager: WorldEntityManager, block_entity_tickers: WorldBlockEntityTickers, game_event_listener_count: Arc<GameEventListenerCount>, entity_tracker: EntityTracker, navigating_mobs: NavigatingMobTracker, pub weather: SyncMutex<Weather>, redstone_torch_toggles: SyncMutex<RedstoneTorchToggleTracker>, scheduled_ticks: WorldTickScheduler, scheduled_block_ticks_this_tick: SyncMutex<Option<Arc<ScheduledTickRunBatch<BlockRef>>>>, scheduled_fluid_ticks_this_tick: SyncMutex<Option<Arc<ScheduledTickRunBatch<FluidRef>>>>, pub poi_storage: SyncMutex<PointOfInterestStorage>, pending_world_changes: SyncMutex<Vec<(SharedEntity, WorldChangeRequest)>>,
}
Expand description

A struct that represents a world.

Fields§

§chunk_map: Arc<ChunkMap>

The chunk map of the world.

§players: PlayerMap

All players in the world with dual indexing by UUID and entity ID.

§player_area_map: PlayerAreaMap

Spatial index for player proximity queries.

§key: Identifier

Loaded world identifier (domain:world).

§dimension_type: DimensionTypeRef

Vanilla dimension type for this loaded world.

Vanilla often calls loaded worlds “dimensions”. In Steel, World is the loaded world instance and dimension_type is the vanilla registry entry controlling height, skylight, ceiling, water evaporation, etc.

§level_data: SyncRwLock<LevelDataManager>

Level data manager for persistent world state.

§saved_data: SavedDataManager

Per-world saved data storage.

§world_border: SyncMutex<WorldBorder>

Runtime world border state.

§view_distance: u8

Server view distance (maximum chunk radius).

§simulation_distance: u8

Server simulation distance.

§compression: Option<CompressionInfo>

Compression settings for encoding broadcast packets.

§is_flat: bool

Whether the world should be marked as flat in login/respawn packets.

§sea_level: i32

Sea level sent in login/respawn packets.

§default_gamemode: GameType

Default game mode for first-visit player data.

§tick_runs_normally: AtomicBool

Whether the tick rate is running normally (not frozen/paused). When false, movement validation checks are skipped.

§handling_tick: AtomicBool

Whether vanilla’s scheduled/chunk/block-event tick phase is active.

§block_events: SyncMutex<BlockEventQueue>

Ordered, duplicate-suppressing server block events awaiting execution.

§neighbor_updater: CollectingNeighborUpdater

Vanilla collecting neighbor updater shared by all live block mutations.

§entity_manager: WorldEntityManager

Central runtime entity ownership and lookup.

§block_entity_tickers: WorldBlockEntityTickers

World-global ordered block-entity ticker phase.

§game_event_listener_count: Arc<GameEventListenerCount>

Physical entries retained by this world’s chunk-owned game-event registries.

§entity_tracker: EntityTracker

Entity tracker for managing which players can see which entities.

§navigating_mobs: NavigatingMobTracker

Runtime IDs for pathfinder mobs currently visible to the active world.

§weather: SyncMutex<Weather>

Weather Data needed for animating starting and stopping of rain clientside

§redstone_torch_toggles: SyncMutex<RedstoneTorchToggleTracker>

Per-level recent toggle history used by vanilla redstone-torch burnout.

§scheduled_ticks: WorldTickScheduler

World registration and sparse head index for chunk-owned scheduled ticks.

§scheduled_block_ticks_this_tick: SyncMutex<Option<Arc<ScheduledTickRunBatch<BlockRef>>>>

Published block batch used by willTickThisTick queries during callbacks.

§scheduled_fluid_ticks_this_tick: SyncMutex<Option<Arc<ScheduledTickRunBatch<FluidRef>>>>

Published fluid batch used by willTickThisTick queries during callbacks.

§poi_storage: SyncMutex<PointOfInterestStorage>

Point of interest storage for efficient spatial queries of special blocks.

§pending_world_changes: SyncMutex<Vec<(SharedEntity, WorldChangeRequest)>>

World-change requests queued by world-local ticks for server safe-point processing.

Implementations§

Source§

impl World

Source

pub fn block_event( &self, pos: BlockPos, block: BlockRef, param_a: i32, param_b: i32, )

Queues a server block event for the next eligible block-event pass.

Exact duplicates are suppressed while queued. Parameters remain i32 for Vanilla behavior parity and are truncated to bytes only for the client packet.

Source

pub(crate) fn run_block_events(self: &Arc<Self>)

Runs queued block events in Vanilla insertion order.

Vanilla gates this queue only on simulation range and may synchronously load chunks from a piston callback. Steel additionally requires the confirmed radius-1 Full neighborhood so the game tick never waits for chunk I/O. Deferred events retain their Vanilla retry behavior.

Source

fn do_block_event(self: &Arc<Self>, event: BlockEventData) -> bool

Source

fn broadcast_block_event(&self, event: BlockEventData)

Source§

impl World

Source

pub(crate) fn try_with_block_region<R>( &self, bounds: BlockRegionBounds, f: impl FnOnce(&BlockRegionRead<'_>) -> R, ) -> Option<R>

Acquires every loaded section intersecting a small bounds once and exposes a scoped read view.

Setup and lock count scale with every intersecting chunk and section, so this is an internal primitive for bounded synchronous gameplay queries rather than arbitrary or player-controlled regions.

The callback must use BlockRegionRead for reads covered by bounds and must not perform world writes. Re-entering a world read for a covered section can deadlock if a writer is already waiting because the requested section read guards remain held until the callback returns.

Source§

impl World

Source

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

Gets the block state at the given position.

Returns void air out of bounds and air when the containing chunk is not loaded.

Source

pub fn light_value_at(&self, layer: LightLayer, pos: BlockPos) -> u8

Vanilla equivalent: level.getBrightness()

Source

pub(crate) fn is_entity_ticking_chunk_loaded(&self, pos: BlockPos) -> bool

Source

pub(crate) fn is_full_chunk_loaded_at(&self, pos: BlockPos) -> bool

Source

pub(crate) fn queue_light_change_after_block_set( &self, pos: BlockPos, old_state: BlockStateId, new_state: BlockStateId, empty_section_change: Option<LightSectionEmptinessChange>, )

Source

pub(super) const fn default_light_value(&self, layer: LightLayer) -> u8

Source

pub fn block_states_in_aabb_are_air(&self, aabb: WorldAabb) -> bool

Returns whether every block state in the vanilla AABB block range is air.

Matches BlockGetter.getBlockStates(AABB) using BlockPos.betweenClosedStream(AABB): both min and max coordinates are floored before iterating the inclusive block range. Large ranges fall back to streaming reads instead of acquiring an unbounded section workset.

Source

pub fn set_block( self: &Arc<Self>, pos: BlockPos, block_state: BlockStateId, flags: UpdateFlags, ) -> bool

Sets a block at the given position.

Returns true if the block was successfully set, false otherwise. Uses the default update limit of 512 (matching vanilla).

Live gameplay callers must run in Steel’s serialized world-mutation phase. Palette and block-entity ownership claims are atomic, but the following Vanilla-ordered callbacks, neighbor updates, and derived-cache writes are intentionally not one concurrent transaction for the same position.

Source

pub fn set_block_with_limit( self: &Arc<Self>, pos: BlockPos, block_state: BlockStateId, flags: UpdateFlags, update_limit: i32, ) -> bool

Sets a block at the given position with a custom update limit.

The update limit bounds recursive shape propagation. The block mutation itself still occurs when the limit is zero or negative, matching vanilla.

Returns true if the block was successfully set, false otherwise. See Self::set_block for the serialized world-mutation requirement.

Source

pub fn set_block_if_unchanged( self: &Arc<Self>, pos: BlockPos, expected_state: BlockStateId, new_state: BlockStateId, flags: UpdateFlags, ) -> ConditionalBlockSetResult

Replaces a block only if it still has expected_state.

The comparison and palette write are performed under one chunk-section write lock. This prevents two consumers of the same observed block state from both succeeding. Block callbacks still run after that state claim, so callers must remain in a serialized world-mutation phase such as an exclusive packet handler or ordered tick commit.

Source

pub fn set_block_if_unchanged_with_limit( self: &Arc<Self>, pos: BlockPos, expected_state: BlockStateId, new_state: BlockStateId, flags: UpdateFlags, update_limit: i32, ) -> ConditionalBlockSetResult

Conditional variant of Self::set_block_with_limit.

Source

pub(super) fn finish_block_set( self: &Arc<Self>, pos: BlockPos, old_state: BlockStateId, block_state: BlockStateId, flags: UpdateFlags, update_limit: i32, )

Source

pub(super) fn update_navigating_mobs_after_block_collision_change( self: &Arc<Self>, pos: BlockPos, old_state: BlockStateId, new_state: BlockStateId, )

Source

pub(super) fn navigating_mob_ids(&self) -> Vec<i32>

Source

pub(super) fn block_collision_shape_changed( &self, pos: BlockPos, old_state: BlockStateId, new_state: BlockStateId, ) -> bool

Source

pub(super) fn block_collision_shape( &self, pos: BlockPos, state: BlockStateId, ) -> VoxelShape

Source

pub fn update_neighbors_at( self: &Arc<Self>, pos: BlockPos, source_block: BlockRef, )

Updates all neighbors of the given position about a block change.

This is the Rust equivalent of vanilla’s Level.updateNeighborsAt().

Source

pub fn update_neighbors_at_except_from_facing( self: &Arc<Self>, pos: BlockPos, source_block: BlockRef, skip_direction: Direction, )

Updates all neighbors except the one in skip_direction.

Mirrors vanilla Level.updateNeighborsAtExceptFromFacing without the experimental redstone Orientation value.

Source

pub(crate) fn update_neighbor_for_output_signal( self: &Arc<Self>, pos: BlockPos, changed_block: BlockRef, )

Updates comparators that can read analog output from pos.

Mirrors vanilla Level.updateNeighbourForOutputSignal. Steel intentionally never synchronously loads the second neighbor chunk: block-ticking chunks have a radius-one Full-chunk safety border, while other call sites retain the game-tick no-blocking policy.

Source

pub(crate) fn update_neighbour_shapes( self: &Arc<Self>, state: BlockStateId, pos: BlockPos, flags: UpdateFlags, update_limit: i32, )

Source

pub(crate) fn update_from_neighbor_shapes( self: &Arc<Self>, state: BlockStateId, pos: BlockPos, ) -> BlockStateId

Recomputes a state against all neighbors in vanilla shape-update order.

Source

pub(crate) fn neighbor_shape_changed( self: &Arc<Self>, direction: Direction, pos: BlockPos, neighbor_pos: BlockPos, neighbor_state: BlockStateId, flags: UpdateFlags, update_limit: i32, )

Called when a neighbor’s shape changes, to update this block’s state.

This is the Rust equivalent of vanilla’s NeighborUpdater.executeShapeUpdate().

Source

pub(super) fn execute_neighbor_shape_update( self: &Arc<Self>, direction: Direction, pos: BlockPos, neighbor_pos: BlockPos, neighbor_state: BlockStateId, flags: UpdateFlags, update_limit: i32, )

Source

pub(crate) fn update_or_destroy( self: &Arc<World>, old_state: BlockStateId, new_state: BlockStateId, pos: BlockPos, flags: UpdateFlags, recursion_left: i32, )

Source

pub(crate) fn update_neighbour_on_block_set( self: &Arc<Self>, pos: BlockPos, old_state: BlockStateId, )

Called when a block changed with a command (setblock, fill, …)

This is the Rust equivalent of vanilla’s ServerLevel.updateNeighborsOnBlockSet().

Source

pub(crate) fn neighbor_changed( self: &Arc<Self>, pos: BlockPos, source_block: BlockRef, )

Notifies a block that one of its neighbors changed.

This is the Rust equivalent of vanilla’s Level.neighborChanged().

Source

pub(crate) fn neighbor_changed_with_state( self: &Arc<Self>, state: BlockStateId, pos: BlockPos, source_block: BlockRef, moved_by_piston: bool, )

Source

pub(super) fn execute_neighbor_update( self: &Arc<Self>, state: BlockStateId, pos: BlockPos, source_block: BlockRef, moved_by_piston: bool, )

Source

pub(super) const fn chunk_pos_for_block(pos: BlockPos) -> ChunkPos

Source

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

Gets a block entity at the given position.

Returns None if the chunk is not loaded or there is no block entity at the position.

Source

pub(crate) fn set_block_entity(&self, block_entity: SharedBlockEntity) -> bool

Adds a block entity to the loaded full chunk at its position.

Source

pub(crate) fn remove_block_entity_if_same( &self, expected: &dyn BlockEntity, ) -> bool

Removes a block entity only while it still owns its position.

Source

pub fn block_entity_changed(&self, pos: BlockPos)

Called when a block entity’s data changes.

Marks the containing chunk as unsaved so it will be persisted to disk.

Source

pub(crate) fn send_block_updated(&self, pos: BlockPos)

Queues a same-state block update and its block-entity update packet.

Mirrors vanilla Level.sendBlockUpdated for callers that changed only block-entity data.

Source

pub fn mark_chunk_dirty(&self, chunk_pos: ChunkPos)

Marks a chunk as dirty (unsaved) so it will be persisted to disk.

Called when entities move, are added/removed, or when block entities change.

Source§

impl World

Source

pub(crate) fn world_border_snapshot(&self) -> WorldBorderSnapshot

Source

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

Returns whether a block position is inside this world’s vanilla world border.

Source

pub fn clamp_to_world_border(&self, x: f64, y: f64, z: f64) -> BlockPos

Clamps a world-space position to this world’s vanilla world border and floors it to a block position.

Source

pub(crate) fn initialize_border_packet(&self) -> CInitializeBorder

Source

pub(crate) fn world_border_adjusted_respawn_data( &self, respawn_data: RespawnData, ) -> RespawnData

Source

pub fn set_world_border_center( &self, x: f64, z: f64, ) -> Result<(), WorldBorderError>

Sets the world border center and broadcasts the vanilla center update packet.

Source

pub fn set_world_border_size(&self, size: f64) -> Result<(), WorldBorderError>

Sets a static world border size and broadcasts the vanilla size update packet.

Source

pub fn lerp_world_border_size_between( &self, from: f64, to: f64, ticks: i64, ) -> Result<(), WorldBorderError>

Starts a vanilla world border size lerp and broadcasts the lerp update packet.

Source

pub fn set_world_border_warning_time(&self, warning_time: i32)

Sets the client warning time and broadcasts the vanilla warning-delay packet.

Source

pub fn set_world_border_warning_blocks(&self, warning_blocks: i32)

Sets the client warning distance and broadcasts the vanilla warning-distance packet.

Source

pub fn set_world_border_damage_per_block( &self, damage_per_block: f64, ) -> Result<(), WorldBorderError>

Sets world border damage per block outside the safe zone.

Source

pub fn set_world_border_safe_zone( &self, safe_zone: f64, ) -> Result<(), WorldBorderError>

Sets the safe distance outside the world border before damage starts.

Source

pub(super) fn tick_world_border(&self)

Source

pub(super) fn sync_world_border_to_level_data(&self)

Source

pub(super) fn store_world_border_data_if_changed(&self, data: WorldBorderData)

Source§

impl World

Source

pub fn broadcast_chat( &self, packet: CPlayerChat, _sender: Arc<Player>, sender_last_seen: LastSeen, message_signature: Option<&[u8; 256]>, )

Broadcasts a signed chat message to all players in the world.

§Panics

Panics if message_signature is None after checking is_some() (should never happen).

Source

pub fn broadcast_system_chat(&self, packet: CSystemChat)

Broadcasts a system chat message to all players.

Source

pub fn broadcast_to_all<P: ClientPacket>(&self, packet: P)

Broadcasts a packet to all players in the world.

Source

pub fn broadcast_to_all_except<P: ClientPacket>(&self, packet: P, exclude: i32)

Broadcasts a packet to all players in the world except one (identified by entity ID).

Source

pub fn broadcast_to_all_with<P: ClientPacket, F: Fn(&Player) -> P>( &self, packet: F, )

Broadcasts a packet to all players in the world.

This method handles encoding the packets produced from the function passed.

Source

pub fn broadcast_to_all_encoded(&self, packet: EncodedPacket)

Broadcasts an already-encoded packet to all players in the world.

Source

pub fn broadcast_to_all_encoded_except( &self, packet: EncodedPacket, exclude: i32, )

Broadcasts an already-encoded packet to all players except one.

Source

pub fn broadcast_unsigned_chat(&self, packet: CPlayerChat)

Broadcasts an unsigned player chat message to all players.

Source

pub fn broadcast_to_nearby<P: ClientPacket>( &self, chunk: ChunkPos, packet: P, exclude: Option<i32>, )

Broadcasts a packet to all players tracking the given chunk.

This method handles encoding the packet internally, avoiding boilerplate at call sites. If encoding fails, the broadcast is silently skipped.

Source

pub fn broadcast_to_nearby_encoded( &self, chunk: ChunkPos, packet: EncodedPacket, exclude: Option<i32>, )

Broadcasts an already-encoded packet to all players tracking the given chunk.

Use this when you have a pre-encoded packet to avoid re-encoding.

Source

pub fn get_packet_tracking_players(&self, chunk: ChunkPos) -> Vec<i32>

Returns players whose view includes the chunk and whose client has the base chunk packet.

Source

pub fn get_light_packet_tracking_players(&self, chunk: ChunkPos) -> Vec<i32>

Returns players on the tracked border of a chunk whose client has its base chunk packet.

Source

pub(super) fn chunk_is_on_packet_tracked_border( view: PlayerChunkView, chunk: ChunkPos, is_chunk_sent: &impl Fn(ChunkPos) -> bool, ) -> bool

Source

pub(super) fn chunk_is_packet_tracked( view: PlayerChunkView, chunk: ChunkPos, is_chunk_sent: &impl Fn(ChunkPos) -> bool, ) -> bool

Source

pub fn broadcast_to_entity_trackers<P: ClientPacket>( &self, entity_id: i32, packet: P, exclude: Option<i32>, )

Broadcasts a packet to players currently tracking an entity.

Source

pub fn broadcast_to_entity_trackers_except_many<P: ClientPacket>( &self, entity_id: i32, packet: P, excluded_player_ids: &[i32], )

Broadcasts a packet to players tracking an entity, excluding several players.

Source

pub fn broadcast_movement_sync_to_entity_trackers( &self, entity_id: i32, packet: EntityMovementSyncPacket, exclude: Option<i32>, )

Broadcasts an entity movement sync packet to players currently tracking an entity.

Source

pub fn broadcast_to_entity_trackers_encoded( &self, entity_id: i32, packet: EncodedPacket, exclude: Option<i32>, )

Broadcasts an already-encoded packet to players currently tracking an entity.

Source

pub(super) fn encode_movement_sync_packet( &self, packet: EntityMovementSyncPacket, ) -> Option<EncodedPacket>

Source§

impl World

Source

pub fn game_time(&self) -> i64

Returns vanilla level game time.

Source

pub(crate) fn clock_total_ticks(&self, clock: WorldClockRef) -> Option<i64>

Returns the total ticks of one clock in this world.

Source

pub(crate) fn time_sync_packet(&self) -> CSetTime

Creates a full per-world time synchronization packet.

Source

pub(crate) fn broadcast_time_sync(&self)

Broadcasts all clock states to players in this world.

Source

pub(crate) fn set_clock_total_ticks( &self, clock: WorldClockRef, total_ticks: i64, ) -> Option<()>

Source

pub(crate) fn add_clock_ticks( &self, clock: WorldClockRef, ticks: i32, ) -> Option<i64>

Source

pub(crate) fn set_clock_paused( &self, clock: WorldClockRef, paused: bool, ) -> Option<()>

Source

pub(crate) fn set_clock_rate( &self, clock: WorldClockRef, rate: f32, ) -> Option<()>

Source

pub(crate) fn move_clock_to_time_marker( &self, clock: WorldClockRef, marker: &Identifier, ) -> Option<bool>

Source

pub(super) fn modify_clock<R>( &self, clock: WorldClockRef, action: impl FnOnce(&mut WorldClockManager) -> Option<R>, ) -> Option<R>

Source

pub(super) fn tick_time(&self)

Advances game time and this world’s clock instances, then periodically synchronizes game time.

Source§

impl World

Source

pub(crate) const fn block_entity_tickers(&self) -> &WorldBlockEntityTickers

Returns the world-global block-entity ticker owner.

Source

pub(crate) fn game_event_listener_count(&self) -> Arc<GameEventListenerCount>

Shares the counter used to skip game-event dispatch when no chunk has listeners.

Source

pub const fn entity_tracker(&self) -> &EntityTracker

Returns the entity tracker for managing player-entity visibility.

Source

pub(super) fn attach_managed_entity_callback( self: &Arc<Self>, entity: &SharedEntity, )

Source

pub(crate) fn add_entity_to_tracker(self: &Arc<Self>, entity: &SharedEntity)

Source

pub(crate) fn remove_entity_from_tracker(&self, entity_id: i32)

Source

pub(crate) fn apply_entity_lifecycle_changes( self: &Arc<Self>, changes: EntityLifecycleChanges, )

Source

pub(super) fn track_navigating_mob(&self, entity: &SharedEntity)

Source

pub(super) fn untrack_navigating_mob(&self, entity_id: i32)

Source

pub(crate) fn register_loaded_entity( self: &Arc<Self>, entity: SharedEntity, ) -> Result<(), AddEntityError>

Source

pub(crate) fn register_loaded_entity_tree( self: &Arc<Self>, entities: &[SharedEntity], ) -> Result<(), AddEntityError>

Source

pub(crate) fn register_loaded_chunk_entities( self: &Arc<Self>, source_chunk: ChunkPos, persisted_status: ChunkStatus, entities: Vec<SharedEntity>, )

Source

pub(super) fn loaded_entity_trees( entities: Vec<SharedEntity>, ) -> Vec<Vec<SharedEntity>>

Source

pub(super) fn collect_loaded_entity_tree( entity: &SharedEntity, seen: &mut FxHashSet<i32>, tree: &mut Vec<SharedEntity>, )

Source

pub(super) fn discard_loaded_entity_tree(entities: &[SharedEntity])

Source

pub(crate) fn has_full_chunk(&self, chunk_pos: ChunkPos) -> bool

Source

pub fn try_add_entity( self: &Arc<Self>, entity: SharedEntity, ) -> Result<(), AddEntityError>

Adds a runtime entity to the world.

Source

pub(crate) fn on_entity_chunk_loaded(self: &Arc<Self>, pos: ChunkPos)

Source

pub(crate) fn update_entity_chunk_visibility( self: &Arc<Self>, pos: ChunkPos, visibility: EntityVisibility, )

Source

pub(crate) fn on_entity_chunk_unload_start(self: &Arc<Self>, pos: ChunkPos)

Source

pub(crate) fn on_entity_chunk_unload_finalized(&self, pos: ChunkPos)

Source

pub fn spawn_item( self: &Arc<Self>, pos: DVec3, item: ItemStack, ) -> Option<Arc<ItemEntity>>

Spawns an item entity at the given position.

This is a convenience method for dropping items in the world.

Returns None if the item stack is empty.

Source

pub fn spawn_item_with_velocity( self: &Arc<Self>, pos: DVec3, item: ItemStack, velocity: DVec3, ) -> Option<Arc<ItemEntity>>

Spawns an item entity at the given position with initial velocity.

Returns None if the item stack is empty.

Source

pub fn pop_resource( self: &Arc<Self>, pos: BlockPos, item: ItemStack, ) -> Option<Arc<ItemEntity>>

Drops an item at a block position with random offset and velocity.

Mirrors vanilla’s Block.popResource(). Used for block drops. The item spawns near the center of the block with slight random offset and small random velocity.

Source

pub fn pop_experience(self: &Arc<Self>, pos: BlockPos, amount: i32)

Spawns experience at a block position when block drops are enabled.

Mirrors Vanilla’s Block.popExperience.

Source

pub fn pop_resource_from_face( self: &Arc<Self>, pos: BlockPos, face: Direction, item: ItemStack, ) -> Option<Arc<ItemEntity>>

Drops an item from a block face with directional velocity.

Mirrors vanilla’s Block.popResourceFromFace(). Used for items ejected from a specific side of a block.

Source

pub fn get_entity_by_id(&self, id: i32) -> Option<SharedEntity>

Gets an entity by its network ID.

Returns None if the entity is not live in the world.

Source

pub(crate) fn contains_live_or_unloading_entity( &self, entity: &SharedEntity, ) -> bool

Returns true if this exact entity is live or retained for chunk-unload recovery.

Source

pub fn queue_world_change( &self, entity: SharedEntity, request: WorldChangeRequest, )

Queues a world change from world-local code for server safe-point processing.

Source

pub(crate) fn drain_world_changes( &self, ) -> Vec<(SharedEntity, WorldChangeRequest)>

Source

pub fn get_accessible_entity_by_id(&self, id: i32) -> Option<SharedEntity>

Gets an entity by its network ID if it is visible to vanilla gameplay lookups.

Returns None if the entity is not live or is hidden in an inaccessible chunk.

Source

pub fn get_entity_by_uuid(&self, uuid: &Uuid) -> Option<SharedEntity>

Gets an entity by its UUID.

Returns None if the entity is not live in the world.

Source

pub fn get_entities_in_aabb(&self, aabb: &WorldAabb) -> Vec<SharedEntity>

Gets all entities intersecting the given bounding box.

Only returns entities in loaded chunks.

Source

pub fn get_entities_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Vec<SharedEntity>

Gets entities intersecting the given bounding box and matching predicate.

Only returns entities in loaded chunks.

Source

pub fn has_entity_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> bool

Returns whether any entity intersects the given bounding box and matches predicate.

Only checks entities in loaded chunks.

Source

pub fn get_entity_bounding_boxes_in_aabb_matching( &self, aabb: &WorldAabb, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Vec<WorldAabb>

Gets matching entity bounding boxes intersecting the given bounding box.

Only checks entities in loaded chunks.

Source

pub fn nearest_entity_in_aabb_matching( &self, aabb: &WorldAabb, origin: DVec3, predicate: impl FnMut(&dyn Entity) -> bool, ) -> Option<SharedEntity>

Gets the nearest entity intersecting the given bounding box and matching predicate.

Only returns entities in loaded chunks.

Source

pub fn nearest_player( &self, position: DVec3, max_distance: f64, predicate: impl FnMut(&Player) -> bool, ) -> Option<Arc<Player>>

Gets the nearest player to position within max_distance.

Source

pub fn nearest_player_distance_sqr(&self, position: DVec3) -> Option<f64>

Gets the squared distance to the nearest player, if any player is present.

Source

pub fn get_pushable_entities( &self, pusher: &dyn Entity, aabb: &WorldAabb, ) -> Vec<SharedEntity>

Gets entities matching vanilla’s pushable entity selector for pusher.

Vanilla also checks team collision rules; Steel has no teams yet, so this currently matches the null-team path where collision is allowed.

Source

pub fn register_game_event_listener( &self, section_pos: SectionPos, listener: SharedGameEventListener, )

Registers a game event listener in a chunk section.

Source

pub fn unregister_game_event_listener( &self, section_pos: SectionPos, listener: &SharedGameEventListener, ) -> bool

Unregisters a game event listener from a chunk section.

Source

pub(super) fn game_event_listener_storage( &self, chunk_pos: ChunkPos, ) -> Option<Arc<GameEventListenerStorage>>

Returns a stable registry handle without retaining the chunk holder read guard.

Source

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

Dispatches a game event to all listeners in range.

Source

pub fn game_event_at( self: &Arc<Self>, event: GameEventRef, source_pos: DVec3, context: &GameEventContext<'_>, )

Dispatches a game event from an exact world position.

Source§

impl World

Source

pub fn broadcast_block_destruction( &self, entity_id: i32, pos: BlockPos, progress: i32, )

Broadcasts block destruction progress to nearby players.

Note: The packet is NOT sent to the player doing the breaking (matching vanilla). The breaking player sees progress through client-side prediction.

§Arguments
  • entity_id - The entity ID of the player breaking the block
  • pos - The position of the block being broken
  • progress - The destruction progress (0-9), or -1 to clear
Source

pub fn broadcast_block_entity_update( &self, pos: BlockPos, block_entity_type: BlockEntityTypeRef, nbt: NbtCompound, )

Broadcasts a block entity update to all players tracking the chunk.

This is used when block entity data changes (e.g., sign text updated).

§Arguments
  • pos - The position of the block entity
  • block_entity_type - The type of block entity
  • nbt - The NBT data to send
Source

pub(crate) fn broadcast_block_entity_if_needed(&self, pos: BlockPos)

Broadcasts the current block-entity update packet when that entity type exposes client-visible update data.

Source

pub fn drop_item_stack(self: &Arc<Self>, pos: BlockPos, item: ItemStack)

Drops an item stack at the given position with scatter behavior.

Mirrors vanilla’s Containers.dropItemStack. Splits large stacks into multiple item entities (10-30 items each) and scatters them with random positions and velocities.

§Arguments
  • pos - The block position to drop the item at
  • item - The item stack to drop
Source§

impl World

Source

pub fn level_event( &self, event_type: i32, pos: BlockPos, data: i32, exclude: Option<i32>, )

Broadcasts a level event to nearby players within 64 blocks.

Level events trigger sounds, particles, and animations on the client. See steel_registry::level_events for available event type constants.

§Arguments
  • event_type - The event type ID from steel_registry::level_events
  • pos - The position where the event occurs
  • data - Event-specific data (e.g., block state ID for block destruction)
  • exclude - Optional entity ID to exclude from receiving the event
Source

pub(super) fn recipient_within_64_blocks( player_pos: DVec3, event_pos: BlockPos, ) -> bool

Source

pub fn send_particles( &self, particle: ParticleData, position: DVec3, count: i32, spread: DVec3, speed: f64, ) -> i32

Sends a particle distribution to every player within Vanilla’s normal 32-block particle radius.

Source

pub fn send_particles_with_options( &self, particle: ParticleData, override_limiter: bool, always_show: bool, position: DVec3, count: i32, spread: DVec3, speed: f64, ) -> i32

Sends a particle distribution with the packet visibility flags selected explicitly. override_limiter also expands the server recipient radius from 32 to 512 blocks, matching ServerLevel.sendParticles.

Source

pub fn send_particles_to( self: &Arc<Self>, player: &Player, particle: ParticleData, override_limiter: bool, always_show: bool, position: DVec3, count: i32, spread: DVec3, speed: f64, ) -> bool

Sends a particle distribution to one player if they are in this world and within Vanilla’s particle recipient radius.

Source

pub(super) fn particle_recipient_in_range( player_block_pos: BlockPos, particle_pos: DVec3, override_limiter: bool, ) -> bool

Source

pub fn global_level_event(&self, event_type: i32, pos: BlockPos, data: i32)

Broadcasts a global level event to all players in the world.

When global_sound_events is disabled, vanilla falls back to a normal nearby level event with the packet’s global flag unset.

§Arguments
  • event_type - The event type ID from steel_registry::level_events
  • pos - The position where the event occurs
  • data - Event-specific data
Source

pub fn destroy_block_effect( &self, pos: BlockPos, block_state_id: u32, exclude: Option<i32>, )

Broadcasts block destruction particles and sound for a destroyed block.

This is a convenience method that sends the PARTICLES_DESTROY_BLOCK level event.

§Arguments
  • pos - The position of the destroyed block
  • block_state_id - The block state ID of the destroyed block
  • exclude - Optional entity ID to exclude from receiving the event
Source

pub fn destroy_block(self: &Arc<Self>, pos: BlockPos, drop_items: bool) -> bool

Destroys a block at the given position, optionally dropping its loot.

Sends destruction particles (skipping fire blocks), optionally drops resources via loot table, then replaces with air.

Defaults to recursion limit of 512

Source

pub fn remove_block( self: &Arc<Self>, pos: BlockPos, moved_by_piston: bool, ) -> bool

Replaces a block with its fluid state’s legacy block.

Mirrors vanilla Level.removeBlock, including the piston-move update flag.

Source

pub fn destroy_block_by_entity( self: &Arc<Self>, pos: BlockPos, drop_items: bool, entity: &dyn Entity, ) -> bool

Destroys a block with an entity source for game-event context.

Source

pub fn destroy_block_with_limit( self: &Arc<Self>, pos: BlockPos, drop_items: bool, recursion_left: i32, ) -> bool

Destroys a block at the given position, optionally dropping its loot.

Sends destruction particles (skipping fire blocks), optionally drops resources via loot table, then replaces with air.

Source

pub(super) fn destroy_block_with_limit_and_entity( self: &Arc<Self>, pos: BlockPos, drop_items: bool, recursion_left: i32, entity: Option<&dyn Entity>, ) -> bool

Source

pub fn drop_resources(self: &Arc<Self>, state: BlockStateId, pos: BlockPos)

Drops the loot for a block using its loot table.

This is the no-tool/no-entity overload. Player block breaking uses block_breaking::drop_block_loot which includes tool context for fortune/silk touch.

Source

pub(super) fn drop_resources_with_entity( self: &Arc<Self>, state: BlockStateId, pos: BlockPos, entity: Option<&dyn Entity>, )

Source

pub(crate) fn block_drops( state: BlockStateId, context: &BlockLootContext<'_>, ) -> Vec<ItemStack>

Source

pub(super) fn default_block_drops( state: BlockStateId, context: &BlockLootContext<'_>, ) -> Vec<ItemStack>

Source

pub fn play_sound( &self, sound: SoundEventRef, source: SoundSource, pos: BlockPos, volume: f32, pitch: f32, exclude: Option<i32>, )

Plays a sound at a specific position, broadcasting to nearby players.

The sound is sent to players within its vanilla range, except for the excluded player (if any). The excluded player is typically the one who triggered the sound, as they hear it client-side.

§Arguments
  • sound - The sound event to play
  • source - The sound source category
  • pos - The block position (sound plays at center of block)
  • volume - Volume multiplier (1.0 = normal)
  • pitch - Pitch multiplier (1.0 = normal)
  • exclude - Optional entity ID to exclude from receiving the sound
Source

pub fn play_sound_at( &self, sound: SoundEventRef, source: SoundSource, pos: DVec3, volume: f32, pitch: f32, exclude: Option<i32>, )

Plays a sound at an exact world position, broadcasting to nearby players.

Source

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

Plays a block sound at a specific position.

Convenience method that uses the BLOCKS sound source and applies the sound type’s volume and pitch modifiers.

§Arguments
  • sound - The sound event to play
  • pos - The block position
  • volume - Base volume (typically from SoundType)
  • pitch - Base pitch (typically from SoundType)
  • exclude - Optional entity ID to exclude from receiving the sound
Source

pub(crate) const fn entity_manager(&self) -> &WorldEntityManager

Returns the runtime entity manager.

Source§

impl World

Source

pub async fn find_adjusted_shared_spawn_pos( self: &Arc<Self>, spawn_suggestion: BlockPos, game_type: GameType, ) -> Result<DVec3, String>

Finds the adjusted shared spawn position used for players entering this world’s default spawn.

Source

pub async fn prepare_player_spawn_chunks( self: &Arc<Self>, spawn_position: DVec3, ) -> Result<ChunkRequestHandle, String>

Loads the vanilla radius-3 full chunk square around a prepared player spawn.

Source

pub(crate) fn request_player_spawn_chunks( self: &Arc<Self>, spawn_position: DVec3, ) -> ChunkRequestHandle

Source

fn request_spawn_candidate_chunk( self: &Arc<Self>, x: i32, z: i32, ) -> ChunkRequestHandle

Source

async fn wait_for_chunk_request( request: &ChunkRequestHandle, ) -> Result<(), String>

Source

fn fixup_spawn_height(self: &Arc<Self>, spawn_pos: BlockPos) -> DVec3

Source

fn no_collision_no_liquid(self: &Arc<Self>, pos: BlockPos) -> bool

Source§

impl World

Source

pub fn find_closest_nether_portal_position( &self, approximate_exit_pos: BlockPos, to_nether: bool, ) -> Option<BlockPos>

Finds the closest existing Nether portal POI using vanilla PortalForcer ordering.

to_nether selects vanilla’s 16-block Nether search radius; non-Nether targets use 128.

§Panics

Panics if vanilla POI registries were not initialized before portal lookup.

Source

pub fn create_nether_portal( self: &Arc<Self>, origin: BlockPos, portal_axis: Axis, ) -> Option<FoundRectangle>

Creates a Nether portal using vanilla PortalForcer.createPortal placement rules.

The caller must keep the target search area loaded as full chunks before calling. Steel returns None if any required chunk read or write is unavailable, rather than treating unloaded chunks as replaceable air.

Source

pub(crate) fn place_portal_ticket(&self, ticket_position: BlockPos)

Adds or refreshes vanilla’s portal chunk ticket for a post-teleport entity.

Source

pub(super) fn find_nether_portal_creation_position( &self, origin: BlockPos, direction: Direction, max_placeable_y: i32, ) -> Result<Option<BlockPos>, MissingPortalCreationChunk>

Source

pub(super) fn can_nether_portal_replace_block( &self, pos: BlockPos, ) -> Result<bool, MissingPortalCreationChunk>

Source

pub(super) fn can_host_nether_portal_frame( &self, origin: BlockPos, direction: Direction, offset: i32, ) -> Result<bool, MissingPortalCreationChunk>

Source

pub(super) fn loaded_block_state(&self, pos: BlockPos) -> Option<BlockStateId>

Source

pub(super) fn fallback_nether_portal_position( &self, origin: BlockPos, direction: Direction, max_placeable_y: i32, ) -> Option<BlockPos>

Source

pub(super) fn can_write_nether_portal_fallback_box( &self, origin: BlockPos, direction: Direction, ) -> bool

Source

pub(super) fn can_write_nether_portal_rectangle( &self, origin: BlockPos, direction: Direction, ) -> bool

Source

pub(super) fn can_write_loaded_block(&self, pos: BlockPos) -> bool

Source

pub(crate) fn create_end_platform(self: &Arc<Self>, origin: BlockPos) -> bool

Mirrors vanilla EndPlatformFeature.createEndPlatform for runtime End portal travel.

Source

pub(crate) fn is_end_gateway_chunk_empty( &self, chunk_pos: ChunkPos, ) -> Option<bool>

Mirrors vanilla TheEndGatewayBlockEntity.isChunkEmpty.

Source

pub(crate) fn find_end_gateway_valid_spawn_in_chunk( &self, chunk_pos: ChunkPos, ) -> Option<BlockPos>

Mirrors vanilla TheEndGatewayBlockEntity.findValidSpawnInChunk.

Source

pub(crate) fn find_end_gateway_tallest_block( &self, around: BlockPos, dist: i32, allow_bedrock: bool, ) -> BlockPos

Mirrors vanilla TheEndGatewayBlockEntity.findTallestBlock.

Source

pub(super) fn is_collision_shape_full_block_at( &self, pos: BlockPos, state: BlockStateId, ) -> bool

Source

pub(crate) fn create_end_island(self: &Arc<Self>, origin: BlockPos) -> bool

Mirrors vanilla EndIslandFeature.place for runtime End gateway island creation.

Source

pub(crate) fn create_end_gateway_portal( self: &Arc<Self>, origin: BlockPos, exit: BlockPos, exact: bool, ) -> bool

Mirrors vanilla EndGatewayFeature.place for runtime End gateway creation.

Source

pub(super) fn clear_nether_portal_fallback_box( self: &Arc<Self>, origin: BlockPos, direction: Direction, ) -> bool

Source

pub(super) fn place_nether_portal_frame_and_blocks( self: &Arc<Self>, origin: BlockPos, direction: Direction, portal_axis: Axis, ) -> bool

Source§

impl World

Source

pub fn difficulty(&self) -> Difficulty

Returns vanilla level difficulty.

Source

pub(crate) fn set_difficulty(&self, difficulty: Difficulty)

Sets the level difficulty and broadcasts the new value to its players.

Source

pub const fn get_height(&self) -> i32

Returns the total height of the world in blocks.

Source

pub const fn get_min_y(&self) -> i32

Returns the minimum Y coordinate of the world.

Source

pub const fn get_max_y(&self) -> i32

Returns the maximum Y coordinate of the world.

Source

pub const fn is_outside_build_height(&self, block_y: i32) -> bool

Returns whether the given Y coordinate is outside the build height.

Source

pub const fn is_in_valid_bounds_horizontal(&self, block_pos: BlockPos) -> bool

Returns whether the block position is within valid horizontal bounds.

Source

pub const fn is_in_valid_bounds(&self, block_pos: BlockPos) -> bool

Returns whether the block position is within valid world bounds.

Source

pub const fn is_in_spawnable_bounds(block_pos: BlockPos) -> bool

Returns whether the block position is within vanilla spawnable bounds.

Source

pub(super) const fn is_in_world_bounds_horizontal(block_pos: BlockPos) -> bool

Source

pub(super) const fn is_outside_spawnable_height(y: i32) -> bool

Source

pub const fn max_build_height(&self) -> i32

Returns the maximum build height (one above the highest placeable block). This is min_y + height.

Source

pub const fn may_interact(&self, _player: &Player, pos: BlockPos) -> bool

Checks if a player may interact with the world at the given position. Currently only checks if position is within world bounds.

Source

pub fn is_unobstructed( &self, collision_shape: OffsetVoxelShape, pos: BlockPos, ) -> bool

Checks if a block’s collision shape at the given position is unobstructed by entities.

This is the Rust equivalent of vanilla’s Level.isUnobstructed(BlockState, BlockPos, CollisionContext). In vanilla, this checks all entities with blocksBuilding=true (players, mobs, boats, etc.).

Returns true if the position is clear, false if an entity would obstruct placement.

Source

pub fn tick_runs_normally(&self) -> bool

Returns whether the tick rate is running normally.

When false (frozen/paused), movement validation checks should be skipped. Matches vanilla’s level.tickRateManager().runsNormally().

Source

pub fn set_tick_runs_normally(&self, runs_normally: bool)

Sets whether the tick rate is running normally.

Set to false to freeze/pause the world (e.g., via /tick freeze command).

Source

pub(crate) fn is_handling_tick(&self) -> bool

Mirrors ServerLevel.isHandlingTick for piston early-retraction rules.

Source

pub fn get_game_rule<T: GameRuleValueType>(&self, rule: &GameRule<T>) -> T

Gets the value of a game rule. WARNING: this function acquires a read lock on the level data. if you already have a write lock on level data, this will DEADLOCK

Source

pub fn get_game_rule_with_guard<T: GameRuleValueType>( &self, rule: &GameRule<T>, guard: &LevelDataManager, ) -> T

Gets the value of a game rule on the LevelDataManager guard being passed in.

Source

pub fn get_erased_game_rule(&self, rule: ErasedGameRuleRef) -> GameRuleValue

Gets a type-erased value for a dynamically selected game rule.

Source

pub fn set_game_rule<T: GameRuleValueType>( &self, rule: &GameRule<T>, value: T, ) -> bool

Sets the value of a game rule. WARNING: this function acquires a write lock on the level data. if you already have a read or write lock on level data, this will DEADLOCK

Source

pub fn set_game_rule_with_guard<T: GameRuleValueType>( &self, rule: &GameRule<T>, value: T, guard: &mut LevelDataManager, ) -> bool

Sets the value of a game rule on the LevelDataManager guard being passed in.

Source

pub fn set_erased_game_rule( &self, rule: ErasedGameRuleRef, value: GameRuleValue, ) -> bool

Sets a type-erased value for a dynamically selected game rule.

Source

pub(super) fn advance_time_with_guard(&self, guard: &LevelDataManager) -> bool

Source

pub fn seed(&self) -> i64

Gets the world seed.

Source

pub fn obfuscated_seed(&self) -> i64

Gets the obfuscated seed for sending to clients.

This uses SHA-256 hashing to prevent clients from easily extracting the actual world seed, matching vanilla’s BiomeManager.obfuscateSeed().

Source§

impl World

Source

pub fn ray_outline_check( &self, block_pos: BlockPos, from: DVec3, to: DVec3, ) -> (bool, Option<Direction>)

Checks if a ray intersects with a block’s selection box.

Source

pub fn clip( &self, start_pos: DVec3, end_pos: DVec3, block_shape: ClipBlockShape, fluid: ClipFluid, ) -> ClipHitResult

Performs a vanilla-style block/fluid clip in the world.

Source

pub fn clip_including_border( &self, start_pos: DVec3, end_pos: DVec3, block_shape: ClipBlockShape, fluid: ClipFluid, ) -> ClipHitResult

Performs vanilla CollisionGetter.clipIncludingBorder.

Source

pub(super) fn clip_block_and_fluid( &self, pos: BlockPos, from: DVec3, to: DVec3, block_shape: ClipBlockShape, fluid: ClipFluid, ) -> Option<ClipHitResult>

Source

pub(super) fn clip_with_interaction_override( pos: BlockPos, from: DVec3, to: DVec3, state: BlockStateId, block_hit: ClipHitResult, ) -> ClipHitResult

Source

pub(super) fn clip_block_shape( &self, state: BlockStateId, pos: BlockPos, shape: ClipBlockShape, ) -> OffsetVoxelShape

Source

pub(super) fn fall_damage_resetting_shape( &self, state: BlockStateId, entity_is_player: bool, ) -> VoxelShape

Source

pub(super) fn clip_fluid_shape( &self, pos: BlockPos, from: DVec3, to: DVec3, state: BlockStateId, fluid: ClipFluid, ) -> Option<ClipHitResult>

Source

pub(super) fn fluid_clip_height( &self, pos: BlockPos, fluid_state: FluidState, ) -> f64

Source

pub(super) fn fluid_clip_height_from_above( fluid_state: FluidState, above_fluid: FluidState, ) -> f64

Source

pub(super) fn clip_shape( block_pos: BlockPos, from: DVec3, to: DVec3, shape: OffsetVoxelShape, ) -> Option<ClipHitResult>

Source

pub(super) fn clip_local_aabb( block_pos: BlockPos, from: DVec3, to: DVec3, aabb: BlockLocalAabb, ) -> Option<ClipHitResult>

Source

pub(super) fn shape_contains_world_point( shape: OffsetVoxelShape, block_vec: DVec3, point: DVec3, ) -> bool

Source

pub(super) fn local_aabb_contains_world_point( aabb: BlockLocalAabb, block_vec: DVec3, point: DVec3, ) -> bool

Source

pub(super) fn clip_miss(from: DVec3, to: DVec3) -> ClipHitResult

Source

pub(super) fn approximate_nearest_direction(vector: DVec3) -> Direction

Source

pub(super) fn intersects_aabb_with_t( start: DVec3, end: DVec3, min: DVec3, max: DVec3, ) -> Option<(f64, Direction)>

Ray-AABB intersection returning the entry t-parameter and the hit face.

Returns Some((tmin, direction)) where tmin is the ray parameter at entry and direction is the face normal pointing away from the hit surface. Returns None if the AABB is missed or entirely behind the ray origin.

Used internally by [ray_outline_check] to pick the closest hit across a multi-box voxel shape, matching vanilla’s VoxelShape.clip() behavior.

Source

pub fn raytrace<F>( &self, start_pos: DVec3, end_pos: DVec3, hit_check: F, ) -> (Option<BlockPos>, Option<Direction>)
where F: Fn(BlockPos, &Self) -> RaytraceAction,

Performs a raytrace in the world.

Adapted from Pumpkin project.

Source§

impl World

Source

pub(crate) fn prune_recent_redstone_torch_toggles(&self)

Removes torch toggles older than vanilla’s 60-game-tick window.

Source

pub(crate) fn redstone_torch_toggled_too_frequently( &self, pos: BlockPos, add: bool, ) -> bool

Counts recent toggles for pos, optionally recording one first.

This bookkeeping and scheduled tick deadlines both use world game time, matching Vanilla’s loaded-world timing model.

Source§

impl World

Source

pub async fn initialize_spawn_if_needed(self: &Arc<Self>) -> Result<(), String>

Initializes this world’s default spawn using vanilla’s first-world spawn search.

Source

pub(super) fn find_spawn_in_loaded_radius( &self, spawn_chunk: ChunkPos, ) -> Option<BlockPos>

Source

pub(super) fn spawn_pos_in_chunk(&self, chunk_pos: ChunkPos) -> Option<BlockPos>

Source

pub(super) fn level_respawn_pos(&self, x: i32, z: i32) -> Option<BlockPos>

Source

pub(crate) fn height_at( &self, heightmap_type: HeightmapType, x: i32, z: i32, ) -> Option<i32>

Source

pub(super) fn vanilla_chunk_height_at( &self, heightmap_type: HeightmapType, x: i32, z: i32, ) -> Option<i32>

Source

pub(super) fn heightmap_pos( &self, heightmap_type: HeightmapType, pos: BlockPos, ) -> BlockPos

Source

pub(crate) fn adjust_spawn_location( &self, spawn_suggestion: BlockPos, ) -> BlockPos

Mirrors vanilla Entity.adjustSpawnLocation for cross-world returns.

Source

pub(super) fn level_height_at( &self, heightmap_type: HeightmapType, x: i32, z: i32, ) -> i32

Source§

impl World

Source

pub fn schedule_block_tick( &self, pos: BlockPos, block: BlockRef, delay: i32, priority: TickPriority, )

Schedules a block tick at the given position.

The tick will fire after delay world game ticks with the given priority. Its deadline continues to age while the loaded chunk is outside simulation distance. Only one tick per (pos, block) pair can be active at a time — duplicates are silently ignored.

Source

pub fn schedule_block_tick_default( &self, pos: BlockPos, block: BlockRef, delay: i32, )

Schedules a block tick with Normal priority.

Source

pub fn schedule_fluid_tick( &self, pos: BlockPos, fluid: FluidRef, delay: i32, priority: TickPriority, )

Schedules a fluid tick at the given position.

The tick will fire after delay world game ticks with the given priority. Its deadline continues to age while the loaded chunk is outside simulation distance. Only one tick per (pos, fluid) pair can be active at a time.

Source

pub fn schedule_fluid_tick_default( &self, pos: BlockPos, fluid: FluidRef, delay: i32, )

Schedules a fluid tick with Normal priority.

Source

pub fn has_scheduled_block_tick(&self, pos: BlockPos, block: BlockRef) -> bool

Returns true if a block tick is already scheduled for the given (pos, block).

§Panics

Panics if a published Full chunk’s scheduled-tick container was finalized, which violates the chunk publication invariant.

Source

pub fn has_scheduled_fluid_tick(&self, pos: BlockPos, fluid: FluidRef) -> bool

Returns true if a fluid tick is already scheduled for the given (pos, fluid).

§Panics

Panics if a published Full chunk’s scheduled-tick container was finalized, which violates the chunk publication invariant.

Source

pub(crate) fn register_full_chunk_ticks( &self, chunk: FullChunkRef<'_>, ) -> Result<(), TickSchedulerError>

Source

pub(crate) fn unregister_full_chunk_ticks(&self, pos: ChunkPos)

Source

pub(crate) fn schedule_block_tick_for_chunk( &self, chunk: FullChunkRef<'_>, pos: BlockPos, block: BlockRef, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Result<bool, TickSchedulerError>

Source

pub(crate) fn schedule_fluid_tick_for_chunk( &self, chunk: FullChunkRef<'_>, pos: BlockPos, fluid: FluidRef, trigger_tick: i64, priority: TickPriority, sub_tick_order: i64, ) -> Result<bool, TickSchedulerError>

Source

pub(crate) fn unpack_scheduled_ticks( &self, pos: ChunkPos, ) -> Result<(), TickSchedulerError>

Source

pub(crate) fn reconcile_active_scheduled_tick_chunks<I>( &self, active_chunks: I, ) -> Result<(), TickSchedulerError>
where I: Iterator<Item = ChunkPos> + Clone,

Source

pub(crate) fn begin_scheduled_tick_phase( &self, current_tick: i64, max_ticks: usize, ) -> ScheduledTickBatch<BlockRef>

Source

pub(crate) fn collect_scheduled_fluid_tick_batch( &self, current_tick: i64, max_ticks: usize, ) -> ScheduledTickBatch<FluidRef>

Source

pub fn will_tick_block_this_tick(&self, pos: BlockPos, block: BlockRef) -> bool

Returns whether a selected block tick at (pos, block) has not started yet.

This mirrors LevelTickAccess.willTickThisTick and is distinct from Self::has_scheduled_block_tick, because selected ticks have already been removed from their owning chunk queue.

Source

pub fn will_tick_fluid_this_tick(&self, pos: BlockPos, fluid: FluidRef) -> bool

Returns whether a selected fluid tick at (pos, fluid) has not started yet.

Source

pub(crate) fn begin_scheduled_block_tick_batch( &self, ticks: Vec<BlockTick>, ) -> Arc<ScheduledTickRunBatch<BlockRef>>

Source

pub(crate) fn end_scheduled_block_tick_batch( &self, batch: &Arc<ScheduledTickRunBatch<BlockRef>>, )

Source

pub(crate) fn begin_scheduled_fluid_tick_batch( &self, ticks: Vec<FluidTick>, ) -> Arc<ScheduledTickRunBatch<FluidRef>>

Source

pub(crate) fn end_scheduled_fluid_tick_batch( &self, batch: &Arc<ScheduledTickRunBatch<FluidRef>>, )

Source§

impl World

Source

pub(super) fn tick_weather(&self)

Source

pub(crate) fn set_weather_parameters( &self, clear_time: i32, rain_time: i32, raining: bool, thundering: bool, )

Sets this world’s weather timers and flags.

Minecraft 26.2 owns this state at server scope. Steel intentionally owns it per world so multiple worlds in one domain can have independent weather.

Source

pub fn is_raining(&self) -> bool

Checks whether the rain level is high enough to be considered raining. Used for both visual rendering and gameplay logic (crop growth, fire, mob behavior).

WARNING: this function acquires a lock on the weather field. if you already have a lock on the weather field, this will DEADLOCK.

Source

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

Checks whether rain reaches the given block position.

Mirrors vanilla Level.isRainingAt: global rain state, sky exposure, motion-blocking height, and biome precipitation must all allow rain.

Source

pub fn is_raining_with_guard(&self, guard: &Weather) -> bool

Checks whether the rain level is sufficient to render rain clientside using the provided guard.

Source

pub fn is_thundering(&self) -> bool

Checks whether the thunder level and rain level are high enough to be considered thundering. Used for lightning spawning and gameplay logic.

WARNING: this function acquires a lock on the weather field. if you already have a lock on the weather field, this will DEADLOCK.

Source

pub fn is_thundering_with_guard(&self, guard: &Weather) -> bool

Checks whether the thunder level and rain level are sufficient to spawn thunderbolts using the provided guard.

Source

pub fn sky_light_level(&self) -> f32

Returns the current vanilla SKY_LIGHT_LEVEL environment attribute.

Source

pub fn sky_darkening(&self) -> u8

Returns vanilla Level.skyDarken.

Source

pub fn sun_angle_degrees(&self) -> f32

Returns the current vanilla SUN_ANGLE environment attribute in degrees.

Source

pub fn effective_sky_brightness(&self, pos: BlockPos) -> u8

Returns sky-layer light after the current sky darkening is subtracted.

Mirrors vanilla LevelReader.getEffectiveSkyBrightness without allowing block light to raise the result.

Source

pub fn is_bright_outside(&self) -> bool

Returns vanilla Level.isBrightOutside.

Source

pub fn is_dark_outside(&self) -> bool

Returns vanilla Level.isDarkOutside.

Source

pub fn can_have_weather(&self) -> bool

Checks whether the world can have weather.

Source

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

Returns whether the position has unobstructed sky exposure.

Live worlds use the motion-blocking heightmap until Steel has a full live sky-light engine.

Source

pub(super) fn can_see_sky_for_precipitation(&self, pos: BlockPos) -> bool

Source

pub(crate) fn biome_at(&self, pos: BlockPos) -> Option<BiomeRef>

Source

pub(super) fn noise_biome_id( &self, quart_x: i32, quart_y: i32, quart_z: i32, ) -> Option<u16>

Source

pub(super) fn biome_quart_y_indices( min_y: i32, section_count: usize, quart_y: i32, ) -> Option<(usize, usize)>

Source

pub(super) fn biome_temperature(&self, biome: BiomeRef, pos: BlockPos) -> f32

Source§

impl World

Source

pub(crate) fn contains_player(&self, player: &Player) -> bool

Returns whether this exact player is registered in this world.

Source

fn loaded_world_memberships(player: &Arc<Player>) -> Vec<Arc<World>>

Source

fn reject_duplicate_player_membership( player: &Arc<Player>, target_world: &Arc<World>, operation: &str, ) -> bool

Source

fn take_player_for_removal(&self, player: &Arc<Player>) -> Option<Arc<Player>>

Source

fn attach_player_entity_callback(self: &Arc<Self>, player: &Arc<Player>)

Source

fn register_player_entity(self: &Arc<Self>, player: &Arc<Player>)

Source

fn unride_player_for_removal(&self, player: &Player, store_root_vehicle: bool)

Source

fn remove_root_vehicle_tree_stored_with_player(entity: SharedEntity)

Source

pub(crate) fn unregister_player_entity(&self, player: &Player)

Source

pub(crate) fn register_respawned_player_entity( self: &Arc<Self>, player: &Arc<Player>, )

Source

pub(crate) fn add_respawned_player( self: &Arc<Self>, player: Arc<Player>, ) -> bool

Source

pub(crate) fn detach_player_for_disconnect( self: &Arc<Self>, player: Arc<Player>, ) -> (Arc<Player>, String, PersistentPlayerData)

Detaches a disconnecting player from live world state and snapshots it.

Persistence happens asynchronously after the server’s pre-tick phase completes.

Source

pub(crate) fn remove_player_for_world_change( self: &Arc<Self>, player: &Arc<Player>, )

Removes a player from the world during a world change.

Unlike remove_player, this is synchronous and skips player data saving and tab list removal — the player stays in the global tab list since they are only switching worlds.

Source

pub(crate) fn detach_player_for_domain_switch( self: &Arc<Self>, player: &Arc<Player>, ) -> Option<(PersistentPlayerData, DomainResidenceToken)>

Detaches a player for a domain switch and returns its persistence snapshot.

Source

pub(crate) fn add_player( self: &Arc<Self>, player: Arc<Player>, _reason: ResetReason, ) -> bool

Adds a player to the world.

On InitialJoin, sends full tab list + entity spawn synchronization to/from all players. On WorldChange, this is skipped — the player already exists in all clients’ tab lists and the entity tracker handles spawning as chunks load.

Source§

impl World

Source

pub async fn new_with_config( chunk_runtime: Arc<Runtime>, key: Identifier, dimension_type: DimensionTypeRef, seed: i64, config: WorldConfig, generation_pool: Arc<ThreadPool>, ) -> Result<Arc<Self>>

Creates a new world with custom configuration.

This allows specifying storage backend (disk or RAM-only) and other options. Uses Arc::new_cyclic to create a cyclic reference between the World and its ChunkMap’s WorldGenContext.

§Arguments
  • chunk_runtime - The Tokio runtime for chunk operations
  • dimension_type - Vanilla dimension type (overworld, nether, end)
  • seed - The world seed
  • config - World configuration including storage options
Source

pub(crate) async fn new_with_config_and_encoding_pool( chunk_runtime: Arc<Runtime>, key: Identifier, dimension_type: DimensionTypeRef, seed: i64, config: WorldConfig, generation_pool: Arc<ThreadPool>, chunk_encoding_pool: Arc<ThreadPool>, ) -> Result<Arc<Self>>

Source

pub async fn cleanup(&self, total_saved: &mut usize)

Cleans up the world by saving all chunks.

Source

pub fn domain(&self) -> &str

Returns the domain this loaded world belongs to.

Source

pub fn tick_game( self: &Arc<Self>, tick_count: u64, runs_normally: bool, ) -> WorldGameTickTimings

Game tick: weather, time, chunk game tick (broadcasts + random/scheduled ticks), and player logic (without chunk sending).

  • tick_count - The current tick number
  • runs_normally - Whether game elements (random ticks, entities) should run. When false (frozen), only essential operations like chunk loading run.
Source

pub async fn save_all_chunks(&self) -> Result<usize>

Saves all dirty chunks in this world to disk.

This should be called during graceful shutdown. Returns the number of chunks saved.

Trait Implementations§

Source§

impl LevelReader for World

Source§

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

Gets the block state at a position.
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_for( &self, state: BlockStateId, pos: BlockPos, direction: Direction, support_type: SupportType, ) -> bool

Mirrors vanilla BlockState.isFaceSturdy for a specific support type. Read more
Source§

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

Returns vanilla raw brightness at a position after sky darkening.
Source§

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

Returns vanilla BlockAndLightGetter.canSeeSky.
Source§

fn ambient_light(&self) -> f32

Returns this dimension’s vanilla ambient light factor.
Source§

fn min_y(&self) -> i32

Returns the minimum build height.
Source§

fn height(&self) -> i32

Returns the build height.
Source§

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

Mirrors vanilla BlockState.isFaceSturdy with full-face support.
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 vanilla LevelReader.getMaxLocalRawBrightness.
Source§

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

Returns vanilla LevelReader.getLightLevelDependentMagicValue.
Source§

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

Returns vanilla LevelReader.getPathfindingCostFromLightLevels.
Source§

impl PistonLevel for World

Auto Trait Implementations§

§

impl !Freeze for World

§

impl !RefUnwindSafe for World

§

impl !UnwindSafe for World

§

impl Send for World

§

impl Sync for World

§

impl Unpin for World

§

impl UnsafeUnpin for World

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SignalGetter for T
where T: LevelReader,

Source§

fn is_redstone_conductor(&self, state: BlockStateId, pos: BlockPos) -> bool

Returns whether state conducts direct power at this level position.
Source§

fn get_direct_signal(&self, pos: BlockPos, direction: Direction) -> i32

Returns the direct signal emitted by the block at pos toward direction.
Source§

fn get_direct_signal_to(&self, pos: BlockPos) -> i32

Returns the strongest direct signal entering pos from its six neighbors.
Source§

fn get_control_input_signal( &self, pos: BlockPos, direction: Direction, only_diodes: bool, ) -> i32

Returns the side input used by vanilla diode blocks.
Source§

fn has_signal(&self, pos: BlockPos, direction: Direction) -> bool

Returns whether the block at pos supplies a signal toward direction.
Source§

fn get_signal(&self, pos: BlockPos, direction: Direction) -> i32

Returns the signal supplied by the block at pos toward direction.
Source§

fn get_best_own_or_neighbour_signal(&self, pos: BlockPos) -> i32

Returns the strongest signal at pos, including the block’s own source value.
Source§

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

Returns whether any of the six neighbors supplies signal to pos.
Source§

fn get_best_neighbor_signal(&self, pos: BlockPos) -> i32

Returns the strongest signal supplied to pos by its six neighbors.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more