diff options
| author | mat <git@matdoes.dev> | 2025-09-20 20:35:16 -1200 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-09-20 20:35:16 -1200 |
| commit | 585b51e91a5335eae37bc5af7c0111bb2092b156 (patch) | |
| tree | c1559014df9db20dd625d9fe972d4e9f88317008 /azalea-entity/src | |
| parent | db793448ff8e656ad80859835edc3b89cb547dd2 (diff) | |
| download | azalea-drasl-585b51e91a5335eae37bc5af7c0111bb2092b156.tar.xz | |
more accurate mining and impl PartialEq for packets
Diffstat (limited to 'azalea-entity/src')
| -rw-r--r-- | azalea-entity/src/attributes.rs | 4 | ||||
| -rw-r--r-- | azalea-entity/src/data.rs | 18 | ||||
| -rw-r--r-- | azalea-entity/src/mining.rs | 8 | ||||
| -rw-r--r-- | azalea-entity/src/particle.rs | 20 |
4 files changed, 25 insertions, 25 deletions
diff --git a/azalea-entity/src/attributes.rs b/azalea-entity/src/attributes.rs index 021fcd56..75423746 100644 --- a/azalea-entity/src/attributes.rs +++ b/azalea-entity/src/attributes.rs @@ -78,14 +78,14 @@ impl AttributeInstance { } } -#[derive(Clone, Debug, AzBuf)] +#[derive(Clone, Debug, AzBuf, PartialEq)] pub struct AttributeModifier { pub id: ResourceLocation, pub amount: f64, pub operation: AttributeModifierOperation, } -#[derive(Clone, Debug, Copy, AzBuf)] +#[derive(Clone, Debug, Copy, AzBuf, PartialEq)] pub enum AttributeModifierOperation { AddValue, AddMultipliedBase, diff --git a/azalea-entity/src/data.rs b/azalea-entity/src/data.rs index 35e8b4c5..d9d2a985 100644 --- a/azalea-entity/src/data.rs +++ b/azalea-entity/src/data.rs @@ -16,10 +16,10 @@ use uuid::Uuid; use crate::particle::Particle; -#[derive(Clone, Debug, Deref)] +#[derive(Clone, Debug, Deref, PartialEq)] pub struct EntityMetadataItems(pub Vec<EntityDataItem>); -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct EntityDataItem { // we can't identify what the index is for here because we don't know the // entity type @@ -55,7 +55,7 @@ impl AzaleaWrite for EntityMetadataItems { // Note: This enum is partially generated and parsed by // codegen/lib/code/entity.py -#[derive(Clone, Debug, EnumAsInner, AzBuf)] +#[derive(Clone, Debug, EnumAsInner, AzBuf, PartialEq)] pub enum EntityDataValue { Byte(u8), Int(#[var] i32), @@ -96,10 +96,10 @@ pub enum EntityDataValue { Quaternion(Quaternion), } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct OptionalUnsignedInt(pub Option<u32>); -#[derive(Clone, Debug, AzBuf)] +#[derive(Clone, Debug, AzBuf, PartialEq)] pub struct Quaternion { pub x: f32, pub y: f32, @@ -109,7 +109,7 @@ pub struct Quaternion { // mojang just calls this ArmadilloState but i added "Kind" since otherwise it // collides with a name in metadata.rs -#[derive(Clone, Debug, Copy, Default, AzBuf)] +#[derive(Clone, Debug, Copy, Default, AzBuf, PartialEq)] pub enum ArmadilloStateKind { #[default] Idle, @@ -137,7 +137,7 @@ impl AzaleaWrite for OptionalUnsignedInt { } /// A set of x, y, and z rotations. This is used for armor stands. -#[derive(Clone, Debug, AzBuf, Default)] +#[derive(Clone, Debug, AzBuf, Default, PartialEq)] pub struct Rotations { pub x: f32, pub y: f32, @@ -167,7 +167,7 @@ pub enum Pose { Inhaling, } -#[derive(Debug, Clone, AzBuf)] +#[derive(Debug, Clone, AzBuf, PartialEq)] pub struct VillagerData { pub kind: azalea_registry::VillagerKind, pub profession: azalea_registry::VillagerProfession, @@ -175,7 +175,7 @@ pub struct VillagerData { pub level: u32, } -#[derive(Debug, Copy, Clone, AzBuf, Default)] +#[derive(Debug, Copy, Clone, AzBuf, Default, PartialEq)] pub enum SnifferStateKind { #[default] Idling, diff --git a/azalea-entity/src/mining.rs b/azalea-entity/src/mining.rs index 8b572935..ea521a9a 100644 --- a/azalea-entity/src/mining.rs +++ b/azalea-entity/src/mining.rs @@ -25,20 +25,20 @@ pub fn get_mine_progress( if destroy_time == -1. { return 0.; } - let divider = if has_correct_tool_for_drops(block, held_item) { + let divisor = if has_correct_tool_for_drops(block, held_item) { 30 } else { 100 }; - (destroy_speed( + let base_destroy_speed = destroy_speed( block.as_registry_block(), held_item, player_inventory, fluid_on_eyes, physics, - ) / destroy_time) - / divider as f32 + ); + (base_destroy_speed / destroy_time) / divisor as f32 } fn has_correct_tool_for_drops(block: &dyn BlockTrait, tool: registry::Item) -> bool { diff --git a/azalea-entity/src/particle.rs b/azalea-entity/src/particle.rs index 212d9668..a457bba2 100644 --- a/azalea-entity/src/particle.rs +++ b/azalea-entity/src/particle.rs @@ -9,7 +9,7 @@ use bevy_ecs::component::Component; // the order of this enum must be kept in sync with ParticleKind, otherwise // we get errors parsing particles. /// A [`ParticleKind`] with data potentially attached to it. -#[derive(Component, Clone, Debug, AzBuf)] +#[derive(Component, Clone, Debug, AzBuf, PartialEq)] pub enum Particle { AngryVillager, Block(BlockParticle), @@ -260,18 +260,18 @@ impl Default for Particle { } } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct BlockParticle { pub block_state: BlockState, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct DustParticle { pub color: RgbColor, /// The scale, will be clamped between 0.01 and 4. pub scale: f32, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct DustColorTransitionParticle { pub from: RgbColor, pub to: RgbColor, @@ -279,24 +279,24 @@ pub struct DustColorTransitionParticle { pub scale: f32, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct ColorParticle { pub color: RgbColor, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct ItemParticle { pub item: ItemStack, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct VibrationParticle { pub position: PositionSource, #[var] pub ticks: u32, } -#[derive(Debug, Clone, AzBuf)] +#[derive(Debug, Clone, AzBuf, PartialEq)] pub enum PositionSource { Block(BlockPos), Entity { @@ -312,12 +312,12 @@ impl Default for PositionSource { } } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct SculkChargeParticle { pub roll: f32, } -#[derive(Debug, Clone, AzBuf, Default)] +#[derive(Debug, Clone, AzBuf, Default, PartialEq)] pub struct ShriekParticle { #[var] pub delay: i32, // The time in ticks before the particle is displayed |
