Keep decoration fixtures independent of region tick and query probes

This commit is contained in:
Ludovic Marie
2026-10-06 14:03:31 +02:00
parent 43d5793f6b
commit 619f319924
3 changed files with 18 additions and 6 deletions
+9 -2
View File
@@ -4,8 +4,15 @@ from tools import test_feature_region_parity as regions
class FeatureRegionCorpusTests(unittest.TestCase):
def test_resident_mutation_contexts_and_failures(self):
fixtures = list(regions.corpus({}))
self.assertEqual(fixtures, list(regions.corpus({})))
facts = {'defaults': {'minecraft:water': 0, 'minecraft:oak_log': 1},
'states': [[None, None, None, None, {'id': 'minecraft:water'}],
[None, None, None, None, {'id': 'minecraft:oak_log', 'properties': {'axis': 'y'}}],
[None, None, None, None, {'id': 'minecraft:oak_log', 'properties': {'axis': 'x'}}]]}
fixtures = list(regions.corpus(facts))
self.assertEqual(fixtures, list(regions.corpus(facts)))
self.assertEqual(sorted(i for f in fixtures for i in f['probe_states']), list(range(len(facts['states']))))
self.assertTrue(all(len(f['tick_commands']) == 77 for f in fixtures))
self.assertTrue(all(f['features'][-1]['type'] == 'spring_feature' for f in fixtures))
self.assertEqual({f['worldgen'] for f in fixtures}, {False, True})
self.assertEqual({f['legacy'] for f in fixtures}, {False, True})
self.assertEqual({f['stage'] for f in fixtures}, {'empty', 'terrain'})
+2 -2
View File
@@ -20,7 +20,7 @@ except ImportError:
def corpus(facts):
template=next(region.corpus(facts))
features=region.configured_features(include_springs=False)
biomes=[[[0],[1,2],[3,4,5]],[[0],[2],[3,5]],[[1],[2],[4,5]]]
chains=[
[{'type':'count','count':2},{'type':'in_square'},{'type':'heightmap','heightmap':'MOTION_BLOCKING'},{'type':'biome'}],
@@ -36,7 +36,7 @@ def corpus(facts):
for placement in chains:
for mixed in [False,True]:
f=decoration.fixture(biomes,seed,present=[0,1,2,3] if mixed else [0])
f.update(features=template['features'],placements=[placement]*len(template['features']),min=-64,height=64,stage=stage,write_fail=fail,reject=reject)
f.update(features=features,placements=[placement]*len(features),min=-64,height=64,stage=stage,write_fail=fail,reject=reject)
yield f
+7 -2
View File
@@ -18,12 +18,17 @@ except ImportError:
import test_worldgen_parity as worldgen
def corpus(facts):
def configured_features(*, include_springs=True):
leaves=[{'type':name} for name in ['end_island','void_start_platform','end_platform']]
layers=[{'feature':{'type':'fill_layer','height':height,'state':state},'placement':[]} for height,state in [(32,'water'),(16,{'id':'oak_log','properties':{'axis':'x'}}),(8,'air'),(4064,'stone')]]
targets=[{'target':{'predicate_type':'block_match','block':'stone'},'state':'iron_ore'},{'target':{'predicate_type':'block_match','block':'oak_log'},'state':'copper_ore'}]
features=leaves+[{'type':'sequence','features':layers},{'type':'replace_single_block','targets':targets},{'type':'scattered_ore','targets':targets,'size':16,'discard_chance_on_air_exposure':0.5}]
features.append({'type':'spring_feature','state':{'id':'water','properties':{'falling':'false'}},'requires_block_below':False,'rock_count':5,'hole_count':5,'valid_blocks':['air','stone','dirt']})
if include_springs:features.append({'type':'spring_feature','state':{'id':'water','properties':{'falling':'false'}},'requires_block_below':False,'rock_count':5,'hole_count':5,'valid_blocks':['air','stone','dirt']})
return features
def corpus(facts):
features=configured_features()
get=lambda name:facts['defaults']['minecraft:'+name]
log_x=next(i for i,state in enumerate(facts['states']) if state[4]['id']=='minecraft:oak_log' and state[4].get('properties',{}).get('axis')=='x')
ticks=[]