0b362e270f
Taming any wolf also granted The Whole Pack and A Complete Catalogue: entity predicates treated minecraft:components as always true, so every tame_animal criterion of those advancements (one per wolf or cat variant) matched the first animal tamed. EntityPredicate tests them with DataComponentExactPredicate against what the entity reports through Entity.get (Wolf.get(WOLF_VARIANT) and so on): mobs now report their variant component (wolf, cat, frog, pig, cow, chicken, zombie nautilus) and the predicate compares it, an absent component never matching. Checked against the real EntityPredicate of every criterion of the variant advancements on real entities of every variant by tools/test_entity_components_parity.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.8 KiB
Python
68 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare the entity predicates of the variant advancements (A Complete
|
|
Catalogue, The Whole Pack, Leash all frog variants) with the pinned client: the
|
|
real EntityPredicate of each criterion, decoded from the advancement files,
|
|
tested on real wolves, cats, frogs, pigs, cows and chickens of every variant
|
|
(the variant data components Entity.get reports for minecraft:components)."""
|
|
import json
|
|
import random
|
|
|
|
try:
|
|
from . import lab, oracle_harness as harness
|
|
except ImportError:
|
|
import lab, oracle_harness as harness
|
|
|
|
ADVANCEMENTS = ('complete_catalogue', 'whole_pack', 'leash_all_frog_variants')
|
|
SPECIES = ('wolf', 'cat', 'frog', 'pig', 'cow', 'chicken')
|
|
|
|
|
|
def predicates():
|
|
"""Every criterion's entity predicate, plus the components alone and
|
|
with the wrong type."""
|
|
folder = lab.LOCAL / 'horizon-client/26.3/data/minecraft/advancement/husbandry'
|
|
out = []
|
|
for name in ADVANCEMENTS:
|
|
data = json.loads((folder / f'{name}.json').read_text())
|
|
for criterion in data['criteria'].values():
|
|
predicate = criterion['conditions']['entity']['predicate']
|
|
out.append(predicate)
|
|
components = {'minecraft:components': predicate['minecraft:components']}
|
|
out.append(components)
|
|
out.append(dict(components, **{'minecraft:entity_type': 'minecraft:pig'}))
|
|
return out
|
|
|
|
|
|
def variants(species):
|
|
folder = lab.LOCAL / f'horizon-client/26.3/data/minecraft/{species}_variant'
|
|
return sorted('minecraft:' + p.stem for p in folder.glob('*.json'))
|
|
|
|
|
|
def make_cases(build):
|
|
path = build / 'cases.jsonl'
|
|
every = predicates()
|
|
rng = random.Random(0x56415249)
|
|
count = 0
|
|
with path.open('w') as out:
|
|
for species in SPECIES:
|
|
for variant in variants(species):
|
|
listed = every + [rng.choice(every) for _ in range(8)]
|
|
case = dict(type='minecraft:' + species, variant=variant, predicates=listed)
|
|
out.write(json.dumps(case, separators=(',', ':')) + '\n')
|
|
count += 1
|
|
return path, count
|
|
|
|
|
|
def main():
|
|
scope = ('The real EntityPredicate of every criterion of complete_catalogue, whole_pack and '
|
|
'leash_all_frog_variants (and their minecraft:components alone, or with another entity type), decoded '
|
|
'with the registries\' ops, on entities made with EntityType.create(LOAD) given each registered variant '
|
|
'of their species through Entity.setComponent. The trigger dispatch around them is not exercised.')
|
|
harness.differential(
|
|
'rust-entity-components-parity', 'VanillaEntityComponentsOracle', 'entity_components_probe', make_cases, scope,
|
|
sources=[lab.ROOT / 'crates/horizon-client/src/advancements.rs',
|
|
lab.ROOT / 'crates/horizon-client/src/mobs/finalize.rs'])
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|