fix: use the correct health for entities
This commit is contained in:
1 parent
1b4b6121eb
commit
6889399e65
3 files changed
+7
-6
No files matched your search
@@ -43,7 +43,7 @@ pub fn read_data(id: DataComponent, data: &NbtTag) -> Option<Box<dyn DataCompone
|
|||||||
MaxStackSize => Some(MaxStackSizeImpl::read_data(data)?.to_dyn()),
|
MaxStackSize => Some(MaxStackSizeImpl::read_data(data)?.to_dyn()),
|
||||||
Enchantments => Some(EnchantmentsImpl::read_data(data)?.to_dyn()),
|
Enchantments => Some(EnchantmentsImpl::read_data(data)?.to_dyn()),
|
||||||
Damage => Some(DamageImpl::read_data(data)?.to_dyn()),
|
Damage => Some(DamageImpl::read_data(data)?.to_dyn()),
|
||||||
_ => todo!(),
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Also Pumpkin\pumpkin-protocol\src\codec\data_component.rs
|
// Also Pumpkin\pumpkin-protocol\src\codec\data_component.rs
|
||||||
|
|||||||
@@ -96,11 +96,12 @@ impl LivingEntity {
|
|||||||
|
|
||||||
// TODO: Extract default MOVEMENT_SPEED Entity Attribute
|
// TODO: Extract default MOVEMENT_SPEED Entity Attribute
|
||||||
let default_movement_speed = 0.25;
|
let default_movement_speed = 0.25;
|
||||||
|
let health = entity.entity_type.max_health.unwrap_or(20.0);
|
||||||
Self {
|
Self {
|
||||||
entity,
|
entity,
|
||||||
hurt_cooldown: AtomicI32::new(0),
|
hurt_cooldown: AtomicI32::new(0),
|
||||||
last_damage_taken: AtomicCell::new(0.0),
|
last_damage_taken: AtomicCell::new(0.0),
|
||||||
health: AtomicCell::new(20.0),
|
health: AtomicCell::new(health),
|
||||||
fall_distance: AtomicCell::new(0.0),
|
fall_distance: AtomicCell::new(0.0),
|
||||||
death_time: AtomicU8::new(0),
|
death_time: AtomicU8::new(0),
|
||||||
dead: AtomicBool::new(false),
|
dead: AtomicBool::new(false),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use pumpkin_data::entity::{EntityType, MobCategory};
|
use pumpkin_data::entity::EntityType;
|
||||||
use pumpkin_util::math::vector3::Vector3;
|
use pumpkin_util::math::vector3::Vector3;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -28,10 +28,10 @@ pub async fn from_type(
|
|||||||
id if id == EntityType::END_CRYSTAL.id => Arc::new(EndCrystalEntity::new(entity)),
|
id if id == EntityType::END_CRYSTAL.id => Arc::new(EndCrystalEntity::new(entity)),
|
||||||
// Fallback Entity
|
// Fallback Entity
|
||||||
_ => {
|
_ => {
|
||||||
if entity_type.category == &MobCategory::MISC {
|
if entity_type.max_health.is_some() {
|
||||||
Arc::new(entity)
|
|
||||||
} else {
|
|
||||||
Arc::new(LivingEntity::new(entity))
|
Arc::new(LivingEntity::new(entity))
|
||||||
|
} else {
|
||||||
|
Arc::new(entity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user