pub struct World {
pub chunks: ChunkStorage,
pub entities_by_chunk: HashMap<ChunkPos, HashSet<Entity>>,
pub entity_by_id: IntMap<MinecraftEntityId, Entity>,
pub registries: RegistryHolder,
}Expand description
A Minecraft world, sometimes referred to as a dimension.
This is the most commonly used type to interact with the world that a client
is in. In here, all chunks are stored as weak pointers, which means that
clients in different areas of the same world can share the same World
instance.
Also see PartialWorld.
Note that this is distinct from Bevy’s World type, which contains all of
the data for every client. When referring to the Bevy World within Azalea,
the term “ECS” is generally used instead.
Fields§
§chunks: ChunkStorage§entities_by_chunk: HashMap<ChunkPos, HashSet<Entity>>An index of all the entities we know are in the chunks of the world
entity_by_id: IntMap<MinecraftEntityId, Entity>An index of Minecraft entity IDs to Azalea ECS entities.
You should avoid using this (particularly if you’re using swarms) and
instead use azalea_entity::EntityIdIndex, since some servers may
give different entity IDs for the same entities to different
players.
registries: RegistryHolderImplementations§
Source§impl World
impl World
Sourcepub fn find_block(
&self,
nearest_to: impl Into<BlockPos>,
block_states: &BlockStates,
) -> Option<BlockPos>
pub fn find_block( &self, nearest_to: impl Into<BlockPos>, block_states: &BlockStates, ) -> Option<BlockPos>
Find the coordinates of a block in the world.
Note that this is sorted by x+y+z and not x^2+y^2+z^2 for
performance purposes.
let pos = world.find_block(position, &BlockKind::Chest.into());Sourcepub fn find_blocks<'a>(
&'a self,
nearest_to: impl Into<BlockPos>,
block_states: &'a BlockStates,
) -> FindBlocks<'a> ⓘ
pub fn find_blocks<'a>( &'a self, nearest_to: impl Into<BlockPos>, block_states: &'a BlockStates, ) -> FindBlocks<'a> ⓘ
Find all the coordinates of a block in the world.
This returns an iterator that yields the BlockPoss of blocks that
are in the given block states.
Note that this is sorted by x+y+z and not x^2+y^2+z^2 for
performance purposes.
Source§impl World
impl World
Sourcepub fn get_block_state(&self, pos: BlockPos) -> Option<BlockState>
pub fn get_block_state(&self, pos: BlockPos) -> Option<BlockState>
Get the block at the given position, or None if it’s outside of the
world that we have loaded.
Sourcepub fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState>
pub fn get_fluid_state(&self, pos: BlockPos) -> Option<FluidState>
Similar to Self::get_block_state, but returns data about the fluid
at the position, including for waterlogged blocks.
Sourcepub fn get_biome(&self, pos: BlockPos) -> Option<Biome>
pub fn get_biome(&self, pos: BlockPos) -> Option<Biome>
Get the biome at the given position.
You can then use Client::with_resolved_registry to get the name and
data from the biome.
Note that biomes are internally stored as 4x4x4 blocks, so if you’re writing code that searches for a specific biome it’ll probably be more efficient to avoid scanning every single block.
pub fn set_block_state( &self, pos: BlockPos, state: BlockState, ) -> Option<BlockState>
Trait Implementations§
Source§impl From<ChunkStorage> for World
impl From<ChunkStorage> for World
Source§fn from(chunks: ChunkStorage) -> Self
fn from(chunks: ChunkStorage) -> Self
Make an empty world from this ChunkStorage. This is meant to be a
convenience function for tests.
Auto Trait Implementations§
impl Freeze for World
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl UnsafeUnpin for World
impl !UnwindSafe for World
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().