diff options
| author | mat <git@matdoes.dev> | 2025-11-13 12:34:47 +0930 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-11-13 07:04:52 +0400 |
| commit | fbaae39cdf9c5a7a34005a51a37b85f7cdd5ea00 (patch) | |
| tree | 3126fb34a4e0ac979a1103a8227a2b9a136c1553 /azalea-client | |
| parent | a4312599f7c04709a92b7be238dcf577bafbb14f (diff) | |
| download | azalea-drasl-fbaae39cdf9c5a7a34005a51a37b85f7cdd5ea00.tar.xz | |
rename ResourceLocation to Identifier ahead of mojmap changes
Diffstat (limited to 'azalea-client')
| -rw-r--r-- | azalea-client/src/client.rs | 7 | ||||
| -rw-r--r-- | azalea-client/src/plugins/packet/game/events.rs | 4 | ||||
| -rw-r--r-- | azalea-client/src/test_utils/simulation.rs | 12 | ||||
| -rw-r--r-- | azalea-client/tests/change_dimension_to_nether_and_back.rs | 28 | ||||
| -rw-r--r-- | azalea-client/tests/despawn_entities_when_changing_dimension.rs | 12 | ||||
| -rw-r--r-- | azalea-client/tests/fast_login.rs | 6 | ||||
| -rw-r--r-- | azalea-client/tests/login_to_dimension_with_same_name.rs | 22 | ||||
| -rw-r--r-- | azalea-client/tests/reply_to_ping_with_pong.rs | 6 | ||||
| -rw-r--r-- | azalea-client/tests/set_health_before_login.rs | 6 |
9 files changed, 51 insertions, 52 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 6957619e..e0902779 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -10,8 +10,7 @@ use std::{ use azalea_auth::game_profile::GameProfile; use azalea_core::{ - data_registry::ResolvableDataRegistry, position::Vec3, resource_location::ResourceLocation, - tick::GameTick, + data_registry::ResolvableDataRegistry, identifier::Identifier, position::Vec3, tick::GameTick, }; use azalea_entity::{ EntityUpdateSystems, PlayerAbilities, Position, @@ -487,7 +486,7 @@ impl Client { pub fn resolve_registry_name( &self, registry: &impl ResolvableDataRegistry, - ) -> Option<ResourceLocation> { + ) -> Option<Identifier> { self.with_registry_holder(|registries| registry.resolve_name(registries)) } /// Resolve the given registry to its name and data and call the given @@ -502,7 +501,7 @@ impl Client { pub fn with_resolved_registry<R>( &self, registry: impl ResolvableDataRegistry, - f: impl FnOnce(&ResourceLocation, &NbtCompound) -> R, + f: impl FnOnce(&Identifier, &NbtCompound) -> R, ) -> Option<R> { self.with_registry_holder(|registries| { registry diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index 7c773b44..53d93855 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -1,7 +1,7 @@ use std::sync::{Arc, Weak}; use azalea_chat::FormattedText; -use azalea_core::resource_location::ResourceLocation; +use azalea_core::identifier::Identifier; use azalea_protocol::packets::{ Packet, game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket}, @@ -145,7 +145,7 @@ pub struct ResourcePackEvent { #[derive(Message, Debug, Clone)] pub struct InstanceLoadedEvent { pub entity: Entity, - pub name: ResourceLocation, + pub name: Identifier, pub instance: Weak<RwLock<Instance>>, } diff --git a/azalea-client/src/test_utils/simulation.rs b/azalea-client/src/test_utils/simulation.rs index 8d52177a..13470600 100644 --- a/azalea-client/src/test_utils/simulation.rs +++ b/azalea-client/src/test_utils/simulation.rs @@ -6,8 +6,8 @@ use azalea_buf::AzaleaWrite; use azalea_core::{ delta::LpVec3, game_type::{GameMode, OptionalGameType}, + identifier::Identifier, position::{BlockPos, ChunkPos, Vec3}, - resource_location::ResourceLocation, tick::GameTick, }; use azalea_entity::metadata::PlayerMetadataBundle; @@ -76,9 +76,9 @@ impl Simulation { ConnectionProtocol::Configuration => {} ConnectionProtocol::Game => { simulation.receive_packet(ClientboundRegistryData { - registry_id: ResourceLocation::new("minecraft:dimension_type"), + registry_id: Identifier::new("minecraft:dimension_type"), entries: vec![( - ResourceLocation::new("minecraft:overworld"), + Identifier::new("minecraft:overworld"), Some(NbtCompound::from_values(vec![ ("height".into(), NbtTag::Int(384)), ("min_y".into(), NbtTag::Int(-64)), @@ -302,13 +302,13 @@ fn tick_app(app: &mut App) { pub fn default_login_packet() -> ClientboundLogin { make_basic_login_packet( DimensionType::new_raw(0), // overworld - ResourceLocation::new("minecraft:overworld"), + Identifier::new("minecraft:overworld"), ) } pub fn make_basic_login_packet( dimension_type: DimensionType, - dimension: ResourceLocation, + dimension: Identifier, ) -> ClientboundLogin { ClientboundLogin { player_id: MinecraftEntityId(0), @@ -338,7 +338,7 @@ pub fn make_basic_login_packet( pub fn make_basic_respawn_packet( dimension_type: DimensionType, - dimension: ResourceLocation, + dimension: Identifier, ) -> ClientboundRespawn { ClientboundRespawn { common: CommonPlayerSpawnInfo { diff --git a/azalea-client/tests/change_dimension_to_nether_and_back.rs b/azalea-client/tests/change_dimension_to_nether_and_back.rs index e3b5d96e..9594da04 100644 --- a/azalea-client/tests/change_dimension_to_nether_and_back.rs +++ b/azalea-client/tests/change_dimension_to_nether_and_back.rs @@ -1,5 +1,5 @@ use azalea_client::{InConfigState, InGameState, test_utils::prelude::*}; -use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; +use azalea_core::{identifier::Identifier, position::ChunkPos}; use azalea_entity::LocalEntity; use azalea_protocol::packets::{ ConnectionProtocol, Packet, @@ -19,11 +19,11 @@ fn test_change_dimension_to_nether_and_back() { fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { let make_basic_login_or_respawn_packet = if using_respawn { - |dimension: DimensionType, instance_name: ResourceLocation| { + |dimension: DimensionType, instance_name: Identifier| { make_basic_respawn_packet(dimension, instance_name).into_variant() } } else { - |dimension: DimensionType, instance_name: ResourceLocation| { + |dimension: DimensionType, instance_name: Identifier| { make_basic_login_packet(dimension, instance_name).into_variant() } }; @@ -33,26 +33,26 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { assert!(!simulation.has_component::<InGameState>()); simulation.receive_packet(ClientboundRegistryData { - registry_id: ResourceLocation::new("minecraft:dimension_type"), + registry_id: Identifier::new("minecraft:dimension_type"), entries: vec![ ( // this dimension should never be created. it just exists to make sure we're not // hard-coding the dimension type id anywhere. - ResourceLocation::new("azalea:fakedimension"), + Identifier::new("azalea:fakedimension"), Some(NbtCompound::from_values(vec![ ("height".into(), NbtTag::Int(16)), ("min_y".into(), NbtTag::Int(0)), ])), ), ( - ResourceLocation::new("minecraft:overworld"), + Identifier::new("minecraft:overworld"), Some(NbtCompound::from_values(vec![ ("height".into(), NbtTag::Int(384)), ("min_y".into(), NbtTag::Int(-64)), ])), ), ( - ResourceLocation::new("minecraft:nether"), + Identifier::new("minecraft:nether"), Some(NbtCompound::from_values(vec![ ("height".into(), NbtTag::Int(256)), ("min_y".into(), NbtTag::Int(0)), @@ -76,13 +76,13 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { simulation.receive_packet(make_basic_login_packet( DimensionType::new_raw(1), // overworld - ResourceLocation::new("azalea:a"), + Identifier::new("azalea:a"), )); simulation.tick(); assert_eq!( *simulation.component::<InstanceName>(), - ResourceLocation::new("azalea:a"), + Identifier::new("azalea:a"), "InstanceName should be azalea:a after setting dimension to that" ); @@ -99,7 +99,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { simulation.receive_packet(make_basic_login_or_respawn_packet( DimensionType::new_raw(2), // nether - ResourceLocation::new("azalea:b"), + Identifier::new("azalea:b"), )); simulation.tick(); @@ -109,7 +109,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { ); assert_eq!( *simulation.component::<InstanceName>(), - ResourceLocation::new("azalea:b"), + Identifier::new("azalea:b"), "InstanceName should be azalea:b after changing dimensions to that" ); @@ -121,7 +121,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { .expect("chunk should exist"); simulation.receive_packet(make_basic_login_or_respawn_packet( DimensionType::new_raw(2), // nether - ResourceLocation::new("minecraft:nether"), + Identifier::new("minecraft:nether"), )); simulation.tick(); @@ -131,13 +131,13 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { simulation.receive_packet(make_basic_login_packet( DimensionType::new_raw(1), // overworld - ResourceLocation::new("azalea:a"), + Identifier::new("azalea:a"), )); simulation.tick(); assert_eq!( *simulation.component::<InstanceName>(), - ResourceLocation::new("azalea:a"), + Identifier::new("azalea:a"), "InstanceName should be azalea:a after setting dimension back to that" ); assert!( diff --git a/azalea-client/tests/despawn_entities_when_changing_dimension.rs b/azalea-client/tests/despawn_entities_when_changing_dimension.rs index 9143b3eb..38388c04 100644 --- a/azalea-client/tests/despawn_entities_when_changing_dimension.rs +++ b/azalea-client/tests/despawn_entities_when_changing_dimension.rs @@ -1,5 +1,5 @@ use azalea_client::test_utils::prelude::*; -use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; +use azalea_core::{identifier::Identifier, position::ChunkPos}; use azalea_entity::metadata::Cow; use azalea_protocol::packets::{ ConnectionProtocol, @@ -15,17 +15,17 @@ fn test_despawn_entities_when_changing_dimension() { let mut simulation = Simulation::new(ConnectionProtocol::Configuration); simulation.receive_packet(ClientboundRegistryData { - registry_id: ResourceLocation::new("minecraft:dimension_type"), + registry_id: Identifier::new("minecraft:dimension_type"), entries: vec![ ( - ResourceLocation::new("minecraft:overworld"), + Identifier::new("minecraft:overworld"), Some(NbtCompound::from_values(vec![ ("height".into(), NbtTag::Int(384)), ("min_y".into(), NbtTag::Int(-64)), ])), ), ( - ResourceLocation::new("minecraft:nether"), + Identifier::new("minecraft:nether"), Some(NbtCompound::from_values(vec