From 52eb549aec94498418d401e98989d38a821c6d02 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 22 Oct 2026 02:21:35 +0200 Subject: [PATCH] Particles: add 26.3's sulfur bubbles over potent sulfur PotentSulfurBlock.animateTick sends two sulfur_bubbles up through a water source above a wet potent sulfur block, and one time in ten plays block.potent_sulfur.noxious_gas. SulfurBubbleParticle rises at -0.04 gravity with 0.85 friction, wiggles sideways, grows from 0.02 to 0.15 and pops when it leaves a water source, stops rising or travels 3 blocks. Its provider passes yAux as the Z speed, which is kept. The particle providers harness gets water worlds for sulfur_bubbles, bubble and bubble_column_up. Co-Authored-By: Claude Opus 5.5 --- .../examples/particle_providers_probe.rs | 32 +++++---- crates/horizon-client/src/animate_tick.rs | 25 +++++++ crates/horizon-client/src/particles.rs | 69 +++++++++++++++++++ crates/horizon-client/src/settings.rs | 5 +- .../VanillaParticleProvidersOracle.java | 15 ++-- tools/test_particle_providers_parity.py | 12 +++- 6 files changed, 138 insertions(+), 20 deletions(-) diff --git a/crates/horizon-client/examples/particle_providers_probe.rs b/crates/horizon-client/examples/particle_providers_probe.rs index 989895c07..8b8bd1e0d 100644 --- a/crates/horizon-client/examples/particle_providers_probe.rs +++ b/crates/horizon-client/examples/particle_providers_probe.rs @@ -112,21 +112,26 @@ fn state(s: &ParticleSnapshot) -> String { } out } -fn world(assets: &Assets, facts: &BlockFacts, floor: bool) -> Result { +fn world(assets: &Assets, facts: &BlockFacts, floor: bool, water: bool) -> Result { let mut world = World::new(facts.air, 0); - let stone = assets - .registry - .default_state("minecraft:stone") - .ok_or("missing stone")?; + let state = |name: &str| assets.registry.default_state(name).ok_or("missing block"); + let (stone, still) = (state("minecraft:stone")?, state("minecraft:water")?); for cz in -3..=2 { for cx in -3..=2 { world .chunks .insert((cx, cz), Arc::new(Chunk::empty(cx, cz))); - if floor { - for z in 0..16 { - for x in 0..16 { - world.set(cx * 16 + x, 63, cz * 16 + z, stone)?; + for z in 0..16 { + for x in 0..16 { + let (x, z) = (cx * 16 + x, cz * 16 + z); + if floor { + world.set(x, 63, z, stone)?; + } + // The oracle's water: still sources from y 64 to 67. + if water { + for y in 64..=67 { + world.set(x, y, z, still)?; + } } } } @@ -142,8 +147,10 @@ fn main() -> Result<()> { let facts = BlockFacts::load(root, assets.registry)?; let collision = collisions::load(root, assets.registry)?; let worlds = [ - world(&assets, &facts, false)?, - world(&assets, &facts, true)?, + world(&assets, &facts, false, false)?, + world(&assets, &facts, true, false)?, + world(&assets, &facts, false, true)?, + world(&assets, &facts, true, true)?, ]; let mut engine = ParticleEngine::new(root, &HashMap::new()); for (ty, item) in [ @@ -174,7 +181,8 @@ fn main() -> Result<()> { engine.requested = Some(Vec::new()); engine.sounds.clear(); let level = ParticleLevel { - world: &worlds[usize::from(case["floor"].as_bool() == Some(true))], + world: &worlds[usize::from(case["floor"].as_bool() == Some(true)) + + 2 * usize::from(case["water"].as_bool() == Some(true))], facts: &facts, collision: &collision, player: None, diff --git a/crates/horizon-client/src/animate_tick.rs b/crates/horizon-client/src/animate_tick.rs index b391c0cbf..ce34df510 100644 --- a/crates/horizon-client/src/animate_tick.rs +++ b/crates/horizon-client/src/animate_tick.rs @@ -61,6 +61,8 @@ enum Animate { Fire, /// An active sculk sensor. SculkSensor, + /// Potent sulfur that is not dry. + PotentSulfur, } fn step(facing: &str) -> [i32; 3] { match facing { @@ -128,6 +130,9 @@ fn classify(name: &str, prop: &dyn Fn(&str) -> Option) -> Animate { } } "respawn_anchor" if prop("charges").is_some_and(|c| c != "0") => Animate::RespawnAnchor, + "potent_sulfur" if prop("potent_sulfur_state").is_some_and(|s| s != "dry") => { + Animate::PotentSulfur + } "bubble_column" => Animate::BubbleColumn { drag: prop("drag").as_deref() == Some("true"), }, @@ -819,6 +824,26 @@ fn block_animate_tick( } } } + Animate::PotentSulfur => { + // PotentSulfurBlock.animateTick: under a water source, two + // bubbles and, one time in ten, the noxious gas. + let above = ctx.facts.get(ctx.state([pos[0], pos[1] + 1, pos[2]])); + if above.fluid == Fluid::Water && above.fluid_level == 8 && !above.fluid_falling { + for _ in 0..2 { + let r = engine.random(); + let p = [ + fx + f64::from(r.next_float()), + fy + 1.0 + f64::from(r.next_float()), + fz + f64::from(r.next_float()), + ]; + add(engine, T::SulfurBubbles, p, [0.0; 3]); + } + if next_int(engine.random(), 10) == 0 { + let name = "minecraft:block.potent_sulfur.noxious_gas"; + sound(engine, name, [fx, fy, fz], 1.0, 1.0); + } + } + } Animate::Mycelium => { let r = engine.random(); if next_int(r, 10) == 0 { diff --git a/crates/horizon-client/src/particles.rs b/crates/horizon-client/src/particles.rs index 29bf5b030..55a7a5120 100644 --- a/crates/horizon-client/src/particles.rs +++ b/crates/horizon-client/src/particles.rs @@ -73,6 +73,7 @@ particle_types! { Splash = "splash", Rain = "rain", Bubble = "bubble", + SulfurBubbles = "sulfur_bubbles", BubblePop = "bubble_pop", BubbleColumnUp = "bubble_column_up", CurrentDown = "current_down", @@ -352,6 +353,14 @@ enum Behaviour { }, WaterDrop, Bubble, + /// `SulfurBubbleParticle`: rises three blocks through still water, + /// growing to 0.15. + SulfurBubble { + y_start: f64, + y_end: f64, + size_start: f32, + y_prev: f64, + }, BubblePop, BubbleColumnUp, CurrentDown { @@ -1099,6 +1108,11 @@ impl ParticleLevel<'_> { }; (s.fluid, height) } + /// The fluid at a block and whether it is a source (`FluidState.isSource`). + fn fluid_source(&self, b: [i32; 3]) -> (Fluid, bool) { + let s = self.facts.get(self.world.block(b[0], b[1], b[2])); + (s.fluid, s.fluid_level == 8 && !s.fluid_falling) + } /// `getCollisionShape(...).max(Y, x, z)` for cached shapes. fn collision_top(&self, b: [i32; 3], fx: f64, fz: f64) -> f64 { let state = self.world.block(b[0], b[1], b[2]); @@ -1933,6 +1947,27 @@ impl ParticleEngine { } q } + T::SulfurBubbles => { + let mut q = Particle::at(r, ty, p); + q.gravity = -0.04; + q.friction = 0.85; + q.set_size(0.02, 0.02); + q.velocity[0] = + v[0] * f64::from(0.2f32) + f64::from((r.next_float() * 2.0 - 1.0) * 0.02); + // The provider passes `yAux` as `za`, so the Z speed comes from Y. + q.velocity[2] = + v[1] * f64::from(0.2f32) + f64::from((r.next_float() * 2.0 - 1.0) * 0.02); + let size_start = 0.02 + 0.02 * r.next_float(); + q.size = size_start; + q.lifetime = i32::MAX; + q.behaviour = Behaviour::SulfurBubble { + y_start: p[1], + y_end: p[1] + 4.0 - 1.0, + size_start, + y_prev: p[1], + }; + q + } T::BubblePop => { let mut q = Particle::at(r, ty, p); q.lifetime = 4; @@ -3172,6 +3207,40 @@ impl ParticleEngine { p.removed = true; } } + Behaviour::SulfurBubble { + y_start, + y_end, + size_start, + y_prev, + } => { + p.base_tick(level); + let (fluid, source) = level.fluid_source(ParticleLevel::block_at(p.position)); + if !p.removed && !(fluid == Fluid::Water && source) { + p.removed = true; + } + if !p.removed && p.position[1] >= y_end { + p.removed = true; + } + if !p.removed && p.position[1] <= y_prev { + p.removed = true; + } + // randomHorizontalWiggling, then a second, horizontal move. + let wiggle = |r: &mut LegacyRandom| { + let f = r.next_float() * 0.003; + f64::from(if r.next_boolean() { f } else { -f }) * 0.5 + }; + p.velocity[0] += wiggle(&mut p.random); + p.velocity[2] += wiggle(&mut p.random); + p.move_by(level, [p.velocity[0], 0.0, p.velocity[2]]); + let progress = ((p.position[1] - y_start) / (y_end - y_start)) as f32; + p.size = size_start + progress * (0.15 - size_start); + p.behaviour = Behaviour::SulfurBubble { + y_start, + y_end, + size_start, + y_prev: p.position[1], + }; + } Behaviour::BubbleColumnUp => { p.base_tick(level); if !p.removed && level.fluid(ParticleLevel::block_at(p.position)).0 != Fluid::Water diff --git a/crates/horizon-client/src/settings.rs b/crates/horizon-client/src/settings.rs index 34b945626..1fadacf57 100644 --- a/crates/horizon-client/src/settings.rs +++ b/crates/horizon-client/src/settings.rs @@ -48,7 +48,10 @@ pub fn sound_source(event: &str) -> usize { "zombified_piglin", "wither_skeleton", ]; - if e.starts_with("music_disc.") { + if e == "block.potent_sulfur.noxious_gas" { + // PotentSulfurBlock.animateTick, its only caller, plays it as AMBIENT. + index("ambient") + } else if e.starts_with("music_disc.") { index("record") } else if e.starts_with("music.") { index("music") diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaParticleProvidersOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaParticleProvidersOracle.java index f060351b3..85fb5ecd9 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaParticleProvidersOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaParticleProvidersOracle.java @@ -48,8 +48,9 @@ import org.jspecify.annotations.Nullable; /** Builds each particle through its real registered ParticleProvider (the real * ParticleResources, sprite sets bound to stand-in sprites named after the * vanilla particles/*.json textures) in a stand-in ClientLevel (air, an - * optional stone floor at y 63, no fluids), then ticks it and records its - * state, the particles and sounds it asks the level for, tick by tick. + * optional stone floor at y 63, optionally still water from y 64 to 67), + * then ticks it and records its state, the particles and sounds it asks the + * level for, tick by tick. * * Each vanilla Particle owns a RandomSource.create() random seeded from the * clock; its seed is recovered after construction (the SEED_UNIQUIFIER value @@ -67,13 +68,18 @@ public final class VanillaParticleProvidersOracle { static T make(Class type) throws Exception { return type.cast(allocate.invoke(unsafe, type)); } static final class Level0 extends ClientLevel { - boolean floor; + boolean floor, water; List events; Level0() { super(null, null, null, null, 0, 0, null, false, 0L, 0); } + // Water: still water sources from y 64 to 67 (above the floor, below the open air). + boolean wet(BlockPos p) { return water && p.getY() >= 64 && p.getY() <= 67; } @Override public BlockState getBlockState(BlockPos p) { + if (wet(p)) return Blocks.WATER.defaultBlockState(); return floor && p.getY() == 63 ? Blocks.STONE.defaultBlockState() : Blocks.AIR.defaultBlockState(); } - @Override public FluidState getFluidState(BlockPos p) { return Fluids.EMPTY.defaultFluidState(); } + @Override public FluidState getFluidState(BlockPos p) { + return wet(p) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState(); + } @Override public @Nullable BlockGetter getChunkForCollisions(int x, int z) { return this; } @Override public boolean hasChunkAt(BlockPos p) { return false; } @Override public void addParticle(ParticleOptions o, double x, double y, double z, double xd, double yd, double zd) { @@ -258,6 +264,7 @@ public final class VanillaParticleProvidersOracle { long seed = c.get("seed").getAsLong(); RandomSource random = null; level.floor = c.get("floor").getAsBoolean(); + level.water = c.has("water") && c.get("water").getAsBoolean(); level.events.clear(); var p = c.getAsJsonArray("pos"); var v = c.getAsJsonArray("vel"); Particle particle = null; diff --git a/tools/test_particle_providers_parity.py b/tools/test_particle_providers_parity.py index afd283359..2fdd510d9 100644 --- a/tools/test_particle_providers_parity.py +++ b/tools/test_particle_providers_parity.py @@ -35,7 +35,7 @@ spore_blossom_air totem_of_undying underwater vault_connection warped_spore whit sweep_attack glow wax_on wax_off electric_spark scrape squid_ink glow_squid_ink item_slime item_snowball item_cobweb sulfur_cube_goo firefly trial_spawner_detection trial_spawner_detection_ominous trial_omen raid_omen ominous_spawning spit fishing dust_plume red_poplar_leaves orange_poplar_leaves yellow_poplar_leaves pause_mob_growth -reset_mob_growth""".split() +reset_mob_growth sulfur_bubbles""".split() def options(kind, rng): @@ -78,6 +78,12 @@ def cases(rng): for vel in velocities: yield dict(type=kind, options=options(kind, rng), pos=pos, vel=vel, floor=floor, seed=rng.randrange(-2**63, 2**63), ticks=80) + # In still water (sources from y 64 to 67): the bubbles rise until they leave it. + for kind in ['sulfur_bubbles', 'bubble', 'bubble_column_up']: + for (pos, floor) in [([0.3125, 64.046875, -0.40625], True), ([-5.75, 66.59375, 3.125], False)]: + for vel in velocities: + yield dict(type=kind, options={}, pos=pos, vel=vel, floor=floor, water=True, + seed=rng.randrange(-2**63, 2**63), ticks=80) def make_cases(build): @@ -215,10 +221,10 @@ def main(): client_jar_sha256=lab.digest(jars['client'], 'sha256'), matched_output_lines=matched, output_sha256=lab.digest(build / 'rust.txt', 'sha256'), libm_tolerated_lines=tolerance, scope=('Real ParticleResources providers for every type Horizon implements, ticked in an air level with an optional ' - 'stone floor: construction (provider, level, SpellParticle and particle-local random draws), per-tick ' + 'stone floor and, for the bubbles, still water: construction (provider, level, SpellParticle and particle-local random draws), per-tick ' 'position, previous position, motion, age, lifetime, removal, onGround, quad size at partial 0 and 0.5, ' 'colour, alpha, roll, sprite, UVs and light at partial 0.5 (unloaded chunk), and the particles and sounds ' - 'requested from the level. Fluids, block light, render layers/facing and the ParticleEngine group limits ' + 'requested from the level. Flowing fluids, block light, render layers/facing and the ParticleEngine group limits ' 'are not exercised.'))) print(f'{units:,} particle cases match the pinned client ({matched:,} output lines, {tolerance} within ' f'the libm tolerance): {report}', flush=True)