From 724f42355f8884824f46189c64525e24ba02a0a4 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:37:21 +0200 Subject: [PATCH] Fix #1255: server players climbing down a ladder take no fall damage Player's MoveSimulationType is AUTHORITATIVE_SIDE_AND_SERVER, so a ServerPlayer travels on the server too, and every tick on a ladder or vine LivingEntity.handleOnClimbable resets its fall distance. Horizon's server only replayed the client's moves (ServerPlayer.doCheckFallDamage), so the fall distance grew all the way down a ladder and hurt the player where it landed: LAN guests, dedicated-server players and, while single player ran on the server thread (#1114), the single player. lan_e2e ladder: the guest slides down ten blocks of ladder and lands with full health (before: 20 -> 13). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/lan_actions.rs | 7 ++++ crates/horizon-client/src/motion.rs | 3 +- tools/lan_e2e.py | 34 +++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/horizon-client/src/game/lan_actions.rs b/crates/horizon-client/src/game/lan_actions.rs index bc224da9e..7028c2eca 100644 --- a/crates/horizon-client/src/game/lan_actions.rs +++ b/crates/horizon-client/src/game/lan_actions.rs @@ -1730,6 +1730,13 @@ impl Game<'_> { break; } } + // A ServerPlayer travels on the server too + // (MoveSimulationType.AUTHORITATIVE_SIDE_AND_SERVER), so every tick + // on a ladder or vine LivingEntity.handleOnClimbable resets its fall + // distance: climbing down doesn't hurt where it lands (#1255). + if w.climbable().unwrap_or(false) { + w.player.fall_distance = 0.0; + } let _ = w.tick_environment_damage(); let _ = w.apply_fire_contact(); let _ = w.server_hazards_tick(in_wall); diff --git a/crates/horizon-client/src/motion.rs b/crates/horizon-client/src/motion.rs index b1088188c..1920026b9 100644 --- a/crates/horizon-client/src/motion.rs +++ b/crates/horizon-client/src/motion.rs @@ -716,7 +716,8 @@ impl MotionWorld<'_, '_, '_> { supporting_block: self.player.ground.supporting_block, } } - fn climbable(&mut self) -> Result { + /// `LivingEntity.onClimbable` at the player's feet (it remembers the block). + pub fn climbable(&mut self) -> Result { if self.player.spectator { return Ok(false); } diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 9b883b163..15129e6b6 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -114,6 +114,8 @@ address. The script then checks, from both sides, what a guest's game used to ge server's game time after the guest's game stalls for a few seconds (#848). - growth: far from the host, the chunks around the guest tick (#890): water placed there flows and wheat on farmland grows (random ticks), however the host runs its world. +- ladder: the guest climbs down ten blocks of ladder and lands unhurt: the server resets its fall + distance on a ladder every tick, as LivingEntity.handleOnClimbable does (#1255). - flight: a player in creative double-taps jump and flies, stays up, and stops flying in survival: the guest, and on the server thread the host's window too, take what may fly from the server's abilities (ClientPacketListener.handlePlayerAbilities). @@ -155,7 +157,7 @@ ROOT = Path(__file__).resolve().parents[1] GUEST_NAME = 'Guest' # The host plays single player on its server thread (--server-thread). SERVER_THREAD = False -CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight'] +CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'flight', 'ladder'] class Game: @@ -2279,6 +2281,34 @@ def check_flight(host, guest, out): return seen + +def check_ladder(host, guest, out): + """#1255: climbing down a ladder doesn't hurt where the guest lands.""" + x, y, z = (int(v // 1) for v in pos_of(guest)) + lx, lz = x + 6, z + guest('command', command='gamemode survival') + guest('command', command=f'fill {lx - 2} {y} {lz - 2} {lx + 2} {y + 12} {lz + 2} minecraft:air') + guest('command', command=f'fill {lx - 2} {y - 1} {lz - 2} {lx + 2} {y - 1} {lz + 2} minecraft:stone') + guest('command', command=f'fill {lx} {y} {lz + 1} {lx} {y + 10} {lz + 1} minecraft:stone') + guest('command', command=f'fill {lx} {y} {lz} {lx} {y + 10} {lz} minecraft:ladder[facing=north]') + guest.wait(10) + try: + before = remote(guest)['health'] + # No input on a ladder: the guest slides down at 0.15 a tick (LivingEntity.handleOnClimbable). + guest('command', command=f'tp @s {lx + 0.5} {y + 10} {lz + 0.4} 0 0') + for _ in range(40): + guest.wait(5) + if pos_of(guest)[1] < y + 0.01: + break + guest.wait(20) + landed, after = pos_of(guest), remote(guest)['health'] + assert landed[1] < y + 0.01, f'the guest stayed on the ladder at {landed}' + assert after >= before, f'climbing down ten blocks of ladder took the guest from {before} to {after} health' + return {'landed': landed, 'health': after} + finally: + guest('command', command=f'fill {lx} {y} {lz} {lx} {y + 10} {lz + 1} minecraft:air') + guest('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}') + def check_growth(host, guest, out): """Block ticks near a guest 1000 blocks from the host: only the guest's tickets tick them.""" x0, y0, z0 = pos_of(guest) @@ -2591,7 +2621,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour, 'name 'xp': check_xp, 'objects': check_objects, 'projectiles': check_projectiles, 'blast': check_blast, 'light': check_light, 'plates': check_plates, 'swings': check_swings, 'cracks': check_cracks, - 'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict} + 'time': check_time, 'growth': check_growth, 'flight': check_flight, 'fireball': check_fireball, 'deflect': check_deflect, 'barter': check_barter, 'worn': check_worn, 'kills': check_kills, 'arrows': check_arrows, 'predict': check_predict, 'ladder': check_ladder} def run(ctl, out, resources, checks):