From 8eca39aff1baca12c5244568a2f6bc4e063bc351 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 11 Oct 2026 16:07:06 +0200 Subject: [PATCH] Equip, saddle and light from dispensers as vanilla does Villagers, piglins, piglin brutes, allays, dolphins, foxes and pandas can pick up loot from construction (their constructors call setCanPickUpLoot), so they take dispensed equipment without spawn finalization. Nautilus saddles play item.nautilus_saddle_equip. The oracle level is the overworld, so fire in an obsidian frame lights a portal there too, and it answers getEntity(id) and level-wide entity queries, which leash cutting needs. Unseeded item motion is compared within its full spread (item motion plus a shearing sheep's push). Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/dispenser.rs | 4 ++-- crates/horizon-client/src/mobs.rs | 12 ++++++++++++ .../parity/VanillaBlockUpdateOracle.java | 19 +++++++++++++++++++ .../parity/VanillaDispenserOracle.java | 1 + tools/test_dispenser_parity.py | 9 ++++++--- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/game/dispenser.rs b/crates/horizon-client/src/game/dispenser.rs index e8a3ecffa..bfbea7038 100644 --- a/crates/horizon-client/src/game/dispenser.rs +++ b/crates/horizon-client/src/game/dispenser.rs @@ -283,9 +283,9 @@ fn equip_sound(m: &Mob, slot: Slot, default: Option) -> Option { _ if equine(s) => "minecraft:entity.horse.saddle".into(), _ if horizon_client::mobs::nautilus::is_nautilus(s) => { if m.fluids.eye_in_water { - "minecraft:entity.nautilus.saddle_underwater_equip".into() + "minecraft:item.nautilus_saddle_underwater_equip".into() } else { - "minecraft:entity.nautilus.saddle_equip".into() + "minecraft:item.nautilus_saddle_equip".into() } } _ => return default, diff --git a/crates/horizon-client/src/mobs.rs b/crates/horizon-client/src/mobs.rs index ff0e37fa5..eb186d7ae 100644 --- a/crates/horizon-client/src/mobs.rs +++ b/crates/horizon-client/src/mobs.rs @@ -994,6 +994,18 @@ impl Mob { }, kind, }; + // setCanPickUpLoot(true) in the Villager, AbstractPiglin, Allay, + // Dolphin, Fox and Panda constructors. + mob.extra.pick_up_loot = matches!( + mob.species(), + Species::Villager + | Species::Piglin + | Species::PiglinBrute + | Species::Allay + | Species::Dolphin + | Species::Fox + | Species::Panda + ); ai::register(&mut mob); mob } diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java index 21908b3e2..037788547 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaBlockUpdateOracle.java @@ -217,6 +217,23 @@ public final class VanillaBlockUpdateOracle { } } } + /** ServerLevel.getEntity(id) over the level's entities. */ + @Override public Entity getEntity(int id) { + if (entities == null) return null; + for (Entity e : entities) if (e.getId() == id && !e.isRemoved()) return e; + return null; + } + /** Every entity of the level (no area), as ServerLevel's entity getter would. */ + @Override public void getEntities(net.minecraft.world.level.entity.EntityTypeTest type, java.util.function.Predicate filter, List out, int max) { + if (entities == null) return; + for (Entity e : List.copyOf(entities)) { + T t = type.tryCast(e); + if (t != null && !e.isRemoved() && filter.test(t)) { + out.add(t); + if (out.size() >= max) return; + } + } + } @Override public List getEntitiesOfClass(Class type, AABB box, java.util.function.Predicate filter) { return getEntities(net.minecraft.world.level.entity.EntityTypeTest.forClass(type), box, filter); } @@ -297,6 +314,8 @@ public final class VanillaBlockUpdateOracle { return attributes; } @Override public net.minecraft.world.level.dimension.DimensionType dimensionType() { return OVERWORLD_TYPE; } + /** The overworld (fire in an obsidian frame lights a portal here). */ + @Override public net.minecraft.resources.ResourceKey dimension() { return net.minecraft.world.level.Level.OVERWORLD; } @Override public long getOverworldClockTime() { return DAY.totalTicks(); } @Override public float getMoonBrightness(BlockPos p) { return net.minecraft.world.level.dimension.DimensionType.MOON_BRIGHTNESS_PER_PHASE[environmentAttributes().getValue(net.minecraft.world.attribute.EnvironmentAttributes.MOON_PHASE, p).index()]; diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java index 0aba1dce4..85ab872e5 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java @@ -84,6 +84,7 @@ public final class VanillaDispenserOracle { } catch (Throwable e) { Throwable c = e; while (c.getCause() != null) c = c.getCause(); + if (System.getenv("ORACLE_TRACE") != null) c.printStackTrace(); StackTraceElement[] st = c.getStackTrace(); result.clear(); result.add("error " + c.getClass().getSimpleName() + " " + (st.length > 0 ? st[0].toString() : "") + " " + c.getMessage()); diff --git a/tools/test_dispenser_parity.py b/tools/test_dispenser_parity.py index 4dbb83b13..85d15a100 100644 --- a/tools/test_dispenser_parity.py +++ b/tools/test_dispenser_parity.py @@ -272,8 +272,9 @@ def cases(facts, count, seed, only): if target['type'] == 'minecraft:sulfur_cube' and rng.random() < 0.5: target['equip'] = {'body': plain(rng.choice(SWALLOWED))} # Leads: tied to an earlier target, or that target holds this one's. - if entities and rng.random() < 0.3: - target['leash'] = rng.randrange(len(entities)) + holders = [i for i, e in enumerate(entities) if e['type'] != 'minecraft:armor_stand'] + if holders and rng.random() < 0.3: + target['leash'] = rng.choice(holders) entities.append(target) if bare == 'shears' and len(entities) == 1 and rng.random() < 0.3: # A holder out of the dispenser's reach whose lead runs to the target. @@ -320,7 +321,9 @@ def numbers_close(java, rust): for x, y in zip(a, b): if x.startswith('~'): try: - if abs(float(x[1:]) - float(y)) > 0.25: + # An item's own motion spans 0.2 per axis, and a shearing + # sheep pushes each wool with its own random by up to 0.1 more. + if abs(float(x[1:]) - float(y)) > 0.4: return False except ValueError: return False