Merge pull request #2184 from kacpherek/fix/elytra-glide-rules

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `LivingEntity.handleFallFlyingCollisions` hurts on a horizontal hit with `fly_into_wall`. Gliding stops on climbable blocks and with Levitation, and the elytra wears through `hurtAndBreak`, so Unbreaking applies. Your update (a4407a4bc: Unbreaking for guests, wall hits kept on the server copy) checked too: clippy clean, the 79 harnesses `parity.py --changed-files` picks pass apart from the campfire cases in `dispenser` and `block_removal` that #2316 fixes, and lan `elytra` passes in both modes. Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-26 20:24:21 +01:00
committed by GitHub
3 changed files with 95 additions and 14 deletions
+10 -6
View File
@@ -4492,12 +4492,6 @@ impl Game<'_> {
let events = std::mem::take(&mut player.events);
let spin_hit = player.spin_hit.take();
let glider_wear = std::mem::take(&mut player.glider_wear);
if glider_wear > 0
&& !self.creative
&& let Some(elytra) = self.armor[1].as_mut()
{
elytra.damage += glider_wear;
}
let feet = [player.position.x, player.position.y, player.position.z];
let player_velocity = [player.velocity.x, player.velocity.y, player.velocity.z];
self.previous_eye = self.eye;
@@ -4508,6 +4502,16 @@ impl Game<'_> {
};
self.eye += (camera_eye.unwrap_or(eye_height) - self.eye) * 0.5;
let crouching = player.pose == horizon_client::pose::Pose::Crouching;
// `ItemStack.hurtAndBreak` for the glide: Unbreaking can save the wear.
if glider_wear > 0
&& !self.creative
&& let Some(stack) = self.armor[1].clone()
{
let loss = self.durability_loss(&stack, glider_wear);
if let Some(elytra) = self.armor[1].as_mut() {
elytra.damage += loss;
}
}
self.tick_avatar(before, riding);
self.end_spin_attack(spin_hit);
self.record_combat(&events);
@@ -2395,9 +2395,13 @@ impl Game<'_> {
}
if (next / 10) % 2 == 0
&& !creative
&& let Some(elytra) = game.armor[1].as_mut()
&& let Some(stack) = game.armor[1].clone()
{
elytra.damage += 1;
// `ItemStack.hurtAndBreak`: Unbreaking can save the wear.
let loss = game.durability_loss(&stack, 1);
if let Some(elytra) = game.armor[1].as_mut() {
elytra.damage += loss;
}
}
let ctx = game.player_context(None);
game.post_game_event("minecraft:elytra_glide", at, ctx);
+79 -6
View File
@@ -50,6 +50,8 @@ pub struct MotionResources {
pub attributes: Arc<Catalog>,
pub blocks: BoundMovementProperties,
pub climbable: BTreeSet<String>,
/// `BlockTags.CAN_GLIDE_THROUGH`: climbable blocks a gliding player passes.
pub glide_through: BTreeSet<String>,
pub fall_reset: BTreeSet<String>,
pub landing: BlockLandingRegistry,
pub health: crate::health::HealthResources,
@@ -108,6 +110,7 @@ impl MotionResources {
suppresses_bounce: tag("minecraft:suppresses_bounce")?,
})?,
climbable: tag("minecraft:climbable")?,
glide_through: tag("minecraft:can_glide_through")?,
fall_reset: tag("minecraft:fall_damage_resetting")?,
})
}
@@ -308,6 +311,9 @@ pub struct PlayerMotion {
/// it travels on the server: `isLocalInstanceAuthoritative` is false, so
/// its moves check no fall damage.
pub server_copy: bool,
/// The span of `events` a wall hit on the server's copy pushed (sound and
/// damage): `server_travel` keeps them while it drops the simulated moves.
pub wall_hit_events: Option<std::ops::Range<usize>>,
/// A client's copy of its own player (`Level.isClientSide`): only the
/// server hurts it (`Entity.hurt` does nothing on a client) and ticks its
/// food (`ServerPlayer.tick`). Its hurt animation comes from the server.
@@ -477,6 +483,7 @@ impl PlayerMotion {
freeze_immune: false,
old_position: position,
server_copy: false,
wall_hit_events: None,
client_side: false,
block_effects: true,
powder_snow_entered: Vec::new(),
@@ -765,6 +772,10 @@ impl MotionWorld<'_, '_, '_> {
.state(self.block(p))
.ok_or("missing scene state")?
.name;
// A gliding player passes through vines (`CAN_GLIDE_THROUGH`).
if self.player.fall_flying && self.resources.glide_through.contains(name) {
return Ok(false);
}
let climbable = self.resources.climbable.contains(name);
if climbable {
self.player.last_climbable = Some(p);
@@ -834,9 +845,17 @@ impl MotionWorld<'_, '_, '_> {
let can_glide = self.player.glider
&& !self.player.ground.on_ground
&& !self.player.flying
&& self.player.status.levitation.is_none()
&& !self.player.fluids.was_touching_water
&& !self.player.is_in_lava();
if jumping && !toggled && !was_jumping && !self.player.fall_flying && can_glide {
// LocalPlayer.aiStep: `!onClimbable()` before tryToStartFallFlying.
if jumping
&& !toggled
&& !was_jumping
&& !self.climbable()?
&& !self.player.fall_flying
&& can_glide
{
self.player.fall_flying = true;
}
// LivingEntity.tick fallFlyTicks, then updateFallFlying.
@@ -848,8 +867,11 @@ impl MotionWorld<'_, '_, '_> {
self.player.fall_distance = 1.0;
}
self.player.fall_fly_ticks += 1;
// canGlide alone: water and lava don't end a glide.
let still = self.player.glider && !self.player.ground.on_ground && !self.player.flying;
// canGlide alone: water and lava don't end a glide, levitation does.
let still = self.player.glider
&& !self.player.ground.on_ground
&& !self.player.flying
&& self.player.status.levitation.is_none();
if !still {
self.player.glide_ending = true;
} else if (self.player.fall_fly_ticks + 1) % 10 == 0
@@ -1021,7 +1043,14 @@ impl MotionWorld<'_, '_, '_> {
{
horizon_world::living_fluid::travel_in_fluid(self, input)?;
} else if self.player.fall_flying {
self.travel_fall_flying()?;
// LivingEntity.travelFallFlying: on a climbable the glide ends and
// the player moves like in the air.
if self.climbable()? {
self.travel_in_air(input)?;
self.player.fall_flying = false;
} else {
self.travel_fall_flying()?;
}
} else {
self.travel_in_air(input)?;
}
@@ -1048,7 +1077,14 @@ impl MotionWorld<'_, '_, '_> {
p.server_copy = false;
(p.position, p.ground, p.collision) = (position, ground, collision);
(p.history, p.fall_distance, p.steps) = (history, fall_distance, steps);
// The wall hit is the server's own: its sound and damage events stay.
let kept: Vec<_> = p
.wall_hit_events
.take()
.map(|span| p.events.drain(span).collect())
.unwrap_or_default();
p.events.truncate(events);
p.events.extend(kept);
travelled
}
/// `LivingEntity.checkAutoSpinAttack`: the first living entity in the
@@ -1536,7 +1572,7 @@ impl MotionWorld<'_, '_, '_> {
let lean = pitch;
let look_h = (look.x * look.x + look.z * look.z).sqrt();
let move_h = (v.x * v.x + v.z * v.z).sqrt();
let gravity = 0.08;
let gravity = living_motion::effective_gravity(self)?;
let lift = f64::from(lean.cos()).powi(2);
let mut m = Vec3::new(v.x, v.y + gravity * (-1.0 + lift * 0.75), v.z);
if m.y < 0.0 && look_h > 0.0 {
@@ -1564,7 +1600,44 @@ impl MotionWorld<'_, '_, '_> {
}
self.player.velocity = Vec3::new(m.x * 0.99, m.y * 0.98, m.z * 0.99);
let movement = self.player.velocity;
self.move_self(movement)
self.move_self(movement)?;
// LivingEntity.handleFallFlyingCollisions: only the server hurts.
if !self.player.client_side && self.player.collision.horizontal {
let new_h = {
let v = self.player.velocity;
(v.x * v.x + v.z * v.z).sqrt()
};
let dmg = ((move_h - new_h) * 10.0 - 3.0) as f32;
if dmg > 0.0 {
let first = self.player.events.len();
// getFallDamageSound((int) dmg)
let sound = if dmg as i32 > 4 {
crate::landing::SceneSound::BigFall
} else {
crate::landing::SceneSound::SmallFall
};
self.player
.events
.push(MotionEvent::Fall(crate::landing::FallEvent::Sound {
sound,
position: None,
volume: 1.0,
pitch: 1.0,
}));
let id = self
.resources
.health
.damage
.id("minecraft:fly_into_wall")
.ok_or("missing fly_into_wall damage type")?;
let rules = self.scene.health_rules;
self.player.hurt(&self.resources.health, rules, id, dmg)?;
if self.player.server_copy {
self.player.wall_hit_events = Some(first..self.player.events.len());
}
}
}
Ok(())
}
/// `LocalPlayer.move`: the move, then `updateAutoJump` with the float
/// horizontal displacement.