Pause: the server thread stops ticking its players, not the window
The window's own tick doesn't run while paused (the frame loop skips Game::tick), so the two gates added there never fired. What kept going was the server thread: its paused pass still ran tick_guests, the players' doTick, so air, hunger and drowning damage moved on behind the pause menu. Vanilla's IntegratedServer.tickPaused only ticks the connections, and ServerGamePacketListenerImpl.tick skips tickPlayer while the server is paused. tick_lan now does the same: the paused pass keeps the connections and skips tick_guests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4147,7 +4147,7 @@ impl Game<'_> {
|
||||
[player.velocity.x, player.velocity.y, player.velocity.z],
|
||||
[player.position.x, player.position.y, player.position.z],
|
||||
);
|
||||
if !riding && !self.pause {
|
||||
if !riding {
|
||||
MotionWorld {
|
||||
entities: &entity_collisions,
|
||||
player,
|
||||
@@ -4413,7 +4413,7 @@ impl Game<'_> {
|
||||
self.resolve_arrivals();
|
||||
});
|
||||
}
|
||||
horizon_client::spans::time("tick_lan", || self.tick_lan());
|
||||
horizon_client::spans::time("tick_lan", || self.tick_lan(false));
|
||||
self.tick_friends();
|
||||
horizon_client::spans::time("tick_hand", || self.tick_hand());
|
||||
horizon_client::spans::time("tick_sleep", || self.tick_sleep());
|
||||
|
||||
@@ -834,8 +834,11 @@ impl Game<'_> {
|
||||
self.lan_object_states(host_entity, hub, out);
|
||||
}
|
||||
|
||||
/// Run the hub for this tick and apply what the guests did.
|
||||
pub(super) fn tick_lan(&mut self) {
|
||||
/// Run the hub for this tick and apply what the guests did. While the
|
||||
/// single player game is `paused` only the connections run
|
||||
/// (`IntegratedServer.tickPaused`): `ServerGamePacketListenerImpl.tick`
|
||||
/// skips `tickPlayer`, so no player's air, hunger or damage moves on.
|
||||
pub(super) fn tick_lan(&mut self, paused: bool) {
|
||||
let Some(mut host) = self.lan.take() else {
|
||||
return;
|
||||
};
|
||||
@@ -1000,7 +1003,9 @@ impl Game<'_> {
|
||||
host.states = states;
|
||||
}
|
||||
self.lan_flush_effects(&mut host);
|
||||
self.tick_guests(&mut host);
|
||||
if !paused {
|
||||
self.tick_guests(&mut host);
|
||||
}
|
||||
self.lan_living_flags(&mut host);
|
||||
self.tick_server_travel(&mut host);
|
||||
self.lan_swings(&mut host);
|
||||
|
||||
@@ -296,7 +296,7 @@ impl Game<'_> {
|
||||
self.update_dedicated_streaming();
|
||||
self.update_world();
|
||||
result = if paused {
|
||||
self.tick_lan();
|
||||
self.tick_lan(true);
|
||||
Ok(())
|
||||
} else if k == 0 {
|
||||
self.tick()
|
||||
|
||||
@@ -3175,10 +3175,7 @@ impl Game<'_> {
|
||||
f64::from(head[2]) + 0.5,
|
||||
);
|
||||
player.velocity = Vec3::ZERO;
|
||||
} else if !dead && !riding && !self.pause {
|
||||
// Minecraft.tick skips the level while the game is paused: the window's own
|
||||
// copy stands still too, so air, hunger and fall prediction do not run ahead
|
||||
// of the paused server (#1592).
|
||||
} else if !dead && !riding {
|
||||
player.velocity = player.velocity.add_vector(pushed);
|
||||
MotionWorld {
|
||||
entities: &entity_collisions,
|
||||
|
||||
Reference in New Issue
Block a user