-- tools/fixtures/schematic.py helper: our model/schematic encoder's output for the reference readers (litemapy, -- nbtlib). Prints "\t" lines. Inputs: the decoded fixtures of tests/gen/schematic, plus grids built here. local Schematic = require("@rosetta/model/schematic") local Bytes = require("@rosetta/core/Bytes") local Types = require("@rosetta/Types") local Fx = require("@tests/gen/schematic") local function hex(b: buffer): string local t = table.create(buffer.len(b)) for i = 0, buffer.len(b) - 1 do t[i + 1] = string.format("%02x", buffer.readu8(b, i)) end return table.concat(t) end local function emit(name: string, b: buffer?, e: any) if not b then error(name .. ": " .. tostring(e)) end print(name .. "\t" .. hex(b)) end local byName = {} for _, c in Fx.cases do byName[c.name] = assert(Schematic.decode(Bytes.reader(buffer.fromstring(c.data)))) end -- same variant (fields kept), and across variants emit("litemapy.litematic", Schematic.encode(byName.litemapy)) emit("litemapy.schem", Schematic.encode(byName.litemapy, { variant = "schem", version = 2 })) emit("sponge2.schem", Schematic.encode(byName.sponge2)) emit("sponge2.litematic", Schematic.encode(byName.sponge2, { variant = "litematic" })) emit("sponge3.schem", Schematic.encode(byName.sponge3)) emit("sponge3v2.schem", Schematic.encode(byName.sponge3, { version = 2 })) emit("sponge1.schem", Schematic.encode(byName.sponge1)) emit("mcedit.schematic", Schematic.encode(byName.mcedit)) emit("worldedit_add.schematic", Schematic.encode(byName.worldedit_add)) emit("sponge2.schematic", Schematic.encode(byName.sponge2, { variant = "schematic" })) emit("mcedit.schem", Schematic.encode(byName.mcedit, { variant = "schem" })) -- a colour grid (no block states): each palette colour becomes the block nearest in colour local v = Types.Voxels.new(4, 3, 2) v.palette[1] = { 160, 40, 35, 255 } v.palette[2] = { 125, 125, 125, 255 } v.palette[3] = { 60, 110, 230, 120 } for i = 0, 4 * 3 * 2 - 1 do buffer.writeu8(v.data, i, i % 4) end emit("colors.schem", Schematic.encode(v)) emit("colors.litematic", Schematic.encode(v, { variant = "litematic" })) emit("colors.schematic", Schematic.encode(v, { variant = "schematic" }))