diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-12-12 00:56:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-12 00:56:02 -0600 |
| commit | f9c25665c203d6377ace62f1e95381d037d8fd9e (patch) | |
| tree | 8b4131d20fe661d3cc1175ec27f801fe61df41ea /azalea-client | |
| parent | 82ad975242292d5875780b4398b62637674bf50a (diff) | |
| download | azalea-drasl-f9c25665c203d6377ace62f1e95381d037d8fd9e.tar.xz | |
Refactor azalea-registry (#294)
* move registries in azalea-registry into separate modules
* rename Item and Block to ItemKind and BlockKind
* remove 'extra' registries from azalea-registry
* hide deprecated items from docs
* use DamageKindKey instead of Identifier when parsing registries
* store tag entries as a Vec instead of a HashSet
* sort tag values by protocol id
* update changelog
Diffstat (limited to 'azalea-client')
29 files changed, 135 insertions, 123 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 970d8da0..aa2da1d5 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -10,7 +10,9 @@ use std::{ use azalea_auth::game_profile::GameProfile; use azalea_core::{ - data_registry::ResolvableDataRegistry, identifier::Identifier, position::Vec3, tick::GameTick, + data_registry::{DataRegistryWithKey, ResolvableDataRegistry}, + position::Vec3, + tick::GameTick, }; use azalea_entity::{ Attributes, EntityUpdateSystems, PlayerAbilities, Position, @@ -26,6 +28,7 @@ use azalea_protocol::{ packets::{Packet, game::ServerboundGamePacket}, resolve, }; +use azalea_registry::{DataRegistryKeyRef, identifier::Identifier}; use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId, PartialInstance}; use bevy_app::{App, AppExit, Plugin, PluginsState, SubApp, Update}; use bevy_ecs::{ @@ -517,7 +520,7 @@ impl Client { &self, registry: &impl ResolvableDataRegistry, ) -> Option<Identifier> { - self.with_registry_holder(|registries| registry.resolve_name(registries).cloned()) + self.with_registry_holder(|registries| registry.key(registries).map(|r| r.into_ident())) } /// Resolve the given registry to its name and data and call the given /// function with it. diff --git a/azalea-client/src/plugins/interact/mod.rs b/azalea-client/src/plugins/interact/mod.rs index 47ada08a..8269197c 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_registry::Item; +use azalea_registry::builtin::ItemKind; use azalea_world::Instance; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; @@ -527,45 +527,45 @@ fn update_attributes_for_held_item( } } -fn added_attack_speed_for_item(item: Item) -> f64 { +fn added_attack_speed_for_item(item: ItemKind) -> f64 { match item { - Item::WoodenSword => -2.4, - Item::WoodenShovel => -3.0, - Item::WoodenPickaxe => -2.8, - Item::WoodenAxe => -3.2, - Item::WoodenHoe => -3.0, - - Item::StoneSword => -2.4, - Item::StoneShovel => -3.0, - Item::StonePickaxe => -2.8, - Item::StoneAxe => -3.2, - Item::StoneHoe => -2.0, - - Item::GoldenSword => -2.4, - Item::GoldenShovel => -3.0, - Item::GoldenPickaxe => -2.8, - Item::GoldenAxe => -3.0, - Item::GoldenHoe => -3.0, - - Item::IronSword => -2.4, - Item::IronShovel => -3.0, - Item::IronPickaxe => -2.8, - Item::IronAxe => -3.1, - Item::IronHoe => -1.0, - - Item::DiamondSword => -2.4, - Item::DiamondShovel => -3.0, - Item::DiamondPickaxe => -2.8, - Item::DiamondAxe => -3.0, - Item::DiamondHoe => 0.0, - - Item::NetheriteSword => -2.4, - Item::NetheriteShovel => -3.0, - Item::NetheritePickaxe => -2.8, - Item::NetheriteAxe => -3.0, - Item::NetheriteHoe => 0.0, - - Item::Trident => -2.9, + ItemKind::WoodenSword => -2.4, + ItemKind::WoodenShovel => -3.0, + ItemKind::WoodenPickaxe => -2.8, + ItemKind::WoodenAxe => -3.2, + ItemKind::WoodenHoe => -3.0, + + ItemKind::StoneSword => -2.4, + ItemKind::StoneShovel => -3.0, + ItemKind::StonePickaxe => -2.8, + ItemKind::StoneAxe => -3.2, + ItemKind::StoneHoe => -2.0, + + ItemKind::GoldenSword => -2.4, + ItemKind::GoldenShovel => -3.0, + ItemKind::GoldenPickaxe => -2.8, + ItemKind::GoldenAxe => -3.0, + ItemKind::GoldenHoe => -3.0, + + ItemKind::IronSword => -2.4, + ItemKind::IronShovel => -3.0, + ItemKind::IronPickaxe => -2.8, + ItemKind::IronAxe => -3.1, + ItemKind::IronHoe => -1.0, + + ItemKind::DiamondSword => -2.4, + ItemKind::DiamondShovel => -3.0, + ItemKind::DiamondPickaxe => -2.8, + ItemKind::DiamondAxe => -3.0, + ItemKind::DiamondHoe => 0.0, + + ItemKind::NetheriteSword => -2.4, + ItemKind::NetheriteShovel => -3.0, + ItemKind::NetheritePickaxe => -2.8, + ItemKind::NetheriteAxe => -3.0, + ItemKind::NetheriteHoe => 0.0, + + ItemKind::Trident => -2.9, _ => 0., } } diff --git a/azalea-client/src/plugins/inventory/equipment_effects.rs b/azalea-client/src/plugins/inventory/equipment_effects.rs index 4294cc2f..c02f8ad5 100644 --- a/azalea-client/src/plugins/inventory/equipment_effects.rs +++ b/azalea-client/src/plugins/inventory/equipment_effects.rs @@ -2,15 +2,13 @@ use std::collections::HashMap; -use azalea_core::{ - data_registry::ResolvableDataRegistry, identifier::Identifier, - registry_holder::value::AttributeEffect, -}; +use azalea_core::{data_registry::ResolvableDataRegistry, registry_holder::value::AttributeEffect}; use azalea_entity::{Attributes, inventory::Inventory}; use azalea_inventory::{ ItemStack, components::{self, AttributeModifier, EquipmentSlot}, }; +use azalea_registry::identifier::Identifier; use bevy_ecs::{ component::Component, entity::Entity, @@ -147,7 +145,7 @@ fn collect_attribute_modifiers_from_item( slot: EquipmentSlot, item: &ItemStack, instance_holder: &InstanceHolder, -) -> Vec<(azalea_registry::Attribute, AttributeModifier)> { +) -> Vec<(azalea_registry::builtin::Attribute, AttributeModifier)> { let mut modifiers = Vec::new(); // handle the attribute_modifiers component first diff --git a/azalea-client/src/plugins/inventory/mod.rs b/azalea-client/src/plugins/inventory/mod.rs index f0d4a9ce..93be9e96 100644 --- a/azalea-client/src/plugins/inventory/mod.rs +++ b/azalea-client/src/plugins/inventory/mod.rs @@ -10,7 +10,7 @@ use azalea_protocol::packets::game::{ s_container_close::ServerboundContainerClose, s_set_carried_item::ServerboundSetCarriedItem, }; -use azalea_registry::MenuKind; +use azalea_registry::builtin::MenuKind; use azalea_world::{InstanceContainer, InstanceName}; use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; @@ -25,6 +25,7 @@ use crate::{ // TODO: when this is removed, remove the Inv alias above (which just exists to // avoid conflicting with this pub deprecated type) +#[doc(hidden)] #[deprecated = "moved to `azalea_entity::inventory::Inventory`."] pub type Inventory = azalea_entity::inventory::Inventory; diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs index 73f2733d..4ed14482 100644 --- a/azalea-client/src/plugins/mining.rs +++ b/azalea-client/src/plugins/mining.rs @@ -7,6 +7,7 @@ use azalea_entity::{ 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 bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; @@ -525,10 +526,8 @@ pub fn handle_finish_mining_block_observer( if game_mode.current == GameMode::Creative { let held_item = inventory.held_item().kind(); - if matches!( - held_item, - azalea_registry::Item::Trident | azalea_registry::Item::DebugStick - ) || azalea_registry::tags::items::SWORDS.contains(&held_item) + if matches!(held_item, ItemKind::Trident | ItemKind::DebugStick) + || azalea_registry::tags::items::SWORDS.contains(&held_item) { return; } @@ -538,12 +537,11 @@ pub fn handle_finish_mining_block_observer( return; }; - let registry_block: azalea_registry::Block = - Box::<dyn BlockTrait>::from(block_state).as_registry_block(); + let registry_block = Box::<dyn BlockTrait>::from(block_state).as_registry_block(); if !can_use_game_master_blocks(abilities, permission_level) && matches!( registry_block, - azalea_registry::Block::CommandBlock | azalea_registry::Block::StructureBlock + BlockKind::CommandBlock | BlockKind::StructureBlock ) { return; diff --git a/azalea-client/src/plugins/movement.rs b/azalea-client/src/plugins/movement.rs index 587bc05b..703b5557 100644 --- a/azalea-client/src/plugins/movement.rs +++ b/azalea-client/src/plugins/movement.rs @@ -29,7 +29,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::EntityKind; +use azalea_registry::builtin::EntityKind; use azalea_world::{Instance, MinecraftEntityId}; use bevy_app::{App, Plugin, Update}; use bevy_ecs::prelude::*; diff --git a/azalea-client/src/plugins/packet/game/events.rs b/azalea-client/src/plugins/packet/game/events.rs index 53d93855..9ce4c252 100644 --- a/azalea-client/src/plugins/packet/game/events.rs +++ b/azalea-client/src/plugins/packet/game/events.rs @@ -1,11 +1,11 @@ use std::sync::{Arc, Weak}; use azalea_chat::FormattedText; -use azalea_core::identifier::Identifier; use azalea_protocol::packets::{ Packet, game::{ClientboundGamePacket, ClientboundPlayerCombatKill, ServerboundGamePacket}, }; +use azalea_registry::identifier::Identifier; use azalea_world::Instance; use bevy_ecs::prelude::*; use parking_lot::RwLock; diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs index 7446a506..89b33274 100644 --- a/azalea-client/src/plugins/packet/game/mod.rs +++ b/azalea-client/src/plugins/packet/game/mod.rs @@ -17,6 +17,7 @@ use azalea_protocol::{ common::movements::MoveFlags, packets::{ConnectionProtocol, game::*}, }; +use azalea_registry::builtin::EntityKind; use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId, PartialInstance}; use bevy_ecs::{prelude::*, system::SystemState}; pub use events::*; @@ -292,7 +293,7 @@ impl GamePacketHandler<'_> { let entity_bundle = EntityBundle::new( game_profile.uuid, Vec3::ZERO, - azalea_registry::EntityKind::Player, + EntityKind::Player, new_instance_name, ); let entity_id = p.player_id; @@ -1478,7 +1479,7 @@ impl GamePacketHandler<'_> { let entity_bundle = EntityBundle::new( game_profile.uuid, Vec3::ZERO, - azalea_registry::EntityKind::Player, + EntityKind::Player, new_instance_name, ); // update the local gamemode and metadata things diff --git a/azalea-client/src/test_utils/simulation.rs b/azalea-client/src/test_utils/simulation.rs index 0aeec3ea..1946fd6d 100644 --- a/azalea-client/src/test_utils/simulation.rs +++ b/azalea-client/src/test_utils/simulation.rs @@ -6,7 +6,6 @@ use azalea_buf::AzaleaWrite; use azalea_core::{ delta::LpVec3, game_type::{GameMode, OptionalGameType}, - identifier::Identifier, position::{BlockPos, ChunkPos, Vec3}, tick::GameTick, }; @@ -25,7 +24,12 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::{Biome, DataRegistry, DimensionType, EntityKind}; +use azalea_registry::{ + DataRegistry, + builtin::EntityKind, + data::{Biome, DimensionKind}, + identifier::Identifier, +}; use azalea_world::{Chunk, Instance, MinecraftEntityId, Section, palette::PalettedContainer}; use bevy_app::App; use bevy_ecs::{ @@ -318,13 +322,13 @@ fn tick_app(app: &mut App) { pub fn default_login_packet() -> ClientboundLogin { make_basic_login_packet( - DimensionType::new_raw(0), // overworld + DimensionKind::new_raw(0), // overworld Identifier::new("minecraft:overworld"), ) } pub fn make_basic_login_packet( - dimension_type: DimensionType, + dimension_type: DimensionKind, dimension: Identifier, ) -> ClientboundLogin { ClientboundLogin { @@ -354,7 +358,7 @@ pub fn make_basic_login_packet( } pub fn make_basic_respawn_packet( - dimension_type: DimensionType, + dimension_type: DimensionKind, dimension: Identifier, ) -> ClientboundRespawn { ClientboundRespawn { 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 9594da04..134c7cbf 100644 --- a/azalea-client/tests/change_dimension_to_nether_and_back.rs +++ b/azalea-client/tests/change_dimension_to_nether_and_back.rs @@ -1,11 +1,11 @@ use azalea_client::{InConfigState, InGameState, test_utils::prelude::*}; -use azalea_core::{identifier::Identifier, position::ChunkPos}; +use azalea_core::position::ChunkPos; use azalea_entity::LocalEntity; use azalea_protocol::packets::{ ConnectionProtocol, Packet, config::{ClientboundFinishConfiguration, ClientboundRegistryData}, }; -use azalea_registry::{DataRegistry, DimensionType}; +use azalea_registry::{DataRegistry, data::DimensionKind, identifier::Identifier}; use azalea_world::InstanceName; use simdnbt::owned::{NbtCompound, NbtTag}; @@ -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: Identifier| { + |dimension: DimensionKind, instance_name: Identifier| { make_basic_respawn_packet(dimension, instance_name).into_variant() } } else { - |dimension: DimensionType, instance_name: Identifier| { + |dimension: DimensionKind, instance_name: Identifier| { make_basic_login_packet(dimension, instance_name).into_variant() } }; @@ -75,7 +75,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { // simulation.receive_packet(make_basic_login_packet( - DimensionType::new_raw(1), // overworld + DimensionKind::new_raw(1), // overworld Identifier::new("azalea:a"), )); simulation.tick(); @@ -98,7 +98,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 + DimensionKind::new_raw(2), // nether Identifier::new("azalea:b"), )); simulation.tick(); @@ -120,7 +120,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { .chunk(ChunkPos::new(0, 0)) .expect("chunk should exist"); simulation.receive_packet(make_basic_login_or_respawn_packet( - DimensionType::new_raw(2), // nether + DimensionKind::new_raw(2), // nether Identifier::new("minecraft:nether"), )); simulation.tick(); @@ -130,7 +130,7 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { // simulation.receive_packet(make_basic_login_packet( - DimensionType::new_raw(1), // overworld + DimensionKind::new_raw(1), // overworld Identifier::new("azalea:a"), )); simulation.tick(); diff --git a/azalea-client/tests/close_open_container.rs b/azalea-client/tests/close_open_container.rs index 96978c59..32a9874d 100644 --- a/azalea-client/tests/close_open_container.rs +++ b/azalea-client/tests/close_open_container.rs @@ -6,7 +6,7 @@ use azalea_protocol::packets::{ ConnectionProtocol, game::{ClientboundContainerClose, ClientboundOpenScreen, ClientboundSetChunkCacheCenter}, }; -use azalea_registry::MenuKind; +use azalea_registry::builtin::MenuKind; #[test] fn test_close_open_container() { diff --git a/azalea-client/tests/correct_movement.rs b/azalea-client/tests/correct_movement.rs index 5aaea9a3..de494111 100644 --- a/azalea-client/tests/correct_movement.rs +++ b/azalea-client/tests/correct_movement.rs @@ -11,7 +11,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_correct_movement() { @@ -34,7 +34,7 @@ fn test_correct_movement() { )); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(31, 63, 370), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, diff --git a/azalea-client/tests/correct_sneak_movement.rs b/azalea-client/tests/correct_sneak_movement.rs index 0e06633a..1186ce8b 100644 --- a/azalea-client/tests/correct_sneak_movement.rs +++ b/azalea-client/tests/correct_sneak_movement.rs @@ -11,7 +11,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_correct_sneak_movement() { @@ -29,11 +29,11 @@ fn test_correct_sneak_movement() { simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16)); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(0, 119, 0), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(0, 119, 1), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, diff --git a/azalea-client/tests/correct_sprint_sneak_movement.rs b/azalea-client/tests/correct_sprint_sneak_movement.rs index c76bc158..8ab955b8 100644 --- a/azalea-client/tests/correct_sprint_sneak_movement.rs +++ b/azalea-client/tests/correct_sprint_sneak_movement.rs @@ -11,7 +11,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_correct_sprint_sneak_movement() { @@ -29,11 +29,11 @@ fn test_correct_sprint_sneak_movement() { simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16)); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(0, 119, 0), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(0, 119, 1), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, diff --git a/azalea-client/tests/despawn_entities_when_changing_dimension.rs b/azalea-client/tests/despawn_entities_when_changing_dimension.rs index 38388c04..466da948 100644 --- a/azalea-client/tests/despawn_entities_when_changing_dimension.rs +++ b/azalea-client/tests/despawn_entities_when_changing_dimension.rs @@ -1,11 +1,13 @@ use azalea_client::test_utils::prelude::*; -use azalea_core::{identifier::Identifier, position::ChunkPos}; +use azalea_core::position::ChunkPos; use azalea_entity::metadata::Cow; use azalea_protocol::packets::{ ConnectionProtocol, config::{ClientboundFinishConfiguration, ClientboundRegistryData}, }; -use azalea_registry::{DataRegistry, DimensionType, EntityKind}; +use azalea_registry::{ + DataRegistry, builtin::EntityKind, data::DimensionKind, identifier::Identifier, +}; use bevy_ecs::query::With; use simdnbt::owned::{NbtCompound, NbtTag}; @@ -44,7 +46,7 @@ fn test_despawn_entities_when_changing_dimension() { // simulation.receive_packet(make_basic_login_packet( - DimensionType::new_raw(0), // overworld + DimensionKind::new_raw(0), // overworld Identifier::new("azalea:a"), )); simulation.tick(); @@ -64,7 +66,7 @@ fn test_despawn_entities_when_changing_dimension() { // simulation.receive_packet(make_basic_respawn_packet( - DimensionType::new_raw(1), // nether + DimensionKind::new_raw(1), // nether Identifier::new("azalea:b"), )); simulation.tick(); diff --git a/azalea-client/tests/enchantments.rs b/azalea-client/tests/enchantments.rs index 55b7c452..8e1a695c 100644 --- a/azalea-client/tests/enchantments.rs +++ b/azalea-client/tests/enchantments.rs @@ -1,5 +1,4 @@ use azalea_client::test_utils::prelude::*; -use azalea_core::identifier::Identifier; use azalea_entity::Attributes; use azalea_inventory::{ItemStack, components::Enchantments}; use azalea_protocol::packets::{ @@ -7,7 +6,7 @@ use azalea_protocol::packets::{ config::{ClientboundFinishConfiguration, ClientboundRegistryData}, game::ClientboundContainerSetSlot, }; -use azalea_registry::{Enchantment, Item, Registry}; +use azalea_registry::{Registry, builtin::ItemKind, data::Enchantment, identifier::Identifier}; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] @@ -92,7 +91,7 @@ fn test_enchantments() { container_id: 0, state_id: 1, slot: *azalea_inventory::Player::HOTBAR_SLOTS.start() as u16, - item_stack: Item::DiamondPickaxe.into(), + item_stack: ItemKind::DiamondPickaxe.into(), }); s.tick(); @@ -103,7 +102,7 @@ fn test_enchantments() { container_id: 0, state_id: 2, slot: *azalea_inventory::Player::HOTBAR_SLOTS.start() as u16, - item_stack: ItemStack::from(Item::DiamondPickaxe).with_component(Enchantments { + item_stack: ItemStack::from(ItemKind::DiamondPickaxe).with_component(Enchantments { levels: [(Enchantment::from_u32(0).unwrap(), 1)].into(), }), }); @@ -116,7 +115,7 @@ fn test_enchantments() { container_id: 0, state_id: 1, slot: *azalea_inventory::Player::HOTBAR_SLOTS.start() as u16, - item_stack: Item::DiamondPickaxe.into(), + item_stack: ItemKind::DiamondPickaxe.into(), }); s.tick(); diff --git a/azalea-client/tests/fast_login.rs b/azalea-client/tests/fast_login.rs index 7962d79e..5a653425 100644 --- a/azalea-client/tests/fast_login.rs +++ b/azalea-client/tests/fast_login.rs @@ -1,11 +1,11 @@ use azalea_client::{InConfigState, test_utils::prelude::*}; -use azalea_core::identifier::Identifier; use azalea_entity::metadata::Health; use azalea_protocol::packets::{ ConnectionProtocol, config::{ClientboundFinishConfiguration, ClientboundRegistryData}, game::ClientboundSetHealth, }; +use azalea_registry::identifier::Identifier; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] diff --git a/azalea-client/tests/login_to_dimension_with_same_name.rs b/azalea-client/tests/login_to_dimension_with_same_name.rs index 0a28cfd3..4adced62 100644 --- a/azalea-client/tests/login_to_dimension_with_same_name.rs +++ b/azalea-client/tests/login_to_dimension_with_same_name.rs @@ -1,14 +1,14 @@ use azalea_client::{ InConfigState, InGameState, local_player::InstanceHolder, test_utils::prelude::*, }; -use azalea_core::{identifier::Identifier, position::ChunkPos}; +use azalea_core::position::ChunkPos; use azalea_entity::LocalEntity; use azalea_protocol::packets::{ ConnectionProtocol, Packet, config::{ClientboundFinishConfiguration, ClientboundRegistryData}, game::ClientboundStartConfiguration, }; -use azalea_registry::{DataRegistry, DimensionType}; +use azalea_registry::{DataRegistry, data::DimensionKind, identifier::Identifier}; use azalea_world::InstanceName; use simdnbt::owned::{NbtCompound, NbtTag}; @@ -22,11 +22,11 @@ fn test_login_to_dimension_with_same_name() { fn generic_test_login_to_dimension_with_same_name(using_respawn: bool) { let make_basic_login_or_respawn_packet = if using_respawn { - |dimension: DimensionType, instance_name: Identifier| { + |dimension: DimensionKind, instance_name: Identifier| { make_basic_respawn_packet(dimension, instance_name).into_variant() } } else { - |dimension: DimensionType, instance_name: Identifier| { + |dimension: DimensionKind, instance_name: Identifier| { make_basic_login_packet(dimension, instance_name).into_variant() } }; @@ -60,7 +60,7 @@ fn generic_test_login_to_dimension_with_same_name(using_respawn: bool) { // simulation.receive_packet(make_basic_login_packet( - DimensionType::new_raw(0), // overworld + DimensionKind::new_raw(0), // overworld Identifier::new("azalea:overworld"), )); simulation.tick(); @@ -97,7 +97,7 @@ fn generic_test_login_to_dimension_with_same_name(using_respawn: bool) { }); simulation.receive_packet(ClientboundFinishConfiguration); simulation.receive_packet(make_basic_login_or_respawn_packet( - DimensionType::new_raw(0), + DimensionKind::new_raw(0), Identifier::new("azalea:overworld"), )); simulation.tick(); diff --git a/azalea-client/tests/mine_block_rollback.rs b/azalea-client/tests/mine_block_rollback.rs index 44ad629f..7d2ed1a5 100644 --- a/azalea-client/tests/mine_block_rollback.rs +++ b/azalea-client/tests/mine_block_rollback.rs @@ -4,7 +4,7 @@ use azalea_protocol::packets::{ ConnectionProtocol, game::{ClientboundBlockChangedAck, ClientboundBlockUpdate}, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_mine_block_rollback() { @@ -21,10 +21,10 @@ fn test_mine_block_rollback() { pos, // tnt is used for this test because it's insta-mineable so we don't have to waste ticks // waiting - block_state: Block::Tnt.into(), + block_state: BlockKind::Tnt.into(), }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Tnt.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Tnt.into())); println!("set serverside tnt"); simulation.write_message(StartMiningBlockEvent { @@ -33,12 +33,12 @@ fn test_mine_block_rollback() { force: true, }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Air.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Air.into())); println!("set clientside air"); // server didn't send the new block, so the change should be rolled back simulation.receive_packet(ClientboundBlockChangedAck { seq: 1 }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Tnt.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Tnt.into())); println!("reset serverside tnt"); } diff --git a/azalea-client/tests/mine_block_timing_hand.rs b/azalea-client/tests/mine_block_timing_hand.rs index 650e630e..6f583e7b 100644 --- a/azalea-client/tests/mine_block_timing_hand.rs +++ b/azalea-client/tests/mine_block_timing_hand.rs @@ -15,7 +15,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_mine_block_timing_hand() { @@ -31,7 +31,7 @@ fn test_mine_block_timing_hand() { let pos = BlockPos::new(0, 2, 0); simulation.receive_packet(ClientboundBlockUpdate { pos, - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, @@ -43,7 +43,10 @@ fn test_mine_block_timing_hand() { relative: RelativeMovements::all_absolute(), }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Stone.into())); + assert_eq!( + simulation.get_block_state(pos), + Some(BlockKind::Stone.into()) + ); println!("set serverside stone"); simulation.with_component_mut::<LookDirection>(|look| { // look down diff --git a/azalea-client/tests/mine_block_without_rollback.rs b/azalea-client/tests/mine_block_without_rollback.rs index a5a437a0..b6020ea2 100644 --- a/azalea-client/tests/mine_block_without_rollback.rs +++ b/azalea-client/tests/mine_block_without_rollback.rs @@ -4,7 +4,7 @@ use azalea_protocol::packets::{ ConnectionProtocol, game::{ClientboundBlockChangedAck, ClientboundBlockUpdate}, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_mine_block_without_rollback() { @@ -21,10 +21,10 @@ fn test_mine_block_without_rollback() { pos, // tnt is used for this test because it's insta-mineable so we don't have to waste ticks // waiting - block_state: Block::Tnt.into(), + block_state: BlockKind::Tnt.into(), }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Tnt.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Tnt.into())); simulation.write_message(StartMiningBlockEvent { entity: simulation.entity, @@ -32,15 +32,15 @@ fn test_mine_block_without_rollback() { force: true, }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Air.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Air.into())); // server acknowledged our change by sending a BlockUpdate + BlockChangedAck, so // no rollback simulation.receive_packet(ClientboundBlockUpdate { pos, - block_state: Block::Air.into(), + block_state: BlockKind::Air.into(), }); simulation.receive_packet(ClientboundBlockChangedAck { seq: 1 }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Air.into())); + assert_eq!(simulation.get_block_state(pos), Some(BlockKind::Air.into())); } diff --git a/azalea-client/tests/move_and_despawn_entity.rs b/azalea-client/tests/move_and_despawn_entity.rs index c05c3f0e..8a143243 100644 --- a/azalea-client/tests/move_and_despawn_entity.rs +++ b/azalea-client/tests/move_and_despawn_entity.rs @@ -7,7 +7,7 @@ use azalea_protocol::{ game::{ClientboundRemoveEntities, ClientboundTeleportEntity}, }, }; -use azalea_registry::EntityKind; +use azalea_registry::builtin::EntityKind; use azalea_world::MinecraftEntityId; #[test] diff --git a/azalea-client/tests/move_despawned_entity.rs b/azalea-client/tests/move_despawned_entity.rs index 8407bfe1..dad2a710 100644 --- a/azalea-client/tests/move_despawned_entity.rs +++ b/azalea-client/tests/move_despawned_entity.rs @@ -2,7 +2,7 @@ use azalea_client::test_utils::prelude::*; use azalea_core::position::ChunkPos; use azalea_entity::metadata::Cow; use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundMoveEntityRot}; -use azalea_registry::EntityKind; +use azalea_registry::builtin::EntityKind; use azalea_world::MinecraftEntityId; use bevy_ecs::query::With; use tracing::Level; diff --git a/azalea-client/tests/packet_order.rs b/azalea-client/tests/packet_order.rs index 90496292..619ed0b6 100644 --- a/azalea-client/tests/packet_order.rs +++ b/azalea-client/tests/packet_order.rs @@ -11,7 +11,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_packet_order() { @@ -30,7 +30,7 @@ fn test_packet_order() { simulation.receive_packet(make_basic_empty_chunk(ChunkPos::new(0, 0), (384 + 64) / 16)); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(1, 1, 3), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, @@ -44,7 +44,7 @@ fn test_packet_order() { simulation.tick(); assert_eq!( simulation.get_block_state(BlockPos::new(1, 1, 3)), - Some(Block::Stone.into()) + Some(BlockKind::Stone.into()) ); sent_packets.expect("AcceptTeleportation", |p| { matches!( diff --git a/azalea-client/tests/packet_order_set_carried_item.rs b/azalea-client/tests/packet_order_set_carried_item.rs index a357dec0..e8ac386f 100644 --- a/azalea-client/tests/packet_order_set_carried_item.rs +++ b/azalea-client/tests/packet_order_set_carried_item.rs @@ -17,7 +17,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; #[test] fn test_packet_order_set_carried_item() { @@ -33,7 +33,7 @@ fn test_packet_order_set_carried_item() { let pos = BlockPos::new(0, 2, 0); simulation.receive_packet(ClientboundBlockUpdate { pos, - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, @@ -45,7 +45,10 @@ fn test_packet_order_set_carried_item() { relative: RelativeMovements::all_absolute(), }); simulation.tick(); - assert_eq!(simulation.get_block_state(pos), Some(Block::Stone.into())); + assert_eq!( + simulation.get_block_state(pos), + Some(BlockKind::Stone.into()) + ); simulation.with_component_mut::<LookDirection>(|look| { // look down look.update_x_rot(90.); diff --git a/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs index 8fa3d925..dfb1fef9 100644 --- a/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs +++ b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs @@ -4,7 +4,7 @@ use azalea_protocol::packets::{ ConnectionProtocol, game::{ClientboundAddEntity, ClientboundStartConfiguration}, }; -use azalea_registry::EntityKind; +use azalea_registry::builtin::EntityKind; use azalea_world::InstanceName; use uuid::Uuid; diff --git a/azalea-client/tests/reply_to_ping_with_pong.rs b/azalea-client/tests/reply_to_ping_with_pong.rs index ff369a1d..6b7cb4ca 100644 --- a/azalea-client/tests/reply_to_ping_with_pong.rs +++ b/azalea-client/tests/reply_to_ping_with_pong.rs @@ -4,7 +4,6 @@ use azalea_client::{ packet::{config::SendConfigPacketEvent, game::SendGamePacketEvent}, test_utils::prelude::*, }; -use azalea_core::identifier::Identifier; use azalea_protocol::packets::{ ConnectionProtocol, config::{ @@ -12,6 +11,7 @@ use azalea_protocol::packets::{ }, game::{self, ServerboundGamePacket}, }; +use azalea_registry::identifier::Identifier; use bevy_ecs::observer::On; use parking_lot::Mutex; use simdnbt::owned::{NbtCompound, NbtTag}; diff --git a/azalea-client/tests/set_health_before_login.rs b/azalea-client/tests/set_health_before_login.rs index 5b2dfc8e..4c1ec3f6 100644 --- a/azalea-client/tests/set_health_before_login.rs +++ b/azalea-client/tests/set_health_before_login.rs @@ -1,11 +1,11 @@ use azalea_client::{InConfigState, test_utils::prelude::*}; -use azalea_core::identifier::Identifier; use azalea_entity::{LocalEntity, metadata::Health}; use azalea_protocol::packets::{ ConnectionProtocol, config::{ClientboundFinishConfiguration, ClientboundRegistryData}, game::ClientboundSetHealth, }; +use azalea_registry::identifier::Identifier; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] diff --git a/azalea-client/tests/teleport_movement.rs b/azalea-client/tests/teleport_movement.rs index 48fc11d5..03df5b92 100644 --- a/azalea-client/tests/teleport_movement.rs +++ b/azalea-client/tests/teleport_movement.rs @@ -15,7 +15,7 @@ use azalea_protocol::{ }, }, }; -use azalea_registry::Block; +use azalea_registry::builtin::BlockKind; use azalea_world::MinecraftEntityId; #[test] @@ -39,7 +39,7 @@ fn test_teleport_movement() { )); simulation.receive_packet(ClientboundBlockUpdate { pos: BlockPos::new(31, 63, 370), - block_state: Block::Stone.into(), + block_state: BlockKind::Stone.into(), }); simulation.receive_packet(ClientboundPlayerPosition { id: 1, |
