diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-11-12 23:54:05 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-12 23:54:05 -0600 |
| commit | 6eee543a3367d38a6f0e9bffb457a2bd76a8f9cc (patch) | |
| tree | a5e493ccd7ec24293b8d866242c3836146517122 /azalea-world/src/lib.rs | |
| parent | fa57d03627aa20b1df44caed7cb025b6db1d9b53 (diff) | |
| download | azalea-drasl-6eee543a3367d38a6f0e9bffb457a2bd76a8f9cc.tar.xz | |
Pathfinder (#25)
Pathfinding is very much not done, but it works enough and I want to get this merged.
TODO: fast replanning, goals that aren't a single node, falling moves (it should be able to play the dropper), parkour moves
Diffstat (limited to 'azalea-world/src/lib.rs')
| -rwxr-xr-x[-rw-r--r--] | azalea-world/src/lib.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index 5fbb7b4d..30e09fe9 100644..100755 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -11,23 +11,23 @@ use azalea_buf::BufReadError; use azalea_core::{BlockPos, ChunkPos, PositionDelta8, Vec3}; pub use bit_storage::BitStorage; pub use chunk_storage::{Chunk, ChunkStorage}; -use entity::{EntityData, EntityMut, EntityRef}; +use entity::{Entity, EntityData}; pub use entity_storage::EntityStorage; +use parking_lot::Mutex; use std::{ io::Cursor, ops::{Index, IndexMut}, - sync::{Arc, Mutex}, + sync::Arc, }; use thiserror::Error; use uuid::Uuid; /// A dimension is a collection of chunks and entities. /// Minecraft calls these "Levels", Fabric calls them "Worlds", Minestom calls them "Instances". -/// Yeah. #[derive(Debug, Default)] pub struct Dimension { - chunk_storage: ChunkStorage, - entity_storage: EntityStorage, + pub chunk_storage: ChunkStorage, + pub entity_storage: EntityStorage, } #[derive(Error, Debug)] @@ -127,16 +127,16 @@ impl Dimension { self.entity_storage.get_mut_by_id(id) } - pub fn entity(&self, id: u32) -> Option<EntityRef> { + pub fn entity(&self, id: u32) -> Option<Entity<&Dimension>> { let entity_data = self.entity_storage.get_by_id(id)?; - Some(EntityRef::new(self, id, entity_data)) + let entity_ptr = unsafe { entity_data.as_const_ptr() }; + Some(Entity::new(self, id, entity_ptr)) } - pub fn entity_mut(&mut self, id: u32) -> Option<EntityMut> { + pub fn entity_mut(&mut self, id: u32) -> Option<Entity<'_, &mut Dimension>> { let entity_data = self.entity_storage.get_mut_by_id(id)?; - let entity_ptr = unsafe { entity_data.as_ptr() }; - Some(EntityMut::new(self, id, entity_ptr)) + Some(Entity::new(self, id, entity_ptr)) } pub fn entity_by_uuid(&self, uuid: &Uuid) -> Option<&EntityData> { |
