feat: implement all missing entities
This commit is contained in:
1 parent
a36240dd40
commit
6f2c3cd5e3
76 files changed
+3838
-131
No files matched your search
@@ -0,0 +1,53 @@
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use pumpkin_data::entity::EntityType;
|
||||
|
||||
use crate::entity::{
|
||||
Entity, NBTStorage,
|
||||
ai::goal::{
|
||||
look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal, swim::SwimGoal,
|
||||
wander_around::WanderAroundGoal,
|
||||
},
|
||||
mob::{Mob, MobEntity},
|
||||
};
|
||||
|
||||
/// Represents a Mule, a passive mob created by breeding a horse and a donkey.
|
||||
///
|
||||
/// Wiki: <https://minecraft.wiki/w/Mule>
|
||||
pub struct MuleEntity {
|
||||
pub mob_entity: MobEntity,
|
||||
}
|
||||
|
||||
impl MuleEntity {
|
||||
pub async fn new(entity: Entity) -> Arc<Self> {
|
||||
let mob_entity = MobEntity::new(entity);
|
||||
let mule = Self { mob_entity };
|
||||
let mob_arc = Arc::new(mule);
|
||||
let mob_weak: Weak<dyn Mob> = {
|
||||
let mob_arc: Arc<dyn Mob> = mob_arc.clone();
|
||||
Arc::downgrade(&mob_arc)
|
||||
};
|
||||
|
||||
{
|
||||
let mut goal_selector = mob_arc.mob_entity.goals_selector.lock().await;
|
||||
|
||||
goal_selector.add_goal(0, Box::new(SwimGoal::default()));
|
||||
goal_selector.add_goal(1, Box::new(WanderAroundGoal::new(0.7)));
|
||||
goal_selector.add_goal(
|
||||
2,
|
||||
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 6.0),
|
||||
);
|
||||
goal_selector.add_goal(3, Box::new(RandomLookAroundGoal::default()));
|
||||
};
|
||||
|
||||
mob_arc
|
||||
}
|
||||
}
|
||||
|
||||
impl NBTStorage for MuleEntity {}
|
||||
|
||||
impl Mob for MuleEntity {
|
||||
fn get_mob_entity(&self) -> &MobEntity {
|
||||
&self.mob_entity
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user