Remove an endermite after 2400 ticks
This commit is contained in:
@@ -458,6 +458,9 @@ pub fn mob_to_nbt(m: &Mob, uuid: [i32; 4], raw: Option<&Tag>) -> Tag {
|
||||
map.insert("life_ticks".into(), Tag::Int(m.extra.egg_time));
|
||||
}
|
||||
}
|
||||
"minecraft:endermite" => {
|
||||
map.insert("Lifetime".into(), Tag::Int(m.extra.counter));
|
||||
}
|
||||
"minecraft:shulker" => {
|
||||
map.insert("AttachFace".into(), Tag::Byte(m.extra.variant3 as i8));
|
||||
map.insert("Peek".into(), Tag::Byte(m.extra.counter as i8));
|
||||
@@ -881,6 +884,9 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap<String, Arc<MobType>>, id: u32) -
|
||||
m.extra.counter2 = number(tag.get("StunTick")).unwrap_or(0) as i32;
|
||||
m.extra.anim_ticks = number(tag.get("RoarTick")).unwrap_or(0) as i32;
|
||||
}
|
||||
if m.species() == crate::mobs::Species::Endermite {
|
||||
m.extra.counter = number(tag.get("Lifetime")).unwrap_or(0) as i32;
|
||||
}
|
||||
if m.species() == crate::mobs::Species::Vex {
|
||||
if let Some(Tag::IntArray(v)) = tag.get("bound_pos")
|
||||
&& v.len() == 3
|
||||
|
||||
@@ -961,6 +961,16 @@ fn species_ai_step(m: &mut Mob, w: &MobWorld, events: &mut Vec<MobEvent>) {
|
||||
}
|
||||
match m.species() {
|
||||
Species::Enderman => super::enderman::ai_step(m, w, events),
|
||||
// Endermite.aiStep: `counter` is the life; an endermite not required
|
||||
// to persist is discarded at 2400.
|
||||
Species::Endermite => {
|
||||
if !m.persistent {
|
||||
m.extra.counter += 1;
|
||||
}
|
||||
if m.extra.counter >= 2400 {
|
||||
m.removed = true;
|
||||
}
|
||||
}
|
||||
Species::Wolf => super::tame::ai_step(m, w, events),
|
||||
Species::Cat => super::tame::cat_ai_step(m, events),
|
||||
Species::Blaze => super::nether::blaze_ai_step(m, events),
|
||||
|
||||
Reference in New Issue
Block a user