pub struct Instance {
pub chunks: ChunkStorage,
pub entities_by_chunk: HashMap<ChunkPos, HashSet<Entity>>,
pub entity_by_id: IntMap<MinecraftEntityId, Entity>,
pub registries: RegistryHolder,
}
Expand description
A world where the chunks are stored as weak pointers. This is used for shared worlds.
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: RegistryHolder
Implementations§
Source§impl Instance
impl Instance
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
optimization purposes.
client.world().read().find_block(client.position(), &azalea_registry::Block::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 BlockPos
s of blocks that
are in the given block states. It’s sorted by x+y+z
.
Source§impl Instance
impl Instance
pub fn get_block_state(&self, pos: &BlockPos) -> Option<BlockState>
pub fn get_fluid_state(&self, pos: &BlockPos) -> Option<FluidState>
pub fn set_block_state( &self, pos: &BlockPos, state: BlockState, ) -> Option<BlockState>
Trait Implementations§
Source§impl From<ChunkStorage> for Instance
impl From<ChunkStorage> for Instance
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 Instance
impl !RefUnwindSafe for Instance
impl Send for Instance
impl Sync for Instance
impl Unpin for Instance
impl !UnwindSafe for Instance
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.