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 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-11 16:07:06 +02:00
parent 894113d7f4
commit 8eca39aff1
5 changed files with 40 additions and 5 deletions
+2 -2
View File
@@ -283,9 +283,9 @@ fn equip_sound(m: &Mob, slot: Slot, default: Option<String>) -> Option<String> {
_ 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,
+12
View File
@@ -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
}
@@ -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 <T extends Entity> void getEntities(net.minecraft.world.level.entity.EntityTypeTest<Entity, T> type, java.util.function.Predicate<? super T> filter, List<? super T> 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 <T extends Entity> List<T> getEntitiesOfClass(Class<T> type, AABB box, java.util.function.Predicate<? super T> 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<net.minecraft.world.level.Level> 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()];
@@ -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());
+6 -3
View File
@@ -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