One side_mask for the two datafixes, one test MobType for two mobs.rs tests

datafix: LeavesFix's getSideMask is ChunkPalettedStorageFix's, line for
line; chunk_leaves uses chunk_flatten's. mobs.rs: push_tests takes
sensor_scan_tests' 46-line cow MobType instead of its own copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-23 15:37:34 +02:00
parent 172ae241f1
commit ac811d4708
3 changed files with 5 additions and 77 deletions
+2 -49
View File
@@ -2277,7 +2277,7 @@ mod sensor_scan_tests {
use horizon_core::geometry::Vec3;
use serde_json::json;
fn kind() -> Arc<MobType> {
pub(super) fn kind() -> Arc<MobType> {
Arc::new(MobType {
id: "minecraft:cow".into(),
species: Species::Cow,
@@ -2481,56 +2481,9 @@ mod sensor_scan_tests {
}
#[cfg(test)]
mod push_tests {
use super::sensor_scan_tests::kind;
use super::*;
use horizon_core::geometry::Vec3;
use serde_json::json;
fn kind() -> Arc<MobType> {
Arc::new(MobType {
id: "minecraft:cow".into(),
species: Species::Cow,
width: 0.9,
height: 1.4,
eye_height: 1.3,
category: "creature".into(),
max_health: 10.0,
speed: 0.2,
flying_speed: 0.4,
attack_damage: 0.0,
attack_knockback: 0.0,
follow_range: 16.0,
step_height: 0.6,
armor: 0.0,
armor_toughness: 0.0,
knockback_resistance: 0.0,
jump_strength: 0.42,
attributes: Arc::default(),
gravity: 0.08,
safe_fall_distance: 3.0,
fall_damage_multiplier: 1.0,
water_efficiency: 0.0,
water_slowdown: 0.8,
air_speed: 0.02,
baby_scale: 0.5,
head_rot_speed: 10.0,
max_head_x_rot: 40.0,
max_head_y_rot: 75.0,
ambient_interval: 120,
flags: Flags {
animal: true,
..Default::default()
},
model: Arc::new(Part::parse("root", &json!({}))),
layers: HashMap::new(),
texture: String::new(),
brain: Brain::Passive,
anim: Anim::Rabbit,
sounds: [""; 3],
step_sound: None,
food: Arc::default(),
tempt: Arc::default(),
})
}
/// The pending pushes as one list, scanned for each mob, as before.
fn take_old(events: &mut Vec<MobEvent>, from: usize, pending: &mut Vec<(u32, Vec3)>) {
@@ -266,8 +266,8 @@ fn is_virtual(block: usize) -> bool {
VIRTUAL.contains(&block)
}
/// `getSideMask`.
fn side_mask(west: bool, east: bool, north: bool, south: bool) -> i32 {
/// `getSideMask` (LeavesFix has the same copy).
pub(super) fn side_mask(west: bool, east: bool, north: bool, south: bool) -> i32 {
let mut s = 0;
if north {
if east {
@@ -6,6 +6,7 @@
//! emulated here (`IntOpenHashSet` and the key order of an `Int2ObjectOpenHashMap`).
use std::collections::{HashMap, HashSet};
use super::chunk_flatten::side_mask;
use super::dynamic::{as_int, as_long_stream, as_str, ceillog2, set};
use crate::nbt::Tag;
@@ -355,32 +356,6 @@ fn get_index(x: i32, y: i32, z: i32) -> i32 {
y << 8 | z << 4 | x
}
fn side_mask(west: bool, east: bool, north: bool, south: bool) -> i32 {
let mut s = 0;
if north {
if east {
s |= 2;
} else if west {
s |= 128;
} else {
s |= 1;
}
} else if south {
if west {
s |= 32;
} else if east {
s |= 8;
} else {
s |= 16;
}
} else if east {
s |= 4;
} else if west {
s |= 64;
}
s
}
/// `LeavesFix` over a chunk (`{Level: ...}`).
pub(super) fn leaves_fix(chunk: &mut Tag) {
let Some(level) = chunk.get_mut("Level") else {