70583cbf2a
The new particle types now come from the events that spawn them in vanilla. - Level events 3003 (wax on), 3004 (wax off), 3005 (scrape): ParticleUtils.spawnParticlesOnBlockFaces, three to five particles on each face, from the client level's random. They are sent by honeycomb on a block (HoneycombItem.useOn), axe scraping and wax removal (BlockTransformer's TransformParticle.send), dispensed honeycomb, and copper golems being waxed or scraped. - Level event 3002: a struck lightning rod sends sparks along its axis (ParticleUtils.spawnParticlesAlongAxis); without an axis they cover the block's faces. - Eating: LivingEntity.spawnItemParticles, five crumbs every four ticks and sixteen when consumed (Consumable.onConsume), placed in front of the eyes and thrown along the look, as item particles in full colour. They were greyed terrain crumbs above the eyes. They now follow Consumable.shouldEmitParticlesAndSounds with the remaining ticks before the countdown, as LivingEntity does: six times over 32 ticks, not seven, each one a tick earlier. - Snowballs (Snowball.handleEntityEvent(3)): eight item crumbs at rest. Eggs (ThrownEgg): eight scattered by up to 0.04 a tick. - Slime, magma cube and sulfur cube landings (AbstractCubeMob.tick): size × 16 item_slime, flame or sulfur_cube_goo particles around the body, from draws the mob's random also makes on the server. New harness tools/test_emitter_particles_parity.py: the real ParticleUtils emitters and LivingEntity.spawnItemParticles. Part of #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
2.6 KiB
Rust
75 lines
2.6 KiB
Rust
#![forbid(unsafe_code)]
|
|
//! Runs tools/test_emitter_particles_parity.py's emitters through
|
|
//! `particles::on_block_faces`, `particles::along_axis` and
|
|
//! `particles::item_use_particles`.
|
|
use horizon_client::{Result, particles};
|
|
use horizon_core::random::{LegacyRandom, RandomSource};
|
|
use serde_json::Value;
|
|
use std::{
|
|
fs::File,
|
|
io::{BufRead, BufReader, BufWriter, Write},
|
|
};
|
|
|
|
fn d(v: f64) -> String {
|
|
format!("{:016x}", v.to_bits())
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
let args: Vec<String> = std::env::args().collect();
|
|
let mut out = BufWriter::new(File::create(&args[2])?);
|
|
for (n, line) in BufReader::new(File::open(&args[1])?).lines().enumerate() {
|
|
let c: Value = serde_json::from_str(&line?)?;
|
|
writeln!(out, "== {n}")?;
|
|
let mut random = LegacyRandom::new(c["seed"].as_i64().ok_or("seed")?);
|
|
let mut lines = Vec::new();
|
|
let record = |kind: &str| {
|
|
let kind = kind.to_owned();
|
|
move |p: [f64; 3], v: [f64; 3]| {
|
|
format!(
|
|
"+ {kind} {} {} {} {} {} {}",
|
|
d(p[0]),
|
|
d(p[1]),
|
|
d(p[2]),
|
|
d(v[0]),
|
|
d(v[1]),
|
|
d(v[2])
|
|
)
|
|
}
|
|
};
|
|
if c["kind"] == "item_use" {
|
|
let p: [f64; 3] = std::array::from_fn(|i| c["pos"][i].as_f64().unwrap_or(0.0));
|
|
let f = |k: &str| c[k].as_f64().unwrap_or(0.0) as f32;
|
|
let line = record("item");
|
|
particles::item_use_particles(
|
|
&mut random,
|
|
f("pitch"),
|
|
f("yaw"),
|
|
p,
|
|
p[1] + f64::from(f("eye")),
|
|
c["count"].as_u64().unwrap_or(0) as u32,
|
|
|p, v| lines.push(line(p, v)),
|
|
);
|
|
} else {
|
|
let p: [i32; 3] = std::array::from_fn(|i| c["pos"][i].as_i64().unwrap_or(0) as i32);
|
|
match c["axis"].as_i64() {
|
|
Some(axis @ 0..=2) => {
|
|
let line = record("electric_spark");
|
|
particles::along_axis(&mut random, axis as usize, p, |p, v| {
|
|
lines.push(line(p, v))
|
|
});
|
|
}
|
|
_ => {
|
|
let line = record("wax_on");
|
|
particles::on_block_faces(&mut random, p, |p, v| lines.push(line(p, v)));
|
|
}
|
|
}
|
|
}
|
|
for l in lines {
|
|
writeln!(out, "{l}")?;
|
|
}
|
|
writeln!(out, "next {}", random.next_long())?;
|
|
}
|
|
out.flush()?;
|
|
Ok(())
|
|
}
|