diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-07-15 04:39:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-15 04:39:43 -0500 |
| commit | cde7e35046b726b07bf3e067c080b85a12b2fd74 (patch) | |
| tree | 9d517911cbaf14f007958a92392101f24ec14118 /azalea-entity | |
| parent | 148f20381750be3e2c38a6bdaf8d339113da1b39 (diff) | |
| download | azalea-drasl-cde7e35046b726b07bf3e067c080b85a12b2fd74.tar.xz | |
Attacking (#96)
* add Client::attack
* partially implement attack cooldowns
* attack speed modifiers
* don't care clippy
---------
Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea-entity')
| -rw-r--r-- | azalea-entity/src/attributes.rs | 19 | ||||
| -rw-r--r-- | azalea-entity/src/lib.rs | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/azalea-entity/src/attributes.rs b/azalea-entity/src/attributes.rs index 97b890dc..18bbc348 100644 --- a/azalea-entity/src/attributes.rs +++ b/azalea-entity/src/attributes.rs @@ -13,6 +13,7 @@ use uuid::{uuid, Uuid}; #[derive(Clone, Debug, Component)] pub struct Attributes { pub speed: AttributeInstance, + pub attack_speed: AttributeInstance, } #[derive(Clone, Debug)] @@ -92,6 +93,24 @@ pub fn sprinting_modifier() -> AttributeModifier { } } +pub static BASE_ATTACK_SPEED_UUID: Uuid = uuid!("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); +pub fn weapon_attack_speed_modifier(amount: f64) -> AttributeModifier { + AttributeModifier { + uuid: BASE_ATTACK_SPEED_UUID, + name: "Weapon modifier".to_string(), + amount, + operation: AttributeModifierOperation::Addition, + } +} +pub fn tool_attack_speed_modifier(amount: f64) -> AttributeModifier { + AttributeModifier { + uuid: BASE_ATTACK_SPEED_UUID, + name: "Tool modifier".to_string(), + amount, + operation: AttributeModifierOperation::Addition, + } +} + impl McBufReadable for AttributeModifier { fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, BufReadError> { let uuid = Uuid::read_from(buf)?; diff --git a/azalea-entity/src/lib.rs b/azalea-entity/src/lib.rs index 53e8bfdb..76c5220a 100644 --- a/azalea-entity/src/lib.rs +++ b/azalea-entity/src/lib.rs @@ -344,6 +344,7 @@ impl EntityBundle { // TODO: do the correct defaults for everything, some // entities have different defaults speed: AttributeInstance::new(0.1), + attack_speed: AttributeInstance::new(4.0), }, jumping: Jumping(false), |
