"""Resource registrations and localization, independent of geometry and raster generation.""" import json import os def write_json(path, obj): os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, "w", encoding="utf-8") as f: json.dump(obj, f, ensure_ascii=False, indent=1) def write_registry(out, namespace, models, items, camera_models): a = os.path.join(out, "assets", namespace) d = os.path.join(out, "data", namespace, "horizon") lang = {} NS = namespace for name, title in models: write_json(os.path.join(a, "blockstates", name + ".json"), {"variants": {"": {"model": f"{NS}:block/{name}"}}}) write_json(os.path.join(d, "block", name + ".json"), {"template": "minecraft:stone", "item": False}) lang[f"block.{NS}.{name}"] = title for name, title, _ in items: write_json(os.path.join(a, "models", "item", name + ".json"), {"parent": "minecraft:item/generated", "textures": {"layer0": f"{NS}:item/{name}"}}) write_json(os.path.join(a, "items", name + ".json"), {"model": {"type": "minecraft:model", "model": f"{NS}:item/{name}"}}) write_json(os.path.join(d, "item", name + ".json"), {"template": "minecraft:stick", "max_stack_size": 1}) lang[f"item.{NS}.{name}"] = title # Предметы-иконки для камеры монитора: 3D-модель цели в интерфейсе. for name in camera_models: title = dict(models)[name] write_json(os.path.join(a, "models", "item", "cam_" + name + ".json"), {"parent": f"{NS}:block/{name}", "display": {"gui": {"rotation": [20, 145, 0], "translation": [0, 0, 0], "scale": [0.36, 0.36, 0.36]}}}) write_json(os.path.join(a, "items", "cam_" + name + ".json"), {"model": {"type": "minecraft:model", "model": f"{NS}:item/cam_{name}"}}) write_json(os.path.join(d, "item", "cam_" + name + ".json"), {"template": "minecraft:stick", "max_stack_size": 1}) lang[f"item.{NS}.cam_{name}"] = title write_json(os.path.join(a, "lang", "en_us.json"), lang) write_json(os.path.join(a, "lang", "ru_ru.json"), lang)