From cc65eeec822ab8a5840a422921c77c4920341437 Mon Sep 17 00:00:00 2001 From: rdbtCVS <87152661+rdbtCVS@users.noreply.github.com> Date: Sun, 25 Oct 2026 03:11:09 +0000 Subject: [PATCH] Make shulker bullets visible on server clients Assign mob-fired projectiles IDs when they are added and recognize shulker bullet spawns on remote clients. Extend the live LAN checks for both hosting modes. Co-Authored-By: OpenCode (agentrouter/gpt-6.1-sol) --- crates/horizon-client/src/game/creatures.rs | 4 +- .../src/game/remote_projectiles.rs | 8 ++ tools/lan_e2e.py | 111 +++++++++++++++++- 3 files changed, 121 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/creatures.rs b/crates/horizon-client/src/game/creatures.rs index ec9848919..0bb7bbe85 100644 --- a/crates/horizon-client/src/game/creatures.rs +++ b/crates/horizon-client/src/game/creatures.rs @@ -978,7 +978,9 @@ impl Game<'_> { m.ai.target = Some(target); } } - MobEvent::Projectile(p) => { + MobEvent::Projectile(mut p) => { + self.next_entity += 1; + p.id = self.next_entity; let (owner, at) = (p.owner, [p.position.x, p.position.y, p.position.z]); self.creatures.projectiles.push(p); self.projectile_event("minecraft:projectile_shoot", owner, at); diff --git a/crates/horizon-client/src/game/remote_projectiles.rs b/crates/horizon-client/src/game/remote_projectiles.rs index 58f82e3a9..5b2a22789 100644 --- a/crates/horizon-client/src/game/remote_projectiles.rs +++ b/crates/horizon-client/src/game/remote_projectiles.rs @@ -24,6 +24,14 @@ fn projectile_kind(kind: &str) -> Option { "minecraft:llama_spit" => ProjectileKind::LlamaSpit, "minecraft:wind_charge" => ProjectileKind::WindCharge, "minecraft:breeze_wind_charge" => ProjectileKind::BreezeWindCharge, + // Homing state stays on the server; the client interpolates its positions. + "minecraft:shulker_bullet" => ProjectileKind::ShulkerBullet { + target: horizon_client::mobs::Who::Player, + dir: None, + steps: 0, + delta: [0.0; 3], + seed: 0, + }, "minecraft:wither_skull" => ProjectileKind::WitherSkull { dangerous: false }, _ => return None, }) diff --git a/tools/lan_e2e.py b/tools/lan_e2e.py index 3ece4b448..cf6bc19af 100755 --- a/tools/lan_e2e.py +++ b/tools/lan_e2e.py @@ -109,7 +109,9 @@ address. The script then checks, from both sides, what a guest's game used to ge - objects: boats, minecarts, armor stands, item frames and paintings the host summons reach the guest as the host has them (kind, place, rotation, what they hold or wear, the variant). - projectiles: primed TNT (one falling), an end crystal and an arrow that lands reach the guest where - the host has them; a falling block lands on both sides. + the host has them; a falling block lands on both sides. +- shulker_bullets: every shot a shulker fires has its own id and flies on both sides, following + the same trajectory; the bullets disappear on both sides when they hit blocks (#1494). - thrown: a splash potion and an eye of ender the host and the guest each throw fly on both sides (#1363, #1391); - sparks: level events' particles on both sides: the host's and the guest's bone meal on wheat @@ -5496,5 +5498,112 @@ CHECKS += ['villagers'] CHECK_FNS.update(villagers=check_villagers) +def check_shulker_bullets(host, guest, out): + """ShulkerAttackGoal's bullets reach ClientPacketListener.handleAddEntity, then the existing + projectile renderer and interpolation, with distinct ids from the server's entity counter.""" + x, y, z = (int(v // 1) for v in pos_of(host)) + tag = 'lan_shulker_bullets' + selector = f'@e[type=minecraft:shulker,tag={tag},limit=1]' + sound = 'minecraft:entity.shulker.shoot' + paths = {g.name: {} for g in (host, guest)} + before = {g.name: heard(g, sound) for g in (host, guest)} + shots = dict.fromkeys(before, 0) + first_shot = stopped = None + photographed = False + + def bullets(status): + return [p for p in status['projectiles'] if p['kind'] == 'ShulkerBullet'] + + try: + host('command', command='difficulty normal') + host('command', command='gamemode creative') + guest('command', command='gamemode survival') + guest('command', command='effect give @s minecraft:resistance 120 4 true') + host('command', command=f'fill {x - 10} {y - 1} {z - 10} {x + 10} {y - 1} {z + 18} minecraft:stone') + host('command', command=f'fill {x - 10} {y} {z - 10} {x + 10} {y + 12} {z + 18} minecraft:air') + # A west wall supports the shulker above the floor, leaving room for a short flight. + host('command', command=f'fill {x - 1} {y} {z + 7} {x - 1} {y + 4} {z + 7} minecraft:stone') + host('command', command=f'tp @s {x + 4.5} {y} {z - 0.5}') + guest('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}') + host('command', command=f'summon minecraft:shulker {x + 0.5} {y + 3} {z + 7.5} ' + f'{{NoAI:1b,PersistenceRequired:1b,Tags:["{tag}"]}}') + for game in (host, guest): + game.raw('look-at', x + 0.5, y + 3.5, z + 7.5) + guest.wait(20) + host('command', command=f'data merge entity {selector} {{NoAI:0b}}') + for waited in range(2, 402, 2): + guest.wait(2) + for game in (host, guest): + status = game('status') + live = bullets(status) + ids = [p['id'] for p in live] + assert all(ids) and len(set(ids)) == len(ids), f'{game.name}: invalid bullet ids {ids}' + for p in live: + paths[game.name].setdefault(p['id'], []).append(p['position']) + shots[game.name] = status['heard'].get(sound, 0) - before[game.name] + if shots['host'] and first_shot is None: + first_shot = waited + if first_shot is not None and waited - first_shot >= 8 and not photographed: + host('command', command='tick freeze') + try: + for game in (host, guest): + game.raw('look-at', x + 0.5, y + 3.5, z + 7.5) + game.raw('key', 'f1', 'tap') + try: + game.shot(out, 'shulker-bullets') + finally: + game.raw('key', 'f1', 'tap') + finally: + host('command', command='tick unfreeze') + photographed = True + if shots['host'] >= 2 and stopped is None: + host('command', command=f'data merge entity {selector} {{NoAI:1b}}') + stopped = waited + if stopped is not None and waited - stopped >= 20: + break + # Keep the survival target in range after a hit applies levitation. + if waited % 20 == 0: + guest('command', command='effect clear @s minecraft:levitation') + guest('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}') + lab.write_json(out / 'shulker-bullets.json', {'shots': shots, 'paths': paths}) + assert shots['host'] >= 2, f'the shulker did not attack twice: {shots}' + for name, by_id in paths.items(): + assert len(by_id) == shots[name], f'{name}: {shots[name]} shots but bullet ids {list(by_id)}' + for id, positions in by_id.items(): + assert any(math.dist(positions[0], p) > 0.5 for p in positions), \ + f'{name}: bullet {id} did not move: {positions}' + assert paths['host'].keys() == paths['guest'].keys(), f'different bullets: {paths}' + for id, positions in paths['guest'].items(): + # The clients interpolate three ticks behind, and reads are not simultaneous. + assert all(min(math.dist(p, q) for q in paths['host'][id]) < 1.5 for p in positions), \ + f'bullet {id} diverged from the host: {paths}' + + # Put blocks in the flight volume to exercise server removal without depending on homing. + for game in (host, guest): + game('command', command='gamemode creative') + game('command', command=f'tp @s {x + 0.5} {y + 16} {z + 0.5}') + host('command', command=f'fill {x - 10} {y} {z - 10} {x + 10} {y + 12} {z + 18} minecraft:stone') + for _ in range(20): + guest.wait(2) + remaining = {g.name: bullets(g('status')) for g in (host, guest)} + if not any(remaining.values()): + break + assert not any(remaining.values()), f'bullets survived block hits: {remaining}' + finally: + host('command', command='tick unfreeze') + host('command', command=f'kill @e[tag={tag}]') + host('command', command=f'fill {x - 10} {y} {z - 10} {x + 10} {y + 12} {z + 18} minecraft:air') + for game in (host, guest): + game('command', command='effect clear @s') + game('command', command=f'tp @s {x + 0.5} {y} {z + 0.5}') + game('command', command='gamemode survival') + face_each_other(host, guest) + return {'shots': shots, 'ids': sorted(paths['host']), 'removed': True} + + +CHECKS += ['shulker_bullets'] +CHECK_FNS.update(shulker_bullets=check_shulker_bullets) + + if __name__ == '__main__': main()