use crate::support::common::f64_bits; use horizon_core::{ geometry::Vec3, random::{LegacyRandom, RandomSource, XoroshiroRandom}, }; use horizon_world::consumable::{Consumable, EmissionWorld, UseAnimation}; use horizon_world::{ component_patch::Prototype, item_particles::{self, ItemParticleWorld, ParticleError}, item_stack_refs::{ItemStacks, StackRef}, item_template::ItemTemplate, }; use horizon_world::{ consumable::{ConsumeResult, ConsumptionWorld}, food::FoodData, food_properties::{ConsumptionSound, FoodConsumptionWorld, FoodProperties, SoundCategory}, }; use serde_json::Value; use std::{ fs, io::{self, Write}, path::Path, }; #[derive(Clone, Debug, PartialEq)] enum Component { Damage(i32), Food(FoodProperties), } type Stack = StackRef; type Template = ItemTemplate; fn n(v: &Value, k: &str) -> i32 { v[k].as_i64().unwrap() as i32 } fn fl(v: &Value, k: &str) -> f32 { f32::from_bits(v[k].as_u64().unwrap() as u32) } fn opt(v: Option<&Component>) -> String { match v { None => "none".into(), Some(Component::Damage(v)) => v.to_string(), _ => panic!("not damage"), } } fn fbits(v: f32) -> u32 { if v.is_nan() { 0x7fc00000 } else { v.to_bits() } } fn food_component(c: &Value) -> Option { let f = &c["food_component"]; if f.is_null() { None } else { Some(Component::Food(FoodProperties { nutrition: n(f, "nutrition"), saturation: fl(f, "saturation"), can_always_eat: f["always"].as_bool().unwrap(), })) } } struct World<'a, R> { f: Value, out: &'a mut dyn Write, stack: Stack, random: [R; 2], position: Vec3, changed: bool, calls: i32, first: Option