383fc116c9
Villagers showed one angry, happy or heart particle where vanilla's AbstractVillager.addParticlesAroundSelf shows five, spread over the body with Gaussian motion. Taming and love bursts were spread about the middle of the body rather than over it, and drew from the world random. particles::around_self places a burst as the client handlers do: per particle three Gaussian speeds, then getRandomX(1), getRandomY() + y, getRandomZ(1). Burst holds the counts, speeds and heights vanilla uses, and entity_event_burst maps entity events to them. The client side uses the particle engine's random, so no server draw moves. - villager hurt by a player, failed breeding (13), breeding hearts and the child's (12), trades, job sites and beds (14): five particles about the villager, not one 1.8 above its feet. - wolf, cat, parrot, nautilus and horse taming (7/6): seven hearts or smoke about the body. - allay duplication (18): three hearts about the allay. - llama growth from food: one particle at rest about the body. - animals in love: the heart moves at the Gaussian speeds already drawn, exactly where vanilla puts it; forced growth's particle sits where it was placed (sendParticles with no spread) instead of being jittered. New harness tools/test_entity_particles_parity.py: the real client handleEntityEvent of Villager, Animal, TamableAnimal, AbstractHorse, Ocelot, Dolphin and Allay against entity_event_burst and around_self. Part of #63 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
1.8 KiB
Rust
52 lines
1.8 KiB
Rust
#![forbid(unsafe_code)]
|
|
//! Runs tools/test_entity_particles_parity.py's entity events through
|
|
//! `particles::entity_event_burst` and `particles::around_self`.
|
|
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 feet: [f64; 3] = std::array::from_fn(|i| c["feet"][i].as_f64().unwrap_or(0.0));
|
|
// EntityDimensions hold floats.
|
|
let width = f64::from(c["width"].as_f64().unwrap_or(0.0) as f32);
|
|
let height = f64::from(c["height"].as_f64().unwrap_or(0.0) as f32);
|
|
let entity = c["entity"].as_str().unwrap_or("");
|
|
if let Some((kind, burst)) =
|
|
particles::entity_event_burst(entity, c["event"].as_u64().unwrap_or(0) as u8)
|
|
{
|
|
let mut lines = Vec::new();
|
|
particles::around_self(&mut random, feet, width, height, burst, |p, v| {
|
|
lines.push(format!(
|
|
"+ {kind} {} {} {} {} {} {}",
|
|
d(p[0]),
|
|
d(p[1]),
|
|
d(p[2]),
|
|
d(v[0]),
|
|
d(v[1]),
|
|
d(v[2])
|
|
));
|
|
});
|
|
for l in lines {
|
|
writeln!(out, "{l}")?;
|
|
}
|
|
}
|
|
writeln!(out, "next {}", random.next_long())?;
|
|
}
|
|
out.flush()?;
|
|
Ok(())
|
|
}
|