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