aboutsummaryrefslogtreecommitdiff
path: root/azalea-physics/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-12-12 00:56:02 -0600
committerGitHub <noreply@github.com>2025-12-12 00:56:02 -0600
commitf9c25665c203d6377ace62f1e95381d037d8fd9e (patch)
tree8b4131d20fe661d3cc1175ec27f801fe61df41ea /azalea-physics/src
parent82ad975242292d5875780b4398b62637674bf50a (diff)
downloadazalea-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-physics/src')
-rw-r--r--azalea-physics/src/clip.rs5
-rw-r--r--azalea-physics/src/collision/mod.rs11
-rw-r--r--azalea-physics/src/fluids.rs5
-rw-r--r--azalea-physics/src/lib.rs14
4 files changed, 18 insertions, 17 deletions
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs
index dbab0da6..625a709e 100644
--- a/azalea-physics/src/clip.rs
+++ b/azalea-physics/src/clip.rs
@@ -11,6 +11,7 @@ use azalea_core::{
math::{self, EPSILON, lerp},
position::{BlockPos, Vec3},
};
+use azalea_registry::{builtin::BlockKind, tags};
use azalea_world::ChunkStorage;
use crate::collision::{BlockWithShape, EMPTY_SHAPE, VoxelShape};
@@ -34,9 +35,7 @@ impl ClipContext {
BlockShapeType::Outline => block_state.outline_shape(),
BlockShapeType::Visual => block_state.collision_shape(),
BlockShapeType::FallDamageResetting => {
- if azalea_registry::tags::blocks::FALL_DAMAGE_RESETTING
- .contains(&azalea_registry::Block::from(block_state))
- {
+ if tags::blocks::FALL_DAMAGE_RESETTING.contains(&BlockKind::from(block_state)) {
block_state.collision_shape()
} else {
&EMPTY_SHAPE
diff --git a/azalea-physics/src/collision/mod.rs b/azalea-physics/src/collision/mod.rs
index e6423fc4..6c622d40 100644
--- a/azalea-physics/src/collision/mod.rs
+++ b/azalea-physics/src/collision/mod.rs
@@ -7,7 +7,7 @@ pub mod world_collisions;
use std::{ops::Add, sync::LazyLock};
-use azalea_block::{BlockState, fluid_state::FluidState};
+use azalea_block::{BlockState, BlockTrait, fluid_state::FluidState};
use azalea_core::{
aabb::Aabb,
direction::Axis,
@@ -18,6 +18,7 @@ use azalea_entity::{
Attributes, Jumping, LookDirection, OnClimbable, Physics, PlayerAbilities, Pose, Position,
metadata::Sprinting,
};
+use azalea_registry::builtin::BlockKind;
use azalea_world::{ChunkStorage, Instance};
use bevy_ecs::{entity::Entity, world::Mut};
pub use blocks::BlockWithShape;
@@ -483,15 +484,15 @@ pub fn legacy_blocks_motion(block: BlockState) -> bool {
return false;
}
- let registry_block = azalea_registry::Block::from(block);
+ let registry_block = BlockKind::from(block);
legacy_calculate_solid(block)
- && registry_block != azalea_registry::Block::Cobweb
- && registry_block != azalea_registry::Block::BambooSapling
+ && registry_block != BlockKind::Cobweb
+ && registry_block != BlockKind::BambooSapling
}
pub fn legacy_calculate_solid(block: BlockState) -> bool {
// force_solid has to be checked before anything else
- let block_trait = Box::<dyn azalea_block::BlockTrait>::from(block);
+ let block_trait = Box::<dyn BlockTrait>::from(block);
if let Some(solid) = block_trait.behavior().force_solid {
return solid;
}
diff --git a/azalea-physics/src/fluids.rs b/azalea-physics/src/fluids.rs
index 3675ca3e..fa6a1586 100644
--- a/azalea-physics/src/fluids.rs
+++ b/azalea-physics/src/fluids.rs
@@ -7,6 +7,7 @@ use azalea_core::{
position::{BlockPos, Vec3},
};
use azalea_entity::{HasClientLoaded, LocalEntity, Physics, Position};
+use azalea_registry::builtin::BlockKind;
use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_ecs::prelude::*;
@@ -255,11 +256,11 @@ fn is_solid_face(
if direction == Direction::Up {
return true;
}
- let registry_block = azalea_registry::Block::from(block_state);
+ let registry_block = BlockKind::from(block_state);
if matches!(
registry_block,
// frosted ice is from frost walker
- azalea_registry::Block::Ice | azalea_registry::Block::FrostedIce
+ BlockKind::Ice | BlockKind::FrostedIce
) {
return false;
}
diff --git a/azalea-physics/src/lib.rs b/azalea-physics/src/lib.rs
index b993a7b5..663c60db 100644
--- a/azalea-physics/src/lib.rs
+++ b/azalea-physics/src/lib.rs
@@ -20,7 +20,7 @@ use azalea_entity::{
LookDirection, OnClimbable, Physics, Pose, Position, dimensions::EntityDimensions,
metadata::Sprinting, move_relative,
};
-use azalea_registry::{Block, EntityKind, MobEffect};
+use azalea_registry::builtin::{BlockKind, EntityKind, MobEffect};
use azalea_world::{Instance, InstanceContainer, InstanceName};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
@@ -296,10 +296,10 @@ fn handle_entity_inside_block(
block_pos: BlockPos,
physics: &mut Physics,
) {
- let registry_block = azalea_registry::Block::from(block);
+ let registry_block = BlockKind::from(block);
#[allow(clippy::single_match)]
match registry_block {
- azalea_registry::Block::BubbleColumn => {
+ BlockKind::BubbleColumn => {
let block_above = world.get_block_state(block_pos.up(1)).unwrap_or_default();
let is_block_above_empty =
block_above.is_collision_shape_empty() && FluidState::from(block_above).is_empty();
@@ -417,14 +417,14 @@ fn handle_relative_friction_and_calculate_movement(ctx: &mut MoveCtx, block_fric
// Vec3(var3.x, 0.2D, var3.z); }
if ctx.physics.horizontal_collision || *ctx.jumping {
- let block_at_feet: Block = ctx
+ let block_at_feet: BlockKind = ctx
.world
.chunks
.get_block_state(BlockPos::from(*ctx.position))
.unwrap_or_default()
.into();
- if *ctx.on_climbable || block_at_feet == Block::PowderSnow {
+ if *ctx.on_climbable || block_at_feet == BlockKind::PowderSnow {
ctx.physics.velocity.y = 0.2;
}
}
@@ -454,12 +454,12 @@ fn handle_on_climbable(
// sneaking on ladders/vines
if y < 0.0
&& pose == Some(Pose::Crouching)
- && azalea_registry::Block::from(
+ && BlockKind::from(
world
.chunks
.get_block_state(position.into())
.unwrap_or_default(),
- ) != azalea_registry::Block::Scaffolding
+ ) != BlockKind::Scaffolding
{
y = 0.;
}