From d5fa5e32b37754b3b5c136e58821e48cd3b7c2ff Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Tue, 13 Jan 2026 10:51:30 -0600 Subject: Rename Instance to World (#304) --- azalea/src/pathfinder/simulation.rs | 56 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'azalea/src/pathfinder/simulation.rs') diff --git a/azalea/src/pathfinder/simulation.rs b/azalea/src/pathfinder/simulation.rs index ca5e4f36..94837f9e 100644 --- a/azalea/src/pathfinder/simulation.rs +++ b/azalea/src/pathfinder/simulation.rs @@ -13,8 +13,8 @@ use azalea_entity::{ Attributes, LookDirection, Physics, Position, dimensions::EntityDimensions, inventory::Inventory, }; -use azalea_registry::{builtin::EntityKind, identifier::Identifier}; -use azalea_world::{ChunkStorage, Instance, InstanceContainer, PartialInstance}; +use azalea_registry::builtin::EntityKind; +use azalea_world::{ChunkStorage, PartialWorld, World, WorldName, Worlds}; use bevy_app::App; use bevy_ecs::prelude::*; use parking_lot::RwLock; @@ -45,14 +45,14 @@ impl SimulatedPlayerBundle { } } -fn simulation_instance_name() -> Identifier { - Identifier::new("azalea:simulation") +fn simulation_world_name() -> WorldName { + WorldName::new("azalea:simulation") } -fn create_simulation_instance(chunks: ChunkStorage) -> (App, Arc>) { - let instance_name = simulation_instance_name(); +fn create_simulation_world(chunks: ChunkStorage) -> (App, Arc>) { + let world_name = simulation_world_name(); - let instance = Arc::new(RwLock::new(Instance { + let world = Arc::new(RwLock::new(World { chunks, ..Default::default() })); @@ -72,8 +72,8 @@ fn create_simulation_instance(chunks: ChunkStorage) -> (App, Arc (App, Arc>, + world: Arc>, player: &SimulatedPlayerBundle, ) -> impl Bundle { - let instance_name = simulation_instance_name(); + let world_name = simulation_world_name(); ( MinecraftEntityId(0), @@ -100,12 +100,12 @@ fn create_simulation_player_complete_bundle( Uuid::nil(), *player.position, EntityKind::Player, - instance_name, + world_name, ), - azalea_client::local_player::InstanceHolder { - // partial_instance is never actually used by the pathfinder so - partial_instance: Arc::new(RwLock::new(PartialInstance::default())), - instance: instance.clone(), + azalea_client::local_player::WorldHolder { + // the partial world is never actually used by the pathfinder, so we can leave it empty + partial: Arc::new(RwLock::new(PartialWorld::default())), + shared: world.clone(), }, Inventory::default(), LocalGameMode::from(GameMode::Survival), @@ -117,11 +117,11 @@ fn create_simulation_player_complete_bundle( } fn create_simulation_player( - ecs: &mut World, - instance: Arc>, + ecs: &mut bevy_ecs::world::World, + world: Arc>, player: SimulatedPlayerBundle, ) -> Entity { - let mut entity = ecs.spawn(create_simulation_player_complete_bundle(instance, &player)); + let mut entity = ecs.spawn(create_simulation_player_complete_bundle(world, &player)); entity.insert(player); entity.id() } @@ -130,17 +130,17 @@ fn create_simulation_player( pub struct Simulation { pub app: App, pub entity: Entity, - _instance: Arc>, + _world: Arc>, } impl Simulation { pub fn new(chunks: ChunkStorage, player: SimulatedPlayerBundle) -> Self { - let (mut app, instance) = create_simulation_instance(chunks); - let entity = create_simulation_player(app.world_mut(), instance.clone(), player); + let (mut app, world) = create_simulation_world(chunks); + let entity = create_simulation_player(app.world_mut(), world.clone(), player); Self { app, entity, - _instance: instance, + _world: world, } } @@ -168,12 +168,12 @@ impl Simulation { /// A set of simulations, useful for efficiently doing multiple simulations. pub struct SimulationSet { pub app: App, - instance: Arc>, + world: Arc>, } impl SimulationSet { pub fn new(chunks: ChunkStorage) -> Self { - let (app, instance) = create_simulation_instance(chunks); - Self { app, instance } + let (app, world) = create_simulation_world(chunks); + Self { app, world } } pub fn tick(&mut self) { self.app.update(); @@ -181,7 +181,7 @@ impl SimulationSet { } pub fn spawn(&mut self, player: SimulatedPlayerBundle) -> Entity { - create_simulation_player(self.app.world_mut(), self.instance.clone(), player) + create_simulation_player(self.app.world_mut(), self.world.clone(), player) } pub fn despawn(&mut self, entity: Entity) { self.app.world_mut().despawn(entity); -- cgit v1.2.3