#!/usr/bin/env python3 """The sound registry of the Rustex remake as a table. The remake keeps its sounds in two places: the files under sounds/ and fsounds/ and the registry sounds.json plus rustex_sounds.json, which say which file belongs to which event. The result is one csv: rsx-protocol/src/main/resources/items/sounds.csv with the columns id, file, volume, pitch. """ import csv import json import sys from pathlib import Path ROOT = Path(r"G:\RustNotMC") ASSETS = ROOT / "assets" / "rustex" / "legacy" / "minecraft" OUT = ROOT / "rsx-protocol" / "src" / "main" / "resources" / "items" / "sounds.csv" def collect(path: Path, out: dict): if not path.is_file(): return data = json.loads(path.read_text(encoding="utf-8", errors="replace")) for key, value in data.items(): if not isinstance(value, dict): continue sounds = value.get("sounds") if isinstance(sounds, list): for sound in sounds: if isinstance(sound, dict) and "name" in sound: out.setdefault(key, []).append( (sound["name"], sound.get("volume", 1.0), sound.get("pitch", 1.0))) elif isinstance(sounds, str): out.setdefault(key, []).append((sounds, 1.0, 1.0)) name = value.get("name") if isinstance(name, str): out.setdefault(key, []).append((name, 1.0, 1.0)) def main() -> int: out = {} collect(ASSETS / "sounds.json", out) collect(ASSETS / "rustex_sounds.json", out) print("событий:", len(out)) OUT.parent.mkdir(parents=True, exist_ok=True) rows = 0 with OUT.open("w", encoding="utf-8", newline="") as handle: writer = csv.writer(handle) writer.writerow(["id", "file", "volume", "pitch"]) for key in sorted(out): for name, volume, pitch in out[key]: writer.writerow([key, name, volume, pitch]) rows += 1 print("строк:", rows, "->", OUT) # The sounds that came with the remake, so that we know what exists. files = 0 for base in (ASSETS / "sounds", ROOT / "assets" / "rustex" / "legacy" / "assets" / "fsounds"): if base.is_dir(): files += sum(1 for _ in base.rglob("*.ogg")) print("файлов ogg на диске:", files) return 0 if __name__ == "__main__": sys.exit(main())