Public Access
Release machine acceleration, dropped books and baseline defaults for both tracks
Build and smoke / changes (push) Waiting to run
Build and smoke / changes (push) Waiting to run
This commit is contained in:
1 parent
d199ac253e
commit
6630ed7ab1
72 files changed
+2390
-108
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Average a JSON-exported SavedData block profile, including zero-count chunks."""
|
||||
import argparse
|
||||
import collections
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
def generate(source, version):
|
||||
raw = source.read_bytes()
|
||||
data = json.loads(raw)["nbt"]["data"]
|
||||
samples = data.get("Samples", data.get("samples"))
|
||||
if not samples:
|
||||
raise ValueError("The source profile has no sampled chunks")
|
||||
totals = collections.Counter()
|
||||
for sample in samples:
|
||||
counts = sample.get("Blocks", sample.get("blocks"))
|
||||
if not isinstance(counts, dict) or any(not isinstance(n, int) or n < 0 for n in counts.values()):
|
||||
raise ValueError("Invalid sampled block counts")
|
||||
totals.update(counts)
|
||||
return {
|
||||
"minecraft_version": version,
|
||||
"source_sample_count": len(samples),
|
||||
"source_sha256": hashlib.sha256(raw).hexdigest(),
|
||||
"blocks_per_chunk": {key: total / len(samples) for key, total in sorted(totals.items())},
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("source", type=Path)
|
||||
parser.add_argument("version", choices=("1.21.1", "26.3"))
|
||||
parser.add_argument("output", type=Path)
|
||||
args = parser.parse_args()
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(json.dumps(generate(args.source, args.version), indent=2) + "\n")
|
||||
Reference in new issue
Block a user