Creative inventory: every tab and the search as vanilla builds them; scrollbar drag

The creative-tabs.json export failed to build the functional blocks tab (no
data-pack registries: banner patterns), and its fallback read decompiled
sources from a path that no longer exists, so the tab was empty and anvils,
crafting and smithing tables were missing from the tabs and the search. The
search also matched only an approximate display name.

VanillaCreativeTabsExporter now builds every tab with vanilla's own
CreativeModeTabs.tryRebuildTabContents over the vanilla data pack's
registries and writes creative-inventory.json: stacks with components, and
the search tab's creative tooltip lines and tags. The client searches them
as SessionSearchTrees does (FullTextSearchTree, IdSearchTree after '#').
Changing tab empties the search box, as in selectTab.

The scrollbar only jumped to the pressed point; holding it now scrolls as
the mouse moves, anywhere, until release (mouseClicked/mouseDragged), and
the wheel and the scroller follow ItemPickerMenu.

tools/test_creative_parity.py compares every tab and 6,793 searches with
the vanilla client's own search trees. horizon-ctl `type` also fills the
creative search box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-13 22:24:55 +02:00
parent 97245773d1
commit cac89a9995
9 changed files with 783 additions and 127 deletions
+9 -33
View File
@@ -413,21 +413,23 @@ def main():
'dev.horizonlab.parity.VanillaCommandParseOracle', 'registries', str(export)],
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
command_registries.write_bytes((export / 'registries.json').read_bytes())
creative = root / 'creative-tabs.json'
creative_oracle = oracle.with_name('VanillaCreativeTabsExporter.java')
creative_sources = base.source_hashes([creative_oracle])
# The creative inventory (creative-inventory.json): every tab built by vanilla's
# CreativeModeTabs over the vanilla data pack's registries, with the search
# tab's tooltip lines and tags.
creative = root / 'creative-inventory.json'
creative_oracles = [oracle.with_name('VanillaCreativeTabsExporter.java'), oracle.with_name('ParityData.java')]
creative_sources = base.source_hashes(creative_oracles)
if not (previous.get('creative_exporters_sha256') == creative_sources and creative.exists()
and previous.get('server_sha256') == origin['server_sha256']):
classes = lab.LOCAL / 'creative-tabs' / 'classes'; classes.mkdir(parents=True, exist_ok=True)
classes = lab.LOCAL / 'creative-inventory' / 'classes'; classes.mkdir(parents=True, exist_ok=True)
dependencies = os.pathsep.join(map(str, [jars['server'], *libraries]))
with (root / 'creative-export.log').open('w') as log:
subprocess.run(['javac', '--release', str(lock['minecraft']['java_major']), '-proc:none',
'-cp', dependencies, '-d', str(classes), str(creative_oracle)],
'-cp', dependencies, '-d', str(classes), *map(str, creative_oracles)],
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
subprocess.run(['java', '-Xmx1G', '-cp', str(classes) + os.pathsep + dependencies,
subprocess.run(['java', '-Xmx2G', '-cp', str(classes) + os.pathsep + dependencies,
'dev.horizonlab.parity.VanillaCreativeTabsExporter', str(creative)],
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
recover_creative_tabs(creative, root)
lab.write_json(manifest, {'schema': 7, **origin,
'health_exporters_sha256': health_sources,
'health_files_sha256': {name: lab.digest(root/name, 'sha256') for name in health_files},
@@ -451,31 +453,5 @@ def main():
print(f'Prepared Horizon native-client resources: {root}')
def recover_creative_tabs(path, root):
"""Tabs whose generators need dynamic registries (banner patterns) fail in
the bare bootstrap; recover their item order from the decompiled source."""
import re
tabs = json.loads(path.read_text())
source = lab.LOCAL / 'decompiled/net/minecraft/world/item/CreativeModeTabs.java'
if not source.exists():
return
items = json.loads((root / 'items.json').read_text())
text = source.read_text()
for tab in tabs:
if tab['items'] or tab['type'] != 'CATEGORY':
continue
name = tab['id'].split(':')[1].upper()
start = text.find(f'{name},')
end = text.find('Registry.register(', start + 1)
found = []
for m in re.finditer(r'\b(Items|Blocks)\.([A-Z0-9_]+)(?:\.(\w+)\(\))?', text[start:end]):
base, colour = m.group(2).lower(), m.group(3)
item = 'minecraft:' + (f'{colour}_{base}' if colour and colour not in ('asItem', 'defaultBlockState', 'get') else base)
if item in items and item not in found:
found.append(item)
tab['items'] = found
path.write_text(json.dumps(tabs))
if __name__ == '__main__':
main()