From f9c25665c203d6377ace62f1e95381d037d8fd9e Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Fri, 12 Dec 2025 00:56:02 -0600 Subject: 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 --- azalea-entity/src/plugin/mod.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'azalea-entity/src/plugin') diff --git a/azalea-entity/src/plugin/mod.rs b/azalea-entity/src/plugin/mod.rs index a3ea11d0..4ff6f4cd 100644 --- a/azalea-entity/src/plugin/mod.rs +++ b/azalea-entity/src/plugin/mod.rs @@ -3,11 +3,12 @@ mod relative_updates; use std::collections::HashSet; -use azalea_block::{BlockState, fluid_state::FluidKind}; +use azalea_block::{BlockState, BlockTrait, fluid_state::FluidKind, properties}; use azalea_core::{ position::{BlockPos, ChunkPos, Vec3}, tick::GameTick, }; +use azalea_registry::{builtin::BlockKind, tags}; use azalea_world::{InstanceContainer, InstanceName, MinecraftEntityId}; use bevy_app::{App, Plugin, PostUpdate, Update}; use bevy_ecs::prelude::*; @@ -143,11 +144,11 @@ pub fn update_on_climbable( let block_pos = BlockPos::from(position); let block_state_at_feet = instance.get_block_state(block_pos).unwrap_or_default(); - let block_at_feet = Box::::from(block_state_at_feet); + let block_at_feet = Box::::from(block_state_at_feet); let registry_block_at_feet = block_at_feet.as_registry_block(); - **on_climbable = azalea_registry::tags::blocks::CLIMBABLE.contains(®istry_block_at_feet) - || (azalea_registry::tags::blocks::TRAPDOORS.contains(®istry_block_at_feet) + **on_climbable = tags::blocks::CLIMBABLE.contains(®istry_block_at_feet) + || (tags::blocks::TRAPDOORS.contains(®istry_block_at_feet) && is_trapdoor_useable_as_ladder(block_state_at_feet, block_pos, &instance)); } } @@ -159,7 +160,7 @@ fn is_trapdoor_useable_as_ladder( ) -> bool { // trapdoor must be open if !block_state - .property::() + .property::() .unwrap_or_default() { return false; @@ -169,17 +170,16 @@ fn is_trapdoor_useable_as_ladder( let block_below = instance .get_block_state(block_pos.down(1)) .unwrap_or_default(); - let registry_block_below = - Box::::from(block_below).as_registry_block(); - if registry_block_below != azalea_registry::Block::Ladder { + let registry_block_below = Box::::from(block_below).as_registry_block(); + if registry_block_below != BlockKind::Ladder { return false; } // and the ladder must be facing the same direction as the trapdoor let ladder_facing = block_below - .property::() + .property::() .expect("ladder block must have facing property"); let trapdoor_facing = block_state - .property::() + .property::() .expect("trapdoor block must have facing property"); if ladder_facing != trapdoor_facing { return false; @@ -292,6 +292,7 @@ mod tests { properties::{FacingCardinal, TopBottom}, }; use azalea_core::position::{BlockPos, ChunkPos}; + use azalea_registry::builtin::BlockKind; use azalea_world::{Chunk, ChunkStorage, Instance, PartialInstance}; use super::is_trapdoor_useable_as_ladder; @@ -307,7 +308,7 @@ mod tests { ); partial_instance.chunks.set_block_state( BlockPos::new(0, 0, 0), - azalea_registry::Block::Stone.into(), + BlockKind::Stone.into(), &chunks, ); -- cgit v1.2.3