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:
@@ -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 = (
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user