Merge pull request #2094 from rdbtCVS/rdbt/fix-1478-firework-bursts-20261026

🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `FireworkRocketEntity.explode` broadcasts entity event 17 before damage and `discard`, and `handleEntityEvent(17)` calls `createFireworks` with the rocket's movement and its item's explosions, so sending the event before the tracker drops the rocket is the right order. Main conflicted (fireworks.rs, lan_e2e.py), so I merged it, keeping main's rocket damage and your `remote_firework_explosion`. `lan_e2e.py --check fireworks` passes in both modes. Fixes #1478. Thanks @rdbtCVS! Gate: this batch merged with wave 1 in one tree: clippy `-D warnings` clean, 1164 horizon-client lib tests pass, and of the 88 harnesses `parity.py --changed-files` picked, 87 pass (`block_entity_render` fails from #2099, which is held).
This commit is contained in:
Ludovic Marie
2026-10-26 16:26:25 +01:00
committed by GitHub
4 changed files with 116 additions and 2 deletions
@@ -17,6 +17,8 @@ use horizon_core::{
random::RandomSource,
};
pub(super) const FIREWORK_EXPLODE_EVENT: i8 = 17;
pub(super) struct Rocket {
/// The entity id a server tracks it by (0 until it is tracked).
pub id: u32,
@@ -261,6 +263,14 @@ impl Game<'_> {
/// `FireworkRocketEntity.explode` and `dealExplosionDamage`.
fn explode_rocket(&mut self, r: &Rocket) {
let at = [r.position.x, r.position.y, r.position.z];
// FireworkRocketEntity.explode broadcasts before discard. Send now:
// tick_lan removes missing tracked entities before flushing effects.
if r.id != 0
&& let Some(host) = &self.lan
{
host.hub
.entity_event(r.id as i32, FIREWORK_EXPLODE_EVENT, at);
}
if !r.explosions.is_empty() {
let damage = 5.0 + r.explosions.len() as f32 * 2.0;
let from = r.position;
@@ -322,6 +332,16 @@ impl Game<'_> {
self.particles
.fireworks(at, v, r.explosions.clone(), camera);
}
/// FireworkRocketEntity.handleEntityEvent: use the synchronized item data.
pub(super) fn remote_firework_explosion(&mut self, id: i32) {
let camera = self.eye_position();
if let Some(r) = self.rockets.iter().find(|r| r.id == id as u32) {
let at = [r.position.x, r.position.y, r.position.z];
let v = [r.velocity.x, r.velocity.y, r.velocity.z];
self.particles
.fireworks(at, v, r.explosions.clone(), camera.unwrap_or(at));
}
}
/// `dealExplosionDamage` on a player that is not the rocket's
/// `attachedToEntity`: within 5 blocks, when the rocket sees its feet or
/// its middle (`ClipContext.Block.COLLIDER`, no fluids).
+3
View File
@@ -2076,6 +2076,9 @@ impl Game<'_> {
}
}
C::EntityEvent(p) => {
if p.event == super::fireworks::FIREWORK_EXPLODE_EVENT {
self.remote_firework_explosion(p.id);
}
// LocalPlayer.setPermissions also refreshes an open World Options screen.
if (24..=28).contains(&p.event)
&& self.remote.as_ref().is_some_and(|r| r.entity_id == p.id)
+59 -2
View File
@@ -290,7 +290,15 @@ ROOT = Path(__file__).resolve().parents[1]
GUEST_NAME = 'Guest'
# Match normal single player; --in-frame is the comparison path.
SERVER_THREAD = True
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp', 'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles', 'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing', 'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push', 'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles', 'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects', 'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands', 'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption', 'breath', 'lava', 'levels', 'drops', 'underwater']
CHECKS = ['tab', 'self', 'armour', 'nametags', 'walls', 'chest', 'crafting', 'sign', 'damage', 'mobs', 'hazards', 'pvp',
'arrows', 'kills', 'hurt', 'looks', 'leads', 'respawn', 'containers', 'feedback', 'titles', 'chat', 'styles',
'commands', 'recipes', 'machines', 'brewing', 'loom', 'stonecutter', 'grindstone', 'anvil', 'smithing',
'enchanting', 'beacon', 'crafter', 'lectern', 'cartography', 'trials', 'clicks', 'sleep', 'predict', 'push',
'eat', 'eating', 'xp', 'objects', 'projectiles', 'thrown', 'sparks', 'hud', 'sidebar', 'border', 'particles',
'worn', 'blast', 'barter', 'deflect', 'fireball', 'light', 'time', 'swings', 'cracks', 'plates', 'effects',
'portals', 'distance', 'growth', 'doors', 'flight', 'ladder', 'boats', 'minecarts', 'frames', 'hands',
'lightning', 'riding', 'mounts', 'worldspawn', 'beds', 'shield', 'deathmining', 'contacts', 'absorption',
'breath', 'lava', 'levels', 'drops', 'underwater', 'fireworks']
class Game:
@@ -2898,6 +2906,55 @@ def sparked(player, other, kinds, act, ticks=20):
return seen
def check_fireworks(host, guest, out):
"""Event 17 must arrive before removal, with the item's colored, trailing explosion (#1478).
FireworkRocketEntity.explode / handleEntityEvent; run with and without --server-thread.
The flash proves a configured explosion reached both clients; red pixels in later screenshots
check that its sparks keep rendering after the tracked rocket disappears.
"""
x, y, z = (int(v // 1) for v in pos_of(host))
at = (x, y - 1, z + 3)
host('command', command=f'fill {x - 5} {y - 1} {z - 2} {x + 5} {y - 1} {z + 8} minecraft:stone')
host('command', command=f'fill {x - 5} {y} {z - 2} {x + 5} {y + 4} {z + 8} minecraft:air')
host('command', command=f'fill {x - 2} {y + 2} {z + 1} {x + 2} {y + 2} {z + 5} minecraft:stone')
for game, dx in ((host, -2), (guest, 2)):
game('command', command='gamemode creative')
game('command', command=f'tp @s {x + dx + 0.5} {y} {z + 0.5}')
game.raw('look-at', x + 0.5, y + 1.5, z + 3.5)
def red(path):
rows, bpp = png_rows(path)
# Exclude the hotbar and chat at the bottom of the view.
return sum(row[i] > 80 and row[i] > 2 * row[i + 1] and row[i] > 2 * row[i + 2]
for row in rows[:len(rows) * 3 // 4] for i in range(0, len(row), bpp))
baseline = {g.name: red(g.shot(out, 'fireworks-before')) for g in (host, guest)}
before = {g.name: made(g, 'flash') for g in (host, guest)}
host('command', command='item replace entity @s weapon.mainhand with minecraft:firework_rocket'
'[fireworks={flight_duration:0,explosions:[{shape:"large_ball",colors:[I;16711680],has_trail:true}]}]')
host.raw('interact', *at)
# The held item's red texture must not count as a burst or a later spark.
host('command', command='item replace entity @s weapon.mainhand with minecraft:air')
for _ in range(30):
host.wait(2)
if all(made(g, 'flash') > before[g.name] for g in (host, guest)):
break
flashes = {g.name: made(g, 'flash') - before[g.name] for g in (host, guest)}
assert all(n == 1 for n in flashes.values()), f'configured burst missing or duplicated: {flashes}'
# Capture both views before decoding PNGs: decoding must not consume the sparks' lifetime.
burst_shots = {g.name: g.shot(out, 'fireworks-burst') for g in (host, guest)}
host.wait(16)
trail_shots = {g.name: g.shot(out, 'fireworks-trail-fade') for g in (host, guest)}
burst = {name: red(path) - baseline[name] for name, path in burst_shots.items()}
trails = {name: red(path) - baseline[name] for name, path in trail_shots.items()}
rockets = {g.name: g('status')['rockets'] for g in (host, guest)}
assert not any(rockets.values()), f'exploded rocket remains: {rockets}'
assert all(n > 20 for n in burst.values()), f'no red burst: {burst}'
assert all(n > 20 for n in trails.values()), f'no later red trail/fade: {trails}'
return {'flashes': flashes, 'red_burst': burst, 'red_trail_fade': trails, 'rockets': rockets}
def check_sparks(host, guest, out):
spots = apart(host, guest)
result = {}
@@ -4631,7 +4688,7 @@ CHECK_FNS = {'tab': check_tab, 'self': check_self, 'armour': check_armour,
'hud': check_hud,
'sidebar': check_sidebar,
'border': check_border,
'particles': check_particles}
'particles': check_particles, 'fireworks': check_fireworks}
def run(ctl, out, resources, checks):
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""FireworkRocketEntity event 17 renders the configured burst before tracked removal.
Exercise both hosting paths and subsequent trail/fade frames through real clients.
"""
import json
import subprocess
import lab
import lan_e2e as lan
def main():
subprocess.run(['cargo', 'build', '--locked', '--profile', 'fast', '-p', 'horizon-client',
'--bin', 'horizon-client', '--bin', 'horizon-ctl'], cwd=lab.ROOT, check=True)
metadata = json.loads(subprocess.check_output(
['cargo', 'metadata', '--format-version', '1', '--no-deps'], cwd=lab.ROOT, text=True))
ctl = lab.ROOT / metadata['target_directory'] / 'fast' / 'horizon-ctl'
# CI supplies the display; each game still gets fresh scratch homes.
lan.game_env = lambda _screen, home: lab.game_env(
HORIZON_HOME=home, HORIZON_TELEMETRY_URL='off')
reports = {}
for threaded in (True, False):
lan.SERVER_THREAD = threaded
mode = 'server-thread' if threaded else 'in-frame'
out = lab.LOCAL / 'remote-fireworks-parity' / mode
out.mkdir(parents=True, exist_ok=True)
reports[mode] = lan.run(ctl, out, lab.RESOURCES.resolve(), ['fireworks'])
lab.write_json(lab.LOCAL / 'remote-fireworks-parity' / 'report.json', reports)
assert all(r['pass'] for mode in reports.values() for r in mode.values()), reports
if __name__ == '__main__':
main()