diff --git a/crates/horizon-client/examples/mob_ai_probe.rs b/crates/horizon-client/examples/mob_ai_probe.rs index 5762abcd6..d6696ea4c 100644 --- a/crates/horizon-client/examples/mob_ai_probe.rs +++ b/crates/horizon-client/examples/mob_ai_probe.rs @@ -902,6 +902,10 @@ fn main() -> horizon_client::Result<()> { for flag in &spec.flags { match flag.as_str() { "persistent" => m.persistent = true, + "ridden" => { + m.extra.head = Some("minecraft:red_harness".into()); + m.rider = Some(horizon_client::mobs::equine::Rider::default()); + } "noai" => m.no_ai = true, // Warden.finalizeSpawn's own part. "digcooldown" | "emerge" => horizon_client::mobs::warden::finalize( diff --git a/crates/horizon-client/src/mobs/ai.rs b/crates/horizon-client/src/mobs/ai.rs index 7c0ef8c61..d97584a06 100644 --- a/crates/horizon-client/src/mobs/ai.rs +++ b/crates/horizon-client/src/mobs/ai.rs @@ -769,6 +769,8 @@ fn push_entities(m: &mut Mob, w: &MobWorld, events: &mut Vec) { && !(m.species() == Species::Creaking && !super::creaking::can_move(m)); let mut targets: Vec<(Who, Vec3)> = Vec::new(); if let Some(p) = &w.player + // Entity.push: passengers of the same vehicle never push each other. + && m.rider.is_none() && p.alive && !p.spectator && p.bounds.intersects(bounds) diff --git a/crates/horizon-client/src/mobs/equine.rs b/crates/horizon-client/src/mobs/equine.rs index 87d96a2e6..46d33b576 100644 --- a/crates/horizon-client/src/mobs/equine.rs +++ b/crates/horizon-client/src/mobs/equine.rs @@ -311,14 +311,14 @@ pub fn ridden_step(m: &mut Mob) { if super::nautilus::is_nautilus(m.species()) { return super::nautilus::ridden(m); } + if m.species() == Species::HappyGhast { + return super::happy_ghast::ridden(m); + } m.yaw = r.yaw; m.head_pitch = r.pitch * 0.5; m.body_yaw = r.yaw; m.head_yaw = r.yaw; m.ai.nav.stop(); - if m.species() == Species::HappyGhast { - return super::happy_ghast::ridden(m); - } if matches!(m.species(), Species::Pig | Species::Strider) { // Pig/Strider: always forward along the rider's look, at a fraction diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java index bac7fa4bd..55c0370f4 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaMobAiOracle.java @@ -553,6 +553,9 @@ public final class VanillaMobAiOracle { String v = kv.length > 1 ? kv[1] : ""; switch (kv[0]) { case "persistent" -> mob.setPersistenceRequired(); + case "ridden" -> mob.setItemSlot(net.minecraft.world.entity.EquipmentSlot.BODY, + new net.minecraft.world.item.ItemStack(BuiltInRegistries.ITEM.getValue( + net.minecraft.resources.Identifier.parse("minecraft:red_harness")))); case "noai" -> mob.setNoAi(true); case "profession" -> { Villager villager = (Villager) mob; @@ -641,6 +644,9 @@ public final class VanillaMobAiOracle { // Leads: to the player ("leashed") or to the n-th mob ("leashto=n"). for (int i = 0; i < s.mobs.size(); i++) { for (String flag : s.mobs.get(i).flags) { + if (flag.equals("ridden")) { + if (!player.startRiding(ENTS.get(i))) throw new IllegalStateException("Could not mount fixture"); + } if (flag.equals("leashed")) ((net.minecraft.world.entity.Leashable) ENTS.get(i)).setLeashedTo(player, true); else if (flag.startsWith("leashto=")) ((net.minecraft.world.entity.Leashable) ENTS.get(i)) .setLeashedTo(ENTS.get(Integer.parseInt(flag.substring(8))), true); diff --git a/tools/test_mob_ai_parity.py b/tools/test_mob_ai_parity.py index b87e0535a..a32ec2cf9 100644 --- a/tools/test_mob_ai_parity.py +++ b/tools/test_mob_ai_parity.py @@ -157,6 +157,11 @@ def scenarios(): # Happy ghasts float above the grass; ghastlings follow players and adults. add('happy_ghast_player', 200, ['player 6.5 -60 0.5', 'mob minecraft:happy_ghast 0.5 -55 0.5 0 81 persistent']) add('happy_ghast_alone', 200, ['mob minecraft:happy_ghast 0.5 -55 0.5 90 82 persistent']) + # The driver's seat overlaps the front of the ghast: it must not push its own rider. + # One tick isolates riding input and turning from later passenger repositioning. + for name, yaw in [('hover', 0), ('turn', 90)]: + add(f'happy_ghast_ridden_{name}', 1, ['player 0.5 -51.6 2.2', + f'mob minecraft:happy_ghast 0.5 -55 0.5 {yaw} 82 persistent ridden']) add('ghastling_player', 200, ['player 8.5 -60 0.5', 'mob minecraft:happy_ghast 0.5 -57 0.5 0 83 persistent baby']) add('ghastling_alone', 200, ['mob minecraft:happy_ghast 0.5 -57 0.5 0 84 persistent baby']) add('ghastling_adult', 200, ['mob minecraft:happy_ghast 10.5 -55 0.5 0 85 persistent',