Merge pull request #2172 from rdbtCVS/fix/1525-forced-dimension-ticking

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `ServerLevel.tick` keeps ticking a level that has forced chunks, even with no players and past the 300-tick empty timeout. `lan_e2e.py --server-thread --check forced-levels` passes. Main conflicted in lan_e2e.py, so I merged main into the branch, keeping both checks. 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 @rdbtCVS!
This commit is contained in:
Ludovic Marie
2026-10-26 18:42:08 +01:00
committed by GitHub
3 changed files with 78 additions and 14 deletions
+9 -8
View File
@@ -2582,14 +2582,15 @@ impl Game<'_> {
(p.position.z.floor() as i32) >> 4,
));
}
let sources = (self.options.dedicated.is_some() || !players.is_empty()).then(|| {
horizon_client::ticket_levels::Sources {
players,
forced: self.streaming.forced.iter().copied().collect(),
view_distance: self.settings.render_distance.clamp(2, 32),
simulation_distance: self.settings.simulation_distance.max(2),
}
});
let sources =
(!self.options.execution_role.is_client() || !players.is_empty()).then(|| {
horizon_client::ticket_levels::Sources {
players,
forced: self.streaming.forced.iter().copied().collect(),
view_distance: self.settings.render_distance.clamp(2, 32),
simulation_distance: self.settings.simulation_distance.max(2),
}
});
self.tickets.update(sources);
}
/// `ServerLevel.startTickingChunk`: a loaded chunk's saved ticks are
+16 -6
View File
@@ -3,8 +3,8 @@
//! The game's tick code reads one level: the one in place, held in `Game`'s
//! own fields (the world, its streaming and save, block ticks, entities).
//! A server (the dedicated server and single player's server thread) keeps
//! the other dimensions' levels here and ticks each one that has players by
//! swapping it into place (`enter_level`), the way `as_guest` swaps a player
//! the other dimensions' levels here and ticks each one with players or forced
//! chunks by swapping it into place (`enter_level`), the way `as_guest` swaps a player
//! in, so the tick code runs unchanged, one level at a time. The in-frame
//! game holds one level, which follows its player (`enter_dimension`).
//!
@@ -293,8 +293,8 @@ impl Game<'_> {
}
/// One server tick (`MinecraftServer.tickServer`): each level with
/// players in turn (`tickChildren`), its chunks streamed and loaded and
/// its world ticked. The first pass reads the network and runs the
/// players or forced chunks in turn (`tickChildren`), its chunks streamed
/// and loaded and its world ticked. The first pass reads the network and runs the
/// tick's shared parts (the clock, the weather, functions, the autosave);
/// the next ones only their level. While `paused`, only the connections
/// run.
@@ -396,7 +396,7 @@ impl Game<'_> {
/// The levels this server tick runs, in `MinecraftServer.levels` order
/// (the Overworld, the Nether, the End): every level with a player in
/// it or a `/pregen` task, or the Overworld while nobody is online.
/// it, forced chunks or a `/pregen` task, or the Overworld while idle.
pub(super) fn levels_to_tick(&self) -> Vec<Dim> {
let guests = self
.lan
@@ -405,7 +405,17 @@ impl Game<'_> {
let mut dims: Vec<Dim> = [Dim::Overworld, Dim::Nether, Dim::End]
.into_iter()
.filter(|d| {
guests.iter().any(|g| g.dimension == d.id()) || self.pregen_level() == Some(*d)
let forced = if *d == self.dim {
!self.streaming.forced.is_empty()
} else {
self.levels
.parked
.get(d)
.is_some_and(|p| !p.streaming.forced.is_empty())
};
guests.iter().any(|g| g.dimension == d.id())
|| forced
|| self.pregen_level() == Some(*d)
})
.collect();
if dims.is_empty() {
+53
View File
@@ -7245,5 +7245,58 @@ CHECKS += ['cushions']
CHECK_FNS['cushions'] = check_cushions
def check_forced_levels(host, guest, out):
"""#1525: forced block/entity ticks outlive the last player and the 300-tick idle timeout.
Also keep a resident, unforced furnace outside the forced ticket's neighbour ring: scheduling
a playerless integrated-server level must not enable the fixtures' tick-everywhere fallback.
"""
if not SERVER_THREAD:
return 'skipped (needs --server-thread)'
start = pos_of(guest)
results = {}
guest('command', command='gamemode creative')
try:
for dimension in (NETHER, END):
into_level(guest, dimension, 8, 100, 8)
host('command', command='tick freeze')
furnace = ('minecraft:furnace{Items:[{Slot:0b,id:"minecraft:raw_iron",count:1},'
'{Slot:1b,id:"minecraft:coal",count:1}],cooking_total_time:200,'
'cooking_time_spent:0}')
for x in (8, 56):
guest('command', command=f'setblock {x} 100 8 {furnace}')
server_reply(guest, f'execute if data block {x} 100 8 '
'Items[{Slot:0b,id:"minecraft:raw_iron"}] '
'run say forced-input-ready', 'forced-input-ready')
guest('command', command='forceload add 8 8')
guest('command', command='summon minecraft:armor_stand 8.5 104 8.5 {Tags:["forced_tick"]}')
guest('command', command=f'execute in {OVERWORLD} run tp @s {start[0]} {start[1]} {start[2]}')
wait_dimension(guest, OVERWORLD, 400)
host('command', command='tick step 450')
host.wait(500)
prefix = f'execute in {dimension} '
results[dimension] = server_reply(
host, prefix + 'if data block 8 100 8 Items[{Slot:2b,id:"minecraft:iron_ingot"}] '
'if data block 56 100 8 {cooking_time_spent:0} '
'if data block 56 100 8 Items[{Slot:0b,id:"minecraft:raw_iron"}] '
'if data entity @e[tag=forced_tick,limit=1] {Pos:[8.5d,101.0d,8.5d]} run say forced-level-pass',
'forced-level-pass')
assert dims(host, guest) == (OVERWORLD, OVERWORLD), dims(host, guest)
host('command', command=prefix + 'run forceload remove 8 8')
host('command', command=prefix + 'run kill @e[tag=forced_tick]')
host('command', command='tick unfreeze')
finally:
host('command', command='tick unfreeze')
for dimension in (NETHER, END):
host('command', command=f'execute in {dimension} run forceload remove 8 8')
guest('command', command=f'execute in {OVERWORLD} run tp @s {start[0]} {start[1]} {start[2]}')
guest('command', command='gamemode survival')
return results
CHECKS += ['forced-levels']
CHECK_FNS['forced-levels'] = check_forced_levels
if __name__ == '__main__':
main()