diff --git a/crates/horizon-client/src/game/lan.rs b/crates/horizon-client/src/game/lan.rs index e32f1e9d5..3ef5473cc 100644 --- a/crates/horizon-client/src/game/lan.rs +++ b/crates/horizon-client/src/game/lan.rs @@ -534,6 +534,14 @@ fn mob_meta( meta.push((19, serializer::BOOLEAN, Value::Bool(true))); } } + // HappyGhast.STAYS_STILL (after AgeableMob's two and IS_LEASH_HOLDER), + // set while `serverStillTimeout > 0` (`syncStayStillFlag`). + "minecraft:happy_ghast" => { + if horizon_client::mobs::happy_ghast::on_still_timeout(m) { + meta.push((19, serializer::BOOLEAN, Value::Bool(true))); + } + defaults.push((19, serializer::BOOLEAN, Value::Bool(false))); + } // Villager.DATA_VILLAGER_DATA and ZombieVillager's (after Zombie's three). "minecraft:villager" | "minecraft:zombie_villager" => { use horizon_client::mobs::render::{PROFESSIONS, VILLAGER_TYPES}; @@ -1317,6 +1325,9 @@ impl Game<'_> { &mut e.meta, &mut e.defaults, ); + // HappyGhast.aiStep: requiresPrecisePosition while on a still timeout. + e.precise = m.species() == horizon_client::mobs::Species::HappyGhast + && horizon_client::mobs::happy_ghast::on_still_timeout(m); mob_freeze_meta(m, &mut e.meta, &mut e.defaults); mob_equipment(m, hub, &mut e.equipment); self.mob_attributes(m, &mut e.attributes); diff --git a/crates/horizon-client/src/game/remote.rs b/crates/horizon-client/src/game/remote.rs index c28c78a0f..6f51baa65 100644 --- a/crates/horizon-client/src/game/remote.rs +++ b/crates/horizon-client/src/game/remote.rs @@ -160,6 +160,9 @@ pub(super) struct Remote { stepped: HashMap, /// `LivingEntity.lerpHeadTo`: the head yaw and the ticks left to reach it. head_lerps: HashMap, + /// The happy ghast the player just got off, until the server's teleport + /// puts the player on top of it (`place_ghast_under`). + pub(super) ghast_dismount: Option, /// Item entities waiting for their item data: where they are and their /// motion. pending_items: HashMap, @@ -478,6 +481,7 @@ impl Game<'_> { lerps: HashMap::new(), stepped: HashMap::new(), head_lerps: HashMap::new(), + ghast_dismount: None, pending_items: HashMap::new(), health: (20.0, 20, 5.0), flash_on_set_health: false, @@ -3351,6 +3355,37 @@ impl Game<'_> { p.health.food.saturation = saturation; } } + /// `ServerPlayer.dismountTo` lands a rider at the ghast's own (x, maxY, z) + /// (`HappyGhast.getDismountLocationForPassenger`). A vanilla client + /// simulates the ghast it rides, so its copy is where the server has it; + /// this window's copy trails the server's by the stepped interpolation and + /// would rise into the rider's feet, which lets the rider fall through. + /// Put the copy under the landing spot. + fn place_ghast_under(&mut self, id: u32, spot: Vec3) { + let Some(m) = self + .mobs + .iter_mut() + .find(|m| m.id == id && m.species() == horizon_client::mobs::Species::HappyGhast) + else { + return; + }; + let at = Vec3::new(spot.x, spot.y - f64::from(m.height()), spot.z); + // Only a teleport that is that dismount: right above the ghast. + if (at.x - m.position.x).powi(2) + (at.z - m.position.z).powi(2) > 25.0 + || (at.y - m.position.y).abs() > 5.0 + { + return; + } + m.position = at; + m.previous = at; + if let Some(handler) = self + .remote + .as_mut() + .and_then(|r| r.stepped.get_mut(&(id as i32))) + { + handler.cancel(); + } + } /// ClientPacketListener.handleMovePlayer. fn remote_teleport(&mut self, p: &play::PlayerPosition) -> Result<()> { use play::relative as rel; @@ -3410,6 +3445,9 @@ impl Game<'_> { self.previous_position = position; self.yaw = yaw; self.pitch = pitch; + if let Some(id) = self.remote.as_mut().and_then(|r| r.ghast_dismount.take()) { + self.place_ghast_under(id, position); + } if let Some(r) = self.remote.as_mut() { // handleMovePlayer does not change LocalPlayer.sendPosition's // baseline: the next tick must still report the corrected state. diff --git a/crates/horizon-client/src/game/remote_mob_data.rs b/crates/horizon-client/src/game/remote_mob_data.rs index 55ba7f997..b1dd94c69 100644 --- a/crates/horizon-client/src/game/remote_mob_data.rs +++ b/crates/horizon-client/src/game/remote_mob_data.rs @@ -212,6 +212,10 @@ fn apply(m: &mut Mob, values: &[(u8, i32, Value)], builtin: &Builtin, local_enti // Pillager.IS_CHARGING_CROSSBOW: the charge pose (Raider's // IS_CELEBRATING takes 16). (Species::Pillager, 17, Value::Bool(charging)) => m.extra.flag = *charging, + // HappyGhast.STAYS_STILL (after AgeableMob's two and IS_LEASH_HOLDER): + // `isOnStillTimeout` on a client, which keeps the ghast solid to + // the player (`canBeCollidedWith`). + (Species::HappyGhast, 19, Value::Bool(still)) => m.extra.counter = i32::from(*still), // SpellcasterIllager.DATA_SPELL_CASTING_ID: the casting pose. (Species::Evoker | Species::Illusioner, 17, Value::Byte(spell)) => { m.extra.variant2 = (*spell).max(0) as u8; diff --git a/crates/horizon-client/src/game/remote_vehicles.rs b/crates/horizon-client/src/game/remote_vehicles.rs index 877ed66e6..c9cbf1159 100644 --- a/crates/horizon-client/src/game/remote_vehicles.rs +++ b/crates/horizon-client/src/game/remote_vehicles.rs @@ -128,6 +128,17 @@ impl Game<'_> { } else if self.riding == Some(vehicle_id) { // The server takes the player out, then teleports it. self.riding = None; + // HappyGhast.removePassenger: a still timeout of 10 (the server's + // STAYS_STILL confirms it), and the rider lands on top of the ghast + // (`place_ghast_under`). + if let Some(m) = self.mobs.iter_mut().find(|m| { + m.id == vehicle_id && m.species() == horizon_client::mobs::Species::HappyGhast + }) { + m.extra.counter = 10; + if let Some(r) = self.remote.as_mut() { + r.ghast_dismount = Some(vehicle_id); + } + } } }