52 lines
2.6 KiB
Python
52 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate tiny original Sponge fixtures using independent nbtlib2.0.4.
|
|
|
|
Run with artifacts/compat-venv/bin/python after installing nbtlib==2.0.4.
|
|
The fixture contains no game assets or third-party map content.
|
|
"""
|
|
from pathlib import Path
|
|
import gzip
|
|
import io
|
|
import nbtlib as n
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
out = ROOT / "crates/shacraft-compat/fixtures"
|
|
out.mkdir(parents=True, exist_ok=True)
|
|
metadata = n.Compound({
|
|
"Name": n.String("Шакрафт тест"), "Byte": n.Byte(-128),
|
|
"Short": n.Short(-32768), "Long": n.Long(-9223372036854775808),
|
|
"Float": n.Float(1.25), "Double": n.Double(-2.5),
|
|
"ByteArray": n.ByteArray([-1, 0, 127]),
|
|
"IntArray": n.IntArray([-2147483648, 2147483647]),
|
|
"LongArray": n.LongArray([-9223372036854775808, 9223372036854775807]),
|
|
"EmptyLongList": n.List[n.Long]([]),
|
|
"Nested": n.Compound({"custom_unknown": n.String("keep me")}),
|
|
})
|
|
entity = n.Compound({"Id": n.String("minecraft:armor_stand"),
|
|
"Pos": n.List[n.Double]([1.5, 1.0, 0.5]),
|
|
"Data": n.Compound({"UUID": n.IntArray([1, 2, 3, 4]), "NoGravity": n.Byte(1)})})
|
|
blockentity = n.Compound({"Id": n.String("minecraft:chest"),
|
|
"Pos": n.IntArray([0, 0, 0]), "Data": n.Compound({
|
|
"Items": n.List[n.Compound]([n.Compound({"Slot": n.Byte(0),
|
|
"id": n.String("minecraft:diamond"), "count": n.Int(3)})]),
|
|
"unknown_inventory_tag": n.Long(12345678901234567),
|
|
})})
|
|
states = ["minecraft:air", "minecraft:chest[facing=north,type=single,waterlogged=false]",
|
|
"minecraft:oak_stairs[facing=east,half=bottom,shape=straight,waterlogged=false]",
|
|
"example:unknown[facing=west]", "minecraft:stone"]
|
|
indices = [1, 2, 3, 4] + [0] * 20
|
|
schematic = n.Compound({"Version": n.Int(3), "DataVersion": n.Int(4903),
|
|
"Width": n.Short(4), "Height": n.Short(3), "Length": n.Short(2),
|
|
"Offset": n.IntArray([-17, -1, 31]), "Metadata": metadata,
|
|
"Blocks": n.Compound({"Palette": n.Compound({s: n.Int(i) for i, s in enumerate(states)}),
|
|
"Data": n.ByteArray(indices), "BlockEntities": n.List[n.Compound]([blockentity])}),
|
|
"Biomes": n.Compound({"Palette": n.Compound({"minecraft:plains": n.Int(0), "minecraft:desert": n.Int(1)}),
|
|
"Data": n.ByteArray([i % 2 for i in range(24)])}),
|
|
"Entities": n.List[n.Compound]([entity]),
|
|
"UnknownRoot": n.Compound({"opaque": n.String("preserve this")}),
|
|
})
|
|
f = n.File({"Schematic": schematic}, root_name="")
|
|
buffer = io.BytesIO(); f.write(buffer)
|
|
(out / "sponge-v3.schem").write_bytes(gzip.compress(buffer.getvalue(), mtime=0))
|
|
print(out / "sponge-v3.schem")
|