diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2026-01-13 10:51:30 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-13 10:51:30 -0600 |
| commit | d5fa5e32b37754b3b5c136e58821e48cd3b7c2ff (patch) | |
| tree | ea04702f96ad170fb1d90e5ed2dc875ae8166495 /azalea-client/src/plugins | |
| parent | efb36d5fc0fe56a98f5795c53dfa109887cd5aae (diff) | |
| download | azalea-drasl-d5fa5e32b37754b3b5c136e58821e48cd3b7c2ff.tar.xz | |
Rename Instance to World (#304)
Diffstat (limited to 'azalea-client/src/plugins')
| -rw-r--r-- | azalea-client/src/plugins/block_update.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/plugins/chunks.rs | 22 | ||||
| -rw-r--r-- | azalea-client/src/plugins/disconnect.rs | 6 | ||||
| -rw-r--r-- | azalea-client/src/plugins/interact/mod.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/interact/pick.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory/equipment_effects.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/plugins/inventory/mod.rs | 12 | ||||
| -rw-r--r-- | azalea-client/src/plugins/join.rs | 11 | ||||
| -rw-r--r-- | azalea-client/src/plugins/mining.rs | 42 | ||||
| -rw-r--r-- | azalea-client/src/plugins/movement.rs | 18 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/config/mod.rs | 10 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 17 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/mod.rs | 217 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/mod.rs | 2 | ||||
| -rw-r--r-- | azalea-client/src/plugins/tick_counter.rs | 8 | ||||
| -rw-r--r-- | azalea-client/src/plugins/tick_end.rs | 4 |
16 files changed, 203 insertions, 212 deletions
diff --git a/azalea-client/src/plugins/block_update.rs b/azalea-client/src/plugins/block_update.rs index 46e6b409..51dba728 100644 --- a/azalea-client/src/plugins/block_update.rs +++ b/azalea-client/src/plugins/block_update.rs @@ -5,7 +5,7 @@ use bevy_ecs::prelude::*; use crate::{ chunks::handle_receive_chunk_event, interact::BlockStatePredictionHandler, - local_player::InstanceHolder, + local_player::WorldHolder, }; pub struct BlockUpdatePlugin; @@ -34,12 +34,12 @@ pub struct QueuedServerBlockUpdates { pub fn handle_block_update_event( mut query: Query<( &mut QueuedServerBlockUpdates, - &InstanceHolder, + &WorldHolder, &mut BlockStatePredictionHandler, )>, ) { - for (mut queued, instance_holder, mut prediction_handler) in query.iter_mut() { - let world = instance_holder.instance.read(); + for (mut queued, world_holder, mut prediction_handler) in query.iter_mut() { + let world = world_holder.shared.read(); for (pos, block_state) in queued.list.drain(..) { if !prediction_handler.update_known_server_state(pos, block_state) { world.chunks.set_block_state(pos, block_state); diff --git a/azalea-client/src/plugins/chunks.rs b/azalea-client/src/plugins/chunks.rs index d5014516..0937c2ef 100644 --- a/azalea-client/src/plugins/chunks.rs +++ b/azalea-client/src/plugins/chunks.rs @@ -17,7 +17,7 @@ use bevy_ecs::prelude::*; use tracing::{error, trace}; use crate::{ - inventory::InventorySystems, local_player::InstanceHolder, packet::game::SendGamePacketEvent, + inventory::InventorySystems, local_player::WorldHolder, packet::game::SendGamePacketEvent, respawn::perform_respawn, }; @@ -66,42 +66,40 @@ pub struct ChunkBatchFinishedEvent { pub fn handle_receive_chunk_event( mut events: MessageReader<ReceiveChunkEvent>, - mut query: Query<&InstanceHolder>, + mut query: Query<&WorldHolder>, ) { for event in events.read() { let pos = ChunkPos::new(event.packet.x, event.packet.z); let local_player = query.get_mut(event.entity).unwrap(); - let mut instance = local_player.instance.write(); - let mut partial_instance = local_player.partial_instance.write(); + let mut world = local_player.shared.write(); + let mut partial_world = local_player.partial.write(); // OPTIMIZATION: if we already know about the chunk from the shared world (and // not ourselves), then we don't need to parse it again. This is only used when // we have a shared world, since we check that the chunk isn't currently owned // by this client. - let shared_chunk = instance.chunks.get(&pos); - let this_client_has_chunk = partial_instance.chunks.limited_get(&pos).is_some(); + let shared_chunk = world.chunks.get(&pos); + let this_client_has_chunk = partial_world.chunks.limited_get(&pos).is_some(); if !this_client_has_chunk && let Some(shared_chunk) = shared_chunk { trace!("Skipping parsing chunk {pos:?} because we already know about it"); - partial_instance - .chunks - .limited_set(&pos, Some(shared_chunk)); + partial_world.chunks.limited_set(&pos, Some(shared_chunk)); continue; } let heightmaps = &event.packet.chunk_data.heightmaps; - if let Err(e) = partial_instance.chunks.replace_with_packet_data( + if let Err(e) = partial_world.chunks.replace_with_packet_data( &pos, &mut Cursor::new(&event.packet.chunk_data.data), heightmaps, - &mut instance.chunks, + &mut world.chunks, ) { error!( "Couldn't set chunk data: {e}. World height: {}", - instance.chunks.height + world.chunks.height ); } } diff --git a/azalea-client/src/plugins/disconnect.rs b/azalea-client/src/plugins/disconnect.rs index 081c174e..be98383b 100644 --- a/azalea-client/src/plugins/disconnect.rs +++ b/azalea-client/src/plugins/disconnect.rs @@ -1,10 +1,10 @@ //! Disconnect a client from the server. use azalea_chat::FormattedText; +use azalea_core::entity_id::MinecraftEntityId; use azalea_entity::{ EntityBundle, HasClientLoaded, InLoadedChunk, LocalEntity, metadata::PlayerMetadataBundle, }; -use azalea_core::entity_id::MinecraftEntityId; use bevy_app::{App, Plugin, PostUpdate}; use bevy_ecs::prelude::*; use derive_more::Deref; @@ -14,7 +14,7 @@ use super::login::IsAuthenticated; #[cfg(feature = "online-mode")] use crate::chat_signing; use crate::{ - client::JoinedClientBundle, connection::RawConnection, local_player::InstanceHolder, + client::JoinedClientBundle, connection::RawConnection, local_player::WorldHolder, tick_counter::TicksConnected, }; @@ -63,7 +63,7 @@ pub struct RemoveOnDisconnectBundle { pub entity: EntityBundle, pub minecraft_entity_id: MinecraftEntityId, - pub instance_holder: InstanceHolder, + pub world_holder: WorldHolder, pub player_metadata: PlayerMetadataBundle, pub in_loaded_chunk: InLoadedChunk, //// This makes it close the TCP connection. diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs index d8f8b8b4..04986de7 100644 --- a/azalea-client/src/plugins/interact/mod.rs +++ b/azalea-client/src/plugins/interact/mod.rs @@ -30,7 +30,7 @@ use azalea_protocol::packets::game::{ s_swing::ServerboundSwing, s_use_item_on::ServerboundUseItemOn, }; -use azalea_world::Instance; +use azalea_world::World; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use tracing::warn; @@ -140,7 +140,7 @@ impl BlockStatePredictionHandler { } } - pub fn end_prediction_up_to(&mut self, seq: u32, world: &Instance) { + pub fn end_prediction_up_to(&mut self, seq: u32, world: &World) { let mut to_remove = Vec::new(); for (pos, state) in &self.server_state { if state.seq > seq { @@ -377,10 +377,10 @@ pub fn handle_entity_interact( /// /// If this is false, then we can interact with the block. /// -/// Passing the inventory, block position, and instance is necessary for the -/// adventure mode check. +/// The world, block position, and inventory are used for the adventure mode +/// check. pub fn check_is_interaction_restricted( - instance: &Instance, + world: &World, block_pos: BlockPos, game_mode: &GameMode, inventory: &Inventory, @@ -393,7 +393,7 @@ pub fn check_is_interaction_restricted( let held_item = inventory.held_item(); match &held_item { ItemStack::Present(item) => { - let block = instance.chunks.get_block_state(block_pos); + let block = world.chunks.get_block_state(block_pos); let Some(block) = block else { // block isn't loaded so just say that it is restricted return true; diff --git a/azalea-client/src/plugins/interact/pick.rs b/azalea-client/src/plugins/interact/pick.rs index 8ffe47e8..1fed584a 100644 --- a/azalea-client/src/plugins/interact/pick.rs +++ b/azalea-client/src/plugins/interact/pick.rs @@ -17,7 +17,7 @@ use azalea_physics::{ clip::{BlockShapeType, ClipContext, FluidPickType}, collision::entity_collisions::{AabbQuery, get_entities}, }; -use azalea_world::{Instance, InstanceContainer, InstanceName}; +use azalea_world::{World, WorldName, Worlds}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; @@ -37,13 +37,13 @@ pub fn update_hit_result_component( &Position, &EntityDimensions, &LookDirection, - &InstanceName, + &WorldName, &Physics, &Attributes, ), With<LocalEntity>, >, - instance_container: Res<InstanceContainer>, + worlds: Res<Worlds>, aabb_query: AabbQuery, pickable_query: MaybePickableEntityQuery, ) { @@ -63,7 +63,7 @@ pub fn update_hit_result_component( let eye_position = position.up(dimensions.eye_height.into()); - let Some(world_lock) = instance_container.get(world_name) else { + let Some(world_lock) = worlds.get(world_name) else { continue; }; let world = world_lock.read(); @@ -117,7 +117,7 @@ pub struct PickOpts<'world, 'state, 'a, 'b, 'c> { look_direction: LookDirection, eye_position: Vec3, aabb: &'a Aabb, - world: &'a Instance, + world: &'a World, entity_pick_range: f64, block_pick_range: f64, aabb_query: &'a AabbQuery<'world, 'state, 'b>, @@ -246,7 +246,7 @@ struct PickEntityOpts<'world, 'state, 'a, 'b> { source_entity: Entity, eye_position: Vec3, end_position: Vec3, - world: &'a azalea_world::Instance, + world: &'a azalea_world::World, pick_range_squared: f64, predicate: &'a dyn Fn(Entity) -> bool, aabb: &'a Aabb, diff --git a/azalea-client/src/plugins/inventory/equipment_effects.rs b/azalea-client/src/plugins/inventory/equipment_effects.rs index 47220bf2..d5897f48 100644 --- a/azalea-client/src/plugins/inventory/equipment_effects.rs +++ b/azalea-client/src/plugins/inventory/equipment_effects.rs @@ -19,7 +19,7 @@ use bevy_ecs::{ }; use tracing::{debug, error, warn}; -use crate::local_player::InstanceHolder; +use crate::local_player::WorldHolder; /// A component that contains the equipment slots that we had last tick. /// @@ -91,9 +91,9 @@ pub struct EquipmentChange { pub fn handle_equipment_changes( equipment_changes: On<EquipmentChangesEvent>, - mut query: Query<(&InstanceHolder, &mut LastEquipmentItems, &mut Attributes)>, + mut query: Query<(&WorldHolder, &mut LastEquipmentItems, &mut Attributes)>, ) { - let Ok((instance_holder, mut last_equipment_items, mut attributes)) = + let Ok((world_holder, mut last_equipment_items, mut attributes)) = query.get_mut(equipment_changes.entity) else { error!( @@ -112,7 +112,7 @@ pub fn handle_equipment_changes( // stopLocationBasedEffects for (attribute, modifier) in - collect_attribute_modifiers_from_item(slot, &change.old, instance_holder) + collect_attribute_modifiers_from_item(slot, &change.old, world_holder) { if let Some(attribute) = attributes.get_mut(attribute) { attribute.remove(&modifier.id); @@ -126,7 +126,7 @@ pub fn handle_equipment_changes( // see ItemStack.forEachModifier in vanilla for (attribute, modifier) in - collect_attribute_modifiers_from_item(slot, &change.new, instance_holder) + collect_attribute_modifiers_from_item(slot, &change.new, world_holder) { if let Some(attribute) = attributes.get_mut(attribute) { attribute.remove(&modifier.id); @@ -144,7 +144,7 @@ pub fn handle_equipment_changes( fn collect_attribute_modifiers_from_item( slot: EquipmentSlot, item: &ItemStack, - instance_holder: &InstanceHolder, + world_holder: &WorldHolder, ) -> Vec<(azalea_registry::builtin::Attribute, AttributeModifier)> { let mut modifiers = Vec::new(); @@ -161,7 +161,7 @@ fn collect_attribute_modifiers_from_item( .get_component::<components::Enchantments>() .unwrap_or_default(); if !enchants.levels.is_empty() { - let registry_holder = &instance_holder.instance.read().registries; + let registry_holder = &world_holder.shared.read().registries; for (enchant, &level) in &enchants.levels { let Some((_enchant_id, enchant_definition)) = enchant.resolve(registry_holder) else { warn!( diff --git a/azalea-client/src/plugins/inventory/mod.rs b/azalea-client/src/plugins/inventory/mod.rs index 740decb1..908ebe66 100644 --- a/azalea-client/src/plugins/inventory/mod.rs +++ b/azalea-client/src/plugins/inventory/mod.rs @@ -11,7 +11,7 @@ use azalea_protocol::packets::game::{ s_set_carried_item::ServerboundSetCarriedItem, }; use azalea_registry::builtin::MenuKind; -use azalea_world::{InstanceContainer, InstanceName}; +use azalea_world::{WorldName, Worlds}; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; use indexmap::IndexMap; @@ -167,10 +167,10 @@ pub struct ContainerClickEvent { pub fn handle_container_click_event( container_click: On<ContainerClickEvent>, mut commands: Commands, - mut query: Query<(Entity, &mut Inv, Option<&PlayerAbilities>, &InstanceName)>, - instance_container: Res<InstanceContainer>, + mut query: Query<(Entity, &mut Inv, Option<&PlayerAbilities>, &WorldName)>, + worlds: Res<Worlds>, ) { - let (entity, mut inventory, player_abilities, instance_name) = + let (entity, mut inventory, player_abilities, world_name) = query.get_mut(container_click.entity).unwrap(); if inventory.id != container_click.window_id { error!( @@ -180,7 +180,7 @@ pub fn handle_container_click_event( return; } - let Some(instance) = instance_container.get(instance_name) else { + let Some(world) = worlds.get(world_name) else { return; }; @@ -191,7 +191,7 @@ pub fn handle_container_click_event( ); let new_slots = inventory.menu().slots(); - let registry_holder = &instance.read().registries; + let registry_holder = &world.read().registries; // see which slots changed after clicking and put them in the map the server // uses this to check if we desynced diff --git a/azalea-client/src/plugins/join.rs b/azalea-client/src/plugins/join.rs index c254bc26..a6c9c586 100644 --- a/azalea-client/src/plugins/join.rs +++ b/azalea-client/src/plugins/join.rs @@ -11,7 +11,7 @@ use azalea_protocol::{ login::{ClientboundLoginPacket, ServerboundHello, ServerboundLoginPacket}, }, }; -use azalea_world::Instance; +use azalea_world::World; use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_tasks::{IoTaskPool, Task, futures_lite::future}; @@ -23,6 +23,7 @@ use crate::{ LocalPlayerBundle, account::Account, connection::RawConnection, + local_player::WorldHolder, packet::login::{InLoginState, SendLoginPacketEvent}, }; @@ -204,12 +205,12 @@ pub fn poll_create_connection_task( let (read_conn, write_conn) = conn.into_split(); let (read_conn, write_conn) = (read_conn.raw, write_conn.raw); - let instance = Instance::default(); - let instance_holder = crate::local_player::InstanceHolder::new( + let world = World::default(); + let world_holder = WorldHolder::new( entity, // default to an empty world, it'll be set correctly later when we // get the login packet - Arc::new(RwLock::new(instance)), + Arc::new(RwLock::new(world)), ); entity_mut.insert(( @@ -220,7 +221,7 @@ pub fn poll_create_connection_task( write_conn, ConnectionProtocol::Login, ), - instance_holder, + world_holder, metadata: azalea_entity::metadata::PlayerMetadataBundle::default(), }, InLoginState, diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index e9dcbe59..35b01a6a 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -8,7 +8,7 @@ use azalea_inventory::ItemStack; use azalea_physics::{PhysicsSystems, collision::BlockWithShape}; use azalea_protocol::packets::game::s_player_action::{self, ServerboundPlayerAction}; use azalea_registry::builtin::{BlockKind, ItemKind}; -use azalea_world::{InstanceContainer, InstanceName}; +use azalea_world::{Worlds, WorldName}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use derive_more::{Deref, DerefMut}; @@ -20,7 +20,7 @@ use crate::{ check_is_interaction_restricted, pick::HitResultComponent, }, inventory::InventorySystems, - local_player::{InstanceHolder, LocalGameMode, PermissionLevel}, + local_player::{LocalGameMode, PermissionLevel, WorldHolder}, movement::MoveEventsSystems, packet::game::SendGamePacketEvent, }; @@ -219,7 +219,7 @@ pub fn handle_mining_queued( query: Query<( Entity, &MiningQueued, - &InstanceHolder, + &WorldHolder, &LocalGameMode, &Inventory, &ActiveEffects, @@ -240,7 +240,7 @@ pub fn handle_mining_queued( for ( entity, mining_queued, - instance_holder, + world_holder, game_mode, inventory, active_effects, @@ -261,9 +261,9 @@ pub fn handle_mining_queued( trace!("handle_mining_queued {mining_queued:?}"); commands.entity(entity).remove::<MiningQueued>(); - let instance = instance_holder.instance.read(); + let world = world_holder.shared.read(); if check_is_interaction_restricted( - &instance, + &world, mining_queued.position, &game_mode.current, inventory, @@ -320,7 +320,7 @@ pub fn handle_mining_queued( )); } - let target_block_state = instance + let target_block_state = world .get_block_state(mining_queued.position) .unwrap_or_default(); @@ -472,7 +472,7 @@ pub struct FinishMiningBlockEvent { pub fn handle_finish_mining_block_observer( finish_mining_block: On<FinishMiningBlockEvent>, mut query: Query<( - &InstanceName, + &WorldName, &LocalGameMode, &Inventory, &PlayerAbilities, @@ -480,12 +480,12 @@ pub fn handle_finish_mining_block_observer( &Position, &mut BlockStatePredictionHandler, )>, - instances: Res<InstanceContainer>, + worlds: Res<Worlds>, ) { let event = finish_mining_block.event(); let ( - instance_name, + world_name, game_mode, inventory, abilities, @@ -493,9 +493,9 @@ pub fn handle_finish_mining_block_observer( player_pos, mut prediction_handler, ) = query.get_mut(finish_mining_block.entity).unwrap(); - let instance_lock = instances.get(instance_name).unwrap(); - let instance = instance_lock.read(); - if check_is_interaction_restricted(&instance, event.position, &game_mode.current, inventory) { + let world_lock = worlds.get(world_name).unwrap(); + let world = world_lock.read(); + if check_is_interaction_restricted(&world, event.position, &game_mode.current, inventory) { return; } @@ -508,7 +508,7 @@ pub fn handle_finish_mining_block_observer( } } - let Some(block_state) = instance.get_block_state(event.position) else { + let Some(block_state) = world.get_block_state(event.position) else { return; }; @@ -528,7 +528,7 @@ pub fn handle_finish_mining_block_observer( // when we break a waterlogged block we want to keep the water there let fluid_state = FluidState::from(block_state); let block_state_for_fluid = BlockState::from(fluid_state); - let old_state = instance + let old_state = world .set_block_state(event.position, block_state_for_fluid) .unwrap_or_default(); prediction_handler.retain_known_server_state(event.position, old_state, **player_pos); @@ -581,7 +581,7 @@ pub fn decrement_mine_delay(mut query: Query<&mut MineDelay>) { pub fn continue_mining_block( mut query: Query<( Entity, - &InstanceName, + &WorldName, &LocalGameMode, &Inventory, &MineBlockPos, @@ -598,11 +598,11 @@ pub fn continue_mining_block( )>, mut commands: Commands, mut mine_block_progress_events: MessageWriter<MineBlockProgressEvent>, - instances: Res<InstanceContainer>, + worlds: Res<Worlds>, ) { for ( entity, - instance_name, + world_name, game_mode, inventory, current_mining_pos, @@ -644,9 +644,9 @@ pub fn continue_mining_block( ) { trace!("continue mining block at {:?}", mining.pos); - let instance_lock = instances.get(instance_name).unwrap(); - let instance = instance_lock.read(); - let target_block_state = instance.get_block_state(mining.pos).unwrap_or_default(); + let world_lock = worlds.get(world_name).unwrap(); + let world = world_lock.read(); + let target_block_state = world.get_block_state(mining.pos).unwrap_or_default(); trace!("target_block_state: {target_block_state:?}"); diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index 40cc108e..94b996a0 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -31,12 +31,12 @@ use azalea_protocol::{ }, }; use azalea_registry::builtin::EntityKind; -use azalea_world::Instance; +use azalea_world::World; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; use crate::{ - local_player::{Hunger, InstanceHolder, LocalGameMode}, + local_player::{Hunger, LocalGameMode, WorldHolder}, packet::game::SendGamePacketEvent, }; @@ -296,7 +296,7 @@ pub fn local_player_ai_step( &PlayerAbilities, &metadata::Swimming, &metadata::SleepingPos, - &InstanceHolder, + &WorldHolder, &Position, Option<&Hunger>, Option<&LastSentInput>, @@ -316,7 +316,7 @@ pub fn local_player_ai_step( abilities, swimming, sleeping_pos, - instance_holder, + world_holder, position, hunger, last_sent_input, @@ -333,7 +333,7 @@ pub fn local_player_ai_step( let is_passenger = false; let is_sleeping = sleeping_pos.is_some(); - let world = instance_holder.instance.read(); + let world = world_holder.shared.read(); let ctx = CanPlayerFitCtx { world: &world, entity, @@ -587,16 +587,16 @@ pub fn update_pose( &Physics, &PhysicsState, &LocalGameMode, - &InstanceHolder, + &WorldHolder, &Position, )>, aabb_query: AabbQuery, collidable_entity_query: CollidableEntityQuery, ) { - for (entity, mut pose, physics, physics_state, game_mode, instance_holder, position) in + for (entity, mut pose, physics, physics_state, game_mode, world_holder, position) in query.iter_mut() { - let world = instance_holder.instance.read(); + let world = world_holder.shared.read(); let world = &*world; let ctx = CanPlayerFitCtx { world, @@ -642,7 +642,7 @@ pub fn update_pose( } struct CanPlayerFitCtx<'world, 'state, 'a, 'b> { - world: &'a Instance, + world: &'a World, entity: Entity, position: Position, aabb_query: &'a AabbQuery<'world, 'state, 'b>, diff --git a/azalea-client/src/plugins/packet/config/mod.rs b/azalea-client/src/plugins/packet/config/mod.rs index 27dae837..f59b8c23 100644 --- a/azalea-client/src/plugins/packet/config/mod.rs +++ b/azalea-client/src/plugins/packet/config/mod.rs @@ -17,7 +17,7 @@ use crate::{ connection::RawConnection, cookies::{RequestCookieEvent, StoreCookieEvent}, disconnect::DisconnectEvent, - local_player::InstanceHolder, + local_player::WorldHolder, packet::game::{KeepAliveEvent, ResourcePackEvent}, }; @@ -69,12 +69,12 @@ pub struct ConfigPacketHandler<'a> { } impl ConfigPacketHandler<'_> { pub fn registry_data(&mut self, p: &ClientboundRegistryData) { - as_system::<Query<&InstanceHolder>>(self.ecs, |mut query| { - let instance_holder = query.get_mut(self.player).unwrap(); - let mut instance = instance_holder.instance.write(); + as_system::<Query<&WorldHolder>>(self.ecs, |mut query| { + let world_holder = query.get_mut(self.player).unwrap(); + let mut world = world_holder.shared.write(); // add the new registry data - instance + world .registries .append(p.registry_id.clone(), p.entries.clone()); }); diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index 535bd519..bc070ec8 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -5,8 +5,7 @@ use azalea_protocol::packets::{ Packet, game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket}, }; -use azalea_registry::identifier::Identifier; -use azalea_world::Instance; +use azalea_world::{World, WorldName}; use bevy_ecs::prelude::*; use parking_lot::RwLock; use tracing::{error, trace}; @@ -138,16 +137,18 @@ pub struct ResourcePackEvent { pub prompt: Option<FormattedText>, } -/// An instance (aka world, dimension) was loaded by a client. +/// A world instance (aka dimension) was loaded by a client. /// -/// Since the instance is given to you as a weak reference, it won't be able to -/// be `upgrade`d if all local players leave it. +/// Since the world is given to you as a weak reference, it won't be able to be +/// `upgrade`d if all local players unload it. #[derive(Clone, Debug, Message)] -pub struct InstanceLoadedEvent { +pub struct WorldLoadedEvent { pub entity: Entity, - pub name: Identifier, - pub instance: Weak<RwLock<Instance>>, + pub name: WorldName, + pub world: Weak<RwLock<World>>, } +#[deprecated = "renamed to `WorldLoadedEvent`."] +pub type InstanceLoadedEvent = WorldLoadedEvent; /// A Bevy trigger that's sent when our client receives a [`ClientboundPing`] /// packet in the game state. diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index f93a02ea..6489c899 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -19,7 +19,7 @@ use azalea_protocol::{ packets::{ConnectionProtocol, game::*}, }; use azalea_registry::builtin::EntityKind; -use azalea_world::{InstanceContainer, InstanceName, PartialInstance}; +use azalea_world::{PartialWorld, WorldName, Worlds}; use bevy_ecs::{prelude::*, system::SystemState}; pub use events::*; use tracing::{debug, error, trace, warn}; @@ -34,7 +34,7 @@ use crate::{ disconnect::DisconnectEvent, interact::BlockStatePredictionHandler, inventory::{ClientsideCloseContainerEvent, MenuOpenedEvent, SetContainerContentEvent}, - local_player::{Hunger, InstanceHolder, LocalGameMode, TabList}, + local_player::{Hunger, LocalGameMode, TabList, WorldHolder}, movement::{KnockbackData, KnockbackEvent}, packet::{as_system, declare_packet_handlers}, player::{GameProfileComponent, PlayerInfo}, @@ -207,15 +207,15 @@ impl GamePacketHandler<'_> { ( &GameProfileComponent, &ClientInformation, - Option<&mut InstanceName>, + Option<&mut WorldName>, Option<&mut LoadedBy>, &mut EntityIdIndex, - &mut InstanceHolder, + &mut WorldHolder, ), With<LocalEntity>, >, - MessageWriter<InstanceLoadedEvent>, - ResMut<InstanceContainer>, + MessageWriter<WorldLoadedEvent>, + ResMut<Worlds>, ResMut<EntityUuidIndex>, Query<&mut LoadedBy, Without<LocalEntity>>, )>( @@ -223,33 +223,31 @@ impl GamePacketHandler<'_> { |( mut commands, mut query, - mut instance_loaded_events, - mut instance_container, + mut world_loaded_events, + mut worlds, mut entity_uuid_index, mut loaded_by_query, )| { let ( game_profile, client_information, - instance_name, + world_name, loaded_by, mut entity_id_index, - mut instance_holder, + mut world_holder, ) = query.get_mut(self.player).unwrap(); - let new_instance_name = p.common.dimension.clone(); + let new_world_name = WorldName(p.common.dimension.clone()); - if let Some(mut instance_name) = instance_name { - **instance_name = new_instance_name.clone(); + if let Some(mut world_name) = world_name { + *world_name = new_world_name.clone(); } else { - commands - .entity(self.player) - .insert(InstanceName(new_instance_name.clone())); + commands.entity(self.player).insert(new_world_name.clone()); } - let weak_instance; + let weak_world; { - let client_registries = &instance_holder.instance.read().registries; + let client_registries = &world_holder.shared.read().registries; let Some((_dimension_type, dimension_data)) = p.common.dimension_type(client_registries) @@ -257,46 +255,44 @@ impl GamePacketHandler<'_> { return; }; - // add this world to the instance_container (or don't if it's already - // there) - weak_instance = instance_container.get_or_insert( - new_instance_name.clone(), + // add this world to the `worlds` (or don't, if it's already there) + weak_world = worlds.get_or_insert( + new_world_name.clone(), dimension_data.height, dimension_data.min_y, client_registries, ); - instance_loaded_events.write(InstanceLoadedEvent { + world_loaded_events.write(WorldLoadedEvent { entity: self.player, - name: new_instance_name.clone(), - instance: Arc::downgrade(&weak_instance), + name: new_world_name.clone(), + world: Arc::downgrade(&weak_world), }); } - // set the partial_world to an empty world - // (when we add chunks or entities those will be in the - // instance_container) + // set the partial world to an empty world (when we add chunks or entities those + // will be in the `worlds`) - *instance_holder.partial_instance.write() = PartialInstance::new( + *world_holder.partial.write() = PartialWorld::new( azalea_world::chunk_storage::calculate_chunk_storage_range( client_information.view_distance.into(), ), - // this argument makes it so other clients don't update this player entity - // in a shared instance + // this argument makes it so other clients don't update this player entity in a + // shared world Some(self.player), ); { - let client_registries = instance_holder.instance.read().registries.clone(); - let shared_registries = &mut weak_instance.write().registries; - // add the registries from this instance to the weak instance + let client_registries = world_holder.shared.read().registries.clone(); + let shared_registries = &mut weak_world.write().registries; + // add the registries from this world to the weak world shared_registries.extend(client_registries); } - instance_holder.instance = weak_instance; + world_holder.shared = weak_world; let entity_bundle = EntityBundle::new( game_profile.uuid, Vec3::ZERO, EntityKind::Player, - new_instance_name, + new_world_name, ); let entity_id = p.player_id; // insert our components into the ecs :) @@ -316,7 +312,7 @@ impl GamePacketHandler<'_> { Some(game_profile.uuid), &mut entity_id_index, &mut entity_uuid_index, - &mut instance_holder.instance.write(), + &mut world_holder.shared.write(), ); // every entity is now unloaded by this player @@ -532,9 +528,9 @@ impl GamePacketHandler<'_> { pub fn set_chunk_cache_center(&mut self, p: &ClientboundSetChunkCacheCenter) { debug!("Got chunk cache center packet {p:?}"); - as_system::<Query<&InstanceHolder>>(self.ecs, |mut query| { - let instance_holder = query.get_mut(self.player).unwrap(); - let mut partial_world = instance_holder.partial_instance.write(); + as_system::<Query<&WorldHolder>>(self.ecs, |mut query| { + let world_holder = query.get_mut(self.player).unwrap(); + let mut partial_world = world_holder.partial.write(); partial_world .chunks @@ -564,10 +560,10 @@ impl GamePacketHandler<'_> { as_system::<( Commands, - Query<(&mut EntityIdIndex, Option<&InstanceName>, Option<&TabList>)>, + Query<(&mut EntityIdIndex, Option<&WorldName>, Option<&TabList>)>, Query<&mut LoadedBy>, Query<Entity>, - Res<InstanceContainer>, + Res<Worlds>, ResMut<EntityUuidIndex>, )>( self.ecs, @@ -576,22 +572,22 @@ impl GamePacketHandler<'_> { mut query, mut loaded_by_query, entity_query, - instance_container, + worlds, mut entity_uuid_index, )| { - let (mut entity_id_index, instance_name, tab_list) = + let (mut entity_id_index, world_name, tab_list) = query.get_mut(self.player).unwrap(); let entity_id = p.id; - let Some(instance_name) = instance_name else { + let Some(world_name) = world_name else { warn!("got add player packet but we haven't gotten a login packet yet"); return; }; // check if the entity already exists, and if it does then only add to LoadedBy - let instance = instance_container.get(instance_name).unwrap(); - if let Some(&ecs_entity) = instance.read().entity_by_id.get(&entity_id) { + let world = worlds.get(world_name).unwrap(); + if let Some(&ecs_entity) = world.read().entity_by_id.get(&entity_id) { // entity already exists let Ok(mut loaded_by) = loaded_by_query.get_mut(ecs_entity) else { // LoadedBy for this entity isn't in the ecs! figure out what went wrong @@ -621,7 +617,7 @@ impl GamePacketHandler<'_> { // entity doesn't exist in the global index! - let bundle = p.as_entity_bundle((**instance_name).clone()); + let bundle = p.as_entity_bundle(world_name.to_owned()); let mut spawned = commands.spawn((entity_id, LoadedBy(HashSet::from([self.player])), bundle)); let ecs_entity: Entity = spawned.id(); @@ -636,7 +632,7 @@ impl GamePacketHandler<'_> { Some(p.uuid), &mut entity_id_index, &mut entity_uuid_index, - &mut instance.write(), + &mut world.write(), ); // add the GameProfileComponent if the uuid is in the tab list @@ -659,12 +655,12 @@ impl GamePacketHandler<'_> { pub fn set_entity_data(&mut self, p: &ClientboundSetEntityData) { as_system::<( Commands, - Query<(&EntityIdIndex, &InstanceHolder)>, + Query<(&EntityIdIndex, &WorldHolder)>, // this is a separate query since it's applied on the entity id that's being updated // instead of the player that received the packet Query<&EntityKindComponent>, )>(self.ecs, |(mut commands, query, entity_kind_query)| { - let (entity_id_index, instance_holder) = query.get(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); let entity = entity_id_index.get_by_minecraft_entity(p.id); @@ -693,7 +689,7 @@ impl GamePacketHandler<'_> { // we use RelativeEntityUpdate because it makes sure changes aren't made // multiple times commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity| { let entity_id = entity.id(); entity.world_scope(|world| { @@ -720,10 +716,10 @@ impl GamePacketHandler<'_> { // vanilla servers use this packet for knockback, but note that the Explode // packet is also sometimes used by servers for knockback - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, query)| { - let (entity_id_index, instance_holder) = query.get(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); let Some(entity) = entity_id_index.get_by_minecraft_entity(p.id) else { // note that this log (and some other ones like the one in RemoveEntities) @@ -742,7 +738,7 @@ impl GamePacketHandler<'_> { let data = KnockbackData::Set(p.delta.to_vec3()); commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity_mut| { entity_mut .world_scope(|world| world.trigger(KnockbackEvent { entity, data })); @@ -790,10 +786,10 @@ impl GamePacketHandler<'_> { pub fn teleport_entity(&mut self, p: &ClientboundTeleportEntity) { debug!("Got teleport entity packet {p:?}"); - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let (entity_id_index, instance_holder) = query.get_mut(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get_mut(self.player).unwrap(); let Some(entity) = entity_id_index.get_by_minecraft_entity(p.id) else { warn!("Got teleport entity packet for unknown entity id {}", p.id); @@ -804,7 +800,7 @@ impl GamePacketHandler<'_> { let change = p.change.clone(); commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity| { let entity_id = entity.id(); entity.world_scope(move |world| { @@ -835,10 +831,10 @@ impl GamePacketHandler<'_> { pub fn rotate_head(&mut self, _p: &ClientboundRotateHead) {} pub fn move_entity_pos(&mut self, p: &ClientboundMoveEntityPos) { - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let (entity_id_index, instance_holder) = query.get_mut(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get_mut(self.player).unwrap(); debug!("Got move entity pos packet {p:?}"); @@ -851,7 +847,7 @@ impl GamePacketHandler<'_> { let new_delta = p.delta.clone(); let new_on_ground = p.on_ground; commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity_mut| { let mut physics = entity_mut.get_mut::<Physics>().unwrap(); let new_pos = physics.vec_delta_codec.decode(&new_delta); @@ -874,10 +870,10 @@ impl GamePacketHandler<'_> { } pub fn move_entity_pos_rot(&mut self, p: &ClientboundMoveEntityPosRot) { - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let (entity_id_index, instance_holder) = query.get_mut(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get_mut(self.player).unwrap(); debug!("Got move entity pos rot packet {p:?}"); @@ -901,7 +897,7 @@ impl GamePacketHandler<'_> { let new_on_ground = p.on_ground; commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity_mut| { let mut physics = entity_mut.get_mut::<Physics>().unwrap(); let new_position = physics.vec_delta_codec.decode(&new_delta); @@ -924,10 +920,10 @@ impl GamePacketHandler<'_> { } pub fn move_entity_rot(&mut self, p: &ClientboundMoveEntityRot) { - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let (entity_id_index, instance_holder) = query.get_mut(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get_mut(self.player).unwrap(); let entity = entity_id_index.get_by_minecraft_entity(p.entity_id); if let Some(entity) = entity { @@ -938,7 +934,7 @@ impl GamePacketHandler<'_> { let new_on_ground = p.on_ground; commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity_mut| { let mut physics = entity_mut.get_mut::<Physics>().unwrap(); physics.set_on_ground(new_on_ground); @@ -1113,10 +1109,10 @@ impl GamePacketHandler<'_> { let mob_effect = p.mob_effect; let effect_data = &p.data; - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, query)| { - let (entity_id_index, instance_holder) = query.get(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { debug!( @@ -1126,10 +1122,10 @@ impl GamePacketHandler<'_> { return; }; - let partial_instance = instance_holder.partial_instance.clone(); + let partial_world = world_holder.partial.clone(); let effect_data = effect_data.clone(); commands.entity(entity).queue(RelativeEntityUpdate::new( - partial_instance, + partial_world, move |entity| { if let Some(mut active_effects) = entity.get_mut::<ActiveEffects>() { active_effects.insert(mob_effect, effect_data.clone()); @@ -1147,11 +1143,11 @@ impl GamePacketHandler<'_> { pub fn award_stats(&mut self, _p: &ClientboundAwardStats) {} pub fn block_changed_ack(&mut self, p: &ClientboundBlockChangedAck) { - as_system::<Query<(&InstanceHolder, &mut BlockStatePredictionHandler)>>( + as_system::<Query<(&WorldHolder, &mut BlockStatePredictionHandler)>>( self.ecs, |mut query| { let (local_player, mut prediction_handler) = query.get_mut(self.player).unwrap(); - let world = local_player.instance.read(); + let world = local_player.shared.read(); prediction_handler.end_prediction_up_to(p.seq, &world); }, ); @@ -1277,12 +1273,12 @@ impl GamePacketHandler<'_> { pub fn forget_level_chunk(&mut self, p: &ClientboundForgetLevelChunk) { debug!("Got forget level chunk packet {p:?}"); - as_system::<Query<&InstanceHolder>>(self.ecs, |mut query| { + as_system::<Query<&WorldHolder>>(self.ecs, |mut query| { let local_player = query.get_mut(self.player).unwrap(); - let mut partial_instance = local_player.partial_instance.write(); + let mut partial_world = local_player.partial.write(); - partial_instance.chunks.limited_set(&p.pos, None); + partial_world.chunks.limited_set(&p.pos, None); }); } @@ -1355,10 +1351,10 @@ impl GamePacketHandler<'_> { let mob_effect = p.effect; - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, query)| { - let (entity_id_index, instance_holder) = query.get(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get(self.player).unwrap(); let Some(entity) = entity_id_index.get_by_minecraft_entity(p.entity_id) else { debug!( @@ -1368,9 +1364,9 @@ impl GamePacketHandler<'_> { return; }; - let partial_instance = instance_holder.partial_instance.clone(); + let partial_world = world_holder.partial.clone(); commands.entity(entity).queue(RelativeEntityUpdate::new( - partial_instance, + partial_world, move |entity| { if let Some(mut active_effects) = entity.get_mut::<ActiveEffects>() { active_effects.remove(mob_effect); @@ -1405,71 +1401,67 @@ impl GamePacketHandler<'_> { Commands, Query< ( - &mut InstanceHolder, + &mut WorldHolder, &GameProfileComponent, &ClientInformation, - Option<&mut InstanceName>, + Option<&mut WorldName>, ), With<LocalEntity>, >, MessageWriter<_>, - ResMut<InstanceContainer>, + ResMut<Worlds>, Query<&mut LoadedBy, Without<LocalEntity>>, )>( self.ecs, - |(mut commands, mut query, mut events, mut instance_container, mut loaded_by_query)| { - let Ok((mut instance_holder, game_profile, client_information, instance_name)) = + |(mut commands, mut query, mut events, mut worlds, mut loaded_by_query)| { + let Ok((mut world_holder, game_profile, client_information, world_name)) = query.get_mut(self.player) else { warn!("Got respawn packet but player doesn't have the required components"); return; }; - let new_instance_name = p.common.dimension.clone(); + let new_world_name = WorldName(p.common.dimension.clone()); - if let Some(mut instance_name) = instance_name { - **instance_name = new_instance_name.clone(); + if let Some(mut world_name) = world_name { + *world_name = new_world_name.clone(); } else { - commands - .entity(self.player) - .insert(InstanceName(new_instance_name.clone())); + commands.entity(self.player).insert(new_world_name.clone()); } - let weak_instance; + let weak_world; { - let client_registries = &instance_holder.instance.read().registries; + let client_registries = &world_holder.shared.read().registries; let Some((_dimension_type, dimension_data)) = p.common.dimension_type(client_registries) else { return; }; - // add this world to the instance_container (or don't if it's already - // there) - weak_instance = instance_container.get_or_insert( - new_instance_name.clone(), + // add this world to the `worlds` (or don't if it's already there) + weak_world = worlds.get_or_insert( + new_world_name.clone(), dimension_data.height, dimension_data.min_y, client_registries, ); - events.write(InstanceLoadedEvent { + events.write(WorldLoadedEvent { entity: self.player, - name: new_instance_name.clone(), - instance: Arc::downgrade(&weak_instance), + name: new_world_name.clone(), + world: Arc::downgrade(&weak_world), }); } - // set the partial_world to an empty world - // (when we add chunks or entities those will be in the - // instance_container) + // set the partial world to an empty world (when we add chunks or entities, + // those will be in the `worlds`) - *instance_holder.partial_instance.write() = PartialInstance::new( + *world_holder.partial.write() = PartialWorld::new( azalea_world::chunk_storage::calculate_chunk_storage_range( client_information.view_distance.into(), ), Some(self.player), ); - instance_holder.instance = weak_instance; + world_holder.shared = weak_world; // every entity is now unloaded by this player for mut loaded_by in &mut loaded_by_query.iter_mut() { @@ -1481,7 +1473,7 @@ impl GamePacketHandler<'_> { game_profile.uuid, Vec3::ZERO, EntityKind::Player, - new_instance_name, + new_world_name, ); // update the local gamemode and metadata things commands.entity(self.player).insert(( @@ -1502,11 +1494,10 @@ impl GamePacketHandler<'_> { pub fn start_configuration(&mut self, _p: &ClientboundStartConfiguration) { debug!("Got start configuration packet"); - as_system::<(Commands, Query<(&mut RawConnection, &mut InstanceHolder)>)>( + as_system::<(Commands, Query<(&mut RawConnection, &mut WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let Some((mut raw_conn, mut instance_holder)) = query.get_mut(self.player).ok() - else { + let Some((mut raw_conn, mut world_holder)) = query.get_mut(self.player).ok() else { warn!("Got start configuration packet but player doesn't have a RawConnection"); return; }; @@ -1523,16 +1514,16 @@ impl GamePacketHandler<'_> { .remove::<crate::JoinedClientBundle>() .remove::<EntityBundle>(); - instance_holder.reset(); + world_holder.reset(); }, ); } pub fn entity_position_sync(&mut self, p: &ClientboundEntityPositionSync) { - as_system::<(Commands, Query<(&EntityIdIndex, &InstanceHolder)>)>( + as_system::<(Commands, Query<(&EntityIdIndex, &WorldHolder)>)>( self.ecs, |(mut commands, mut query)| { - let (entity_id_index, instance_holder) = query.get_mut(self.player).unwrap(); + let (entity_id_index, world_holder) = query.get_mut(self.player).unwrap(); let Some(entity) = entity_id_index.get_by_minecraft_entity(p.id) else { debug!("Got teleport entity packet for unknown entity id {}", p.id); @@ -1544,7 +1535,7 @@ impl GamePacketHandler<'_> { let new_look_direction = p.values.look_direction; commands.entity(entity).queue(RelativeEntityUpdate::new( - instance_holder.partial_instance.clone(), + world_holder.partial.clone(), move |entity_mut| { let is_local_entity = entity_mut.get::<LocalEntity>().is_some(); let mut physics = entity_mut.get_mut::<Physics>().unwrap(); diff --git a/azalea-client/src/plugins/packet/mod.rs b/azalea-client/src/plugins/packet/mod.rs index 9d842dc6..63a94ee0 100644 --- a/azalea-client/src/plugins/packet/mod.rs +++ b/azalea-client/src/plugins/packet/mod.rs @@ -45,7 +45,7 @@ impl Plugin for PacketPlugin { .add_message::<game::DeathEvent>() .add_message::<game::KeepAliveEvent>() .add_message::<game::ResourcePackEvent>() - .add_message::<game::InstanceLoadedEvent>() + .add_message::<game::WorldLoadedEvent>() .add_message::<login::ReceiveCustomQueryEvent>(); } } diff --git a/azalea-client/src/plugins/tick_counter.rs b/azalea-client/src/plugins/tick_counter.rs index e4b5f0a4..fba8bc1c 100644 --- a/azalea-client/src/plugins/tick_counter.rs +++ b/azalea-client/src/plugins/tick_counter.rs @@ -1,6 +1,6 @@ use azalea_core::tick::GameTick; use azalea_physics::PhysicsSystems; -use azalea_world::InstanceName; +use azalea_world::WorldName; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; @@ -27,9 +27,9 @@ impl Plugin for TickCounterPlugin { } } -/// Increment the [`TicksConnected`] component on every entity -/// that lives in an instance. -pub fn increment_counter(mut query: Query<&mut TicksConnected, With<InstanceName>>) { +/// Increment the [`TicksConnected`] component for every entity that's in any +/// world. +pub fn increment_counter(mut query: Query<&mut TicksConnected, With<WorldName>>) { for mut counter in &mut query { counter.0 += 1; } diff --git a/azalea-client/src/plugins/tick_end.rs b/azalea-client/src/plugins/tick_end.rs index 15cd2e59..6df46c78 100644 --- a/azalea-client/src/plugins/tick_end.rs +++ b/azalea-client/src/plugins/tick_end.rs @@ -4,7 +4,7 @@ use azalea_core::tick::GameTick; use azalea_entity::LocalEntity; use azalea_physics::PhysicsSystems; use azalea_protocol::packets::game::ServerboundClientTickEnd; -use azalea_world::InstanceName; +use azalea_world::WorldName; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; @@ -27,7 +27,7 @@ impl Plugin for TickEndPlugin { } pub fn game_tick_packet( - query: Query<Entity, (With<LocalEntity>, With<InstanceName>)>, + query: Query<Entity, (With<LocalEntity>, With<WorldName>)>, mut commands: Commands, ) { for entity in query.iter() { |
