A server's player's client sets its body as in frame: look pitch, use slowdown, boots on powder snow

On a server (guests, and single player on the server thread) the window ticks
its player through tick_remote_level, which copied the yaw, the Respiration
level, the wings and FAST_LAVA but not the rest of what the in-frame tick sets
from the window's own state. Both now call Game::sync_player_body:

- the look pitch: Player.travel steers sprint-swimming up and down by it (#1303)
- the slowdown of an item in use, LocalPlayer.modifyInput (#1278)
- leather boots, PowderSnowBlock.canEntityWalkOnPowderSnow (#1296)
- freeze-immune wear, LivingEntity.canFreeze
- the Auto Jump option, LocalPlayer.sendPosition (#1279)

tools/lan_e2e.py gains a body check: each player walks while drawing a bow,
stands on powder snow with leather boots and without, and sprint-swims looking
down.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-23 23:00:42 +02:00
parent 287d7a7eb5
commit fa4ea80d32
3 changed files with 132 additions and 47 deletions
+50 -37
View File
@@ -1825,6 +1825,55 @@ impl Game<'_> {
.is_some_and(|i| i.glider && (i.max_damage == 0 || s.damage + 1 < i.max_damage))
})
}
/// What the window decides for its player's body every tick, in frame and
/// on a server alike: the look (Player.travel steers sprint-swimming by
/// the pitch), Auto Jump (LocalPlayer.sendPosition), the slowdown of an
/// item in use (LocalPlayer.modifyInput), the helmet's Respiration
/// (decreaseAirSupply), the wings, leather boots on powder snow
/// (PowderSnowBlock.canEntityWalkOnPowderSnow), freeze-immune wear
/// (LivingEntity.canFreeze) and the dimension's FAST_LAVA.
pub(crate) fn sync_player_body(&mut self) {
let glider = self.glider_worn();
let item_use_speed = self
.using
.and_then(|(slot, _)| {
if slot == shield::OFFHAND_SLOT {
self.offhand.as_ref()
} else {
self.inventory.get(slot)?.as_ref()
}
})
.and_then(|s| self.res.items().get(&s.item))
.map(|i| i.use_speed);
let respiration = self.armor[0]
.as_ref()
.map_or(0, |s| s.enchantment_level("minecraft:respiration") as i32);
let leather_boots = self.armor[3]
.as_ref()
.is_some_and(|s| &*s.item == "minecraft:leather_boots");
let immune = self
.res
.items()
.item_tags
.get("minecraft:freeze_immune_wearables");
let freeze_immune = self
.armor
.iter()
.flatten()
.any(|s| immune.is_some_and(|t| t.contains(&*s.item)));
let Some(player) = self.player.as_mut() else {
return;
};
player.yaw = self.yaw;
player.pitch = self.pitch;
player.auto_jump_enabled = self.settings.auto_jump;
player.item_use_speed = item_use_speed;
player.respiration = respiration;
player.glider = glider;
player.leather_boots = leather_boots;
player.freeze_immune = freeze_immune;
player.fluids.fast_lava = self.dim == Dim::Nether;
}
fn held_slot(&self) -> usize {
match self.hand {
Hand::Main => self.selected,
@@ -4035,7 +4084,7 @@ impl Game<'_> {
let riding = self.riding.is_some();
let ghast_collisions = self.happy_ghast_player_collisions();
let spin_targets = self.spin_targets();
let glider = self.glider_worn();
self.sync_player_body();
let Some(player) = self.player.as_mut() else {
// A dedicated server has no local player: the world still runs.
if self.options.dedicated.is_some() {
@@ -4067,46 +4116,10 @@ impl Game<'_> {
if !riding {
self.previous_position = player.position;
}
player.yaw = self.yaw;
let spectator = self.mode == horizon_client::command::args::GameMode::Spectator;
player.may_fly = self.creative || spectator;
// LocalPlayer.sendPosition: autoJumpEnabled follows the option.
player.auto_jump_enabled = self.settings.auto_jump;
player.invulnerable = self.creative || spectator;
player.spectator = spectator;
player.respiration = self.armor[0]
.as_ref()
.map_or(0, |s| s.enchantment_level("minecraft:respiration") as i32);
player.pitch = self.pitch;
player.glider = glider;
// LocalPlayer.modifyInput: walking while using an item.
player.item_use_speed = self
.using
.and_then(|(slot, _)| {
if slot == shield::OFFHAND_SLOT {
self.offhand.as_ref()
} else {
self.inventory.get(slot)?.as_ref()
}
})
.and_then(|s| self.res.items().get(&s.item))
.map(|i| i.use_speed);
// PowderSnowBlock.canEntityWalkOnPowderSnow and LivingEntity.canFreeze.
player.leather_boots = self.armor[3]
.as_ref()
.is_some_and(|s| &*s.item == "minecraft:leather_boots");
let immune = self
.res
.items()
.item_tags
.get("minecraft:freeze_immune_wearables");
player.freeze_immune = self
.armor
.iter()
.flatten()
.any(|s| immune.is_some_and(|t| t.contains(&*s.item)));
// The dimension's FAST_LAVA: the Nether's lava pushes harder.
player.fluids.fast_lava = self.dim == Dim::Nether;
player.spin_targets = spin_targets;
let grounded = player.ground.on_ground;
let before = (
+1 -10
View File
@@ -3144,19 +3144,10 @@ impl Game<'_> {
[player.position.x, player.position.y, player.position.z],
);
let was_flying = player.flying;
player.yaw = self.yaw;
// As the window's own tick has them: the helmet's Respiration
// (decreaseAirSupply) and the dimension's FAST_LAVA, the Nether's
// stronger lava current.
player.respiration = self.armor[0]
.as_ref()
.map_or(0, |s| s.enchantment_level("minecraft:respiration") as i32);
player.fluids.fast_lava = self.dim == Dim::Nether;
let glider = self.glider_worn();
self.sync_player_body();
let Some(player) = self.player.as_mut() else {
return Ok(());
};
player.glider = glider;
let was_gliding = player.fall_flying;
let dead = self.screen == Screen::Dead;
// LivingEntity.isImmobile: a sleeper lies still in the bed.
+81
View File
@@ -207,6 +207,9 @@ address. The script then checks, from both sides, what a guest's game used to ge
bites and reeling in catches it (#1348).
- maps: the host and the guest each make a map and hold it: their client draws the terrain
around them and their marker, from the server's map data (#1382).
- body: the host and the guest each walk while drawing a bow (slowed), stand on powder snow
with leather boots (held up) and without (sinking), and sprint-swim looking down
(diving): their own client decides it (#1278, #1296, #1303).
Each check is reported on its own (a failing one doesn't stop the others) and the screenshots of
both sides go to --out (host-*.png, guest-*.png).
@@ -4844,5 +4847,83 @@ CHECKS += ['maps']
CHECK_FNS.update(maps=check_maps)
def check_body(host, guest, out):
"""What each player's own client decides for its body (#1278, #1303, #1296): walking while
drawing a bow is slowed to a fifth (LocalPlayer.modifyInput), sprint-swimming follows the look
down (Player.travel's look angle) and leather boots hold on powder snow
(PowderSnowBlock.canEntityWalkOnPowderSnow)."""
hx, hy, hz = (int(v // 1) for v in pos_of(host))
seen = {}
def walked(game, x, z, use):
game('command', command=f'tp @s {x + 0.5} {hy} {z + 0.5} -90 0')
game.wait(10)
if use:
game.raw('mouse', 'right', 'down')
game.wait(5)
a = pos_of(game)
game.raw('move', 'forward', '0.8')
game.wait(10)
b = pos_of(game)
game.raw('mouse', 'right', 'up')
game.wait(5)
return round(math.dist((a[0], a[2]), (b[0], b[2])), 2)
try:
for game, dz in ((host, -4), (guest, 4)):
x, z = hx, hz + dz
host('command', command=f'fill {x - 1} {hy - 1} {z - 1} {x + 10} {hy - 1} {z + 1} minecraft:stone')
host('command', command=f'fill {x - 1} {hy} {z - 1} {x + 10} {hy + 3} {z + 1} minecraft:air')
game('command', command='gamemode survival')
game('command', command='clear @s')
game('command', command='effect clear @s')
s = {'walk': walked(game, x, z, False)}
game('command', command='item replace entity @s weapon.mainhand with minecraft:bow')
game('command', command='give @s minecraft:arrow 4')
game.wait(5)
s['drawing'] = walked(game, x, z, True)
game('command', command='clear @s')
# Powder snow under the feet: leather boots stand on it, bare feet sink.
host('command', command=f'setblock {x + 3} {hy - 1} {z} minecraft:powder_snow')
for boots in ('leather_boots', 'air'):
game('command', command=f'item replace entity @s armor.feet with minecraft:{boots}')
game('command', command=f'tp @s {x + 3.5} {hy} {z + 0.5} -90 0')
game.wait(30)
s[boots] = round(pos_of(game)[1] - hy, 2)
host('command', command=f'setblock {x + 3} {hy - 1} {z} minecraft:stone')
# Deep water: sprint-swimming while looking down dives.
wx, wz = x, z + 2 * (1 if dz > 0 else -1) * 3
host('command', command=f'fill {wx - 1} {hy - 14} {wz - 2} {wx + 12} {hy + 2} {wz + 2} minecraft:stone')
host('command', command=f'fill {wx} {hy - 13} {wz - 1} {wx + 11} {hy - 1} {wz + 1} minecraft:water')
game.wait(10)
game('command', command=f'tp @s {wx + 1.5} {hy - 6} {wz + 0.5} -90 60')
game.wait(10)
a = pos_of(game)
game.raw('move', 'forward', '1.5', '--sprint')
game.wait(5)
s['dive'] = round(pos_of(game)[1] - a[1], 2)
game('command', command=f'tp @s {x + 0.5} {hy} {z + 0.5} -90 0')
game.wait(5)
host('command', command=f'fill {wx - 1} {hy - 14} {wz - 2} {wx + 12} {hy + 2} {wz + 2} minecraft:air')
host('command', command=f'fill {wx - 1} {hy - 14} {wz - 2} {wx + 12} {hy - 1} {wz + 2} minecraft:stone')
game.shot(out, 'body')
seen[game.name] = s
finally:
for game in (host, guest):
back_to_game(game)
game.raw('mouse', 'right', 'up')
game('command', command='clear @s')
face_each_other(host, guest)
for name, s in seen.items():
assert s['walk'] > 2.5 and s['drawing'] < s['walk'] * 0.4, f'{name} drawing a bow: {seen}'
assert s['leather_boots'] > -0.01 and s['air'] < -0.5, f'{name} powder snow: {seen}'
assert s['dive'] < -2, f'{name} sprint-swimming down: {seen}'
return seen
CHECKS += ['body']
CHECK_FNS.update(body=check_body)
if __name__ == '__main__':
main()