model formats (mca..x3d): comments are specs only

This commit is contained in:
4DBug committed 2026-11-01 01:54:32 -05:00
1 parent 0bd7b87d2b
commit b952c10222
49 files changed
+310 -936

No files matched your search

+3 -9
View File
@@ -1,9 +1,7 @@
--!strict
-- model/schematic/Litematic: Litematica's .litematic, from the mod's sources (LitematicaSchematic,
-- LitematicaBitArray) as documented by the litemapy project: Metadata (name, author, description, enclosing size,
-- counts, times, preview), several named Regions with a Position and a Size that may be negative, a block-state
-- palette (index 0 = air) and BlockStates packed spanning long boundaries (at least 2 bits), TileEntities (relative
-- to the region's minimum corner), Entities and pending ticks (kept as they are).
-- model/schematic/Litematic: .litematic, from LitematicaSchematic / LitematicaBitArray as documented by litemapy:
-- Metadata, named Regions (Position, Size may be negative), palette (0 = air), BlockStates spanning longs (>= 2 bits),
-- TileEntities relative to the region's minimum corner, Entities and pending ticks.
local Types = require("@rosetta/Types")
local Nbt = require("@rosetta/codecs/text/Nbt")
local Mc = require("@rosetta/codecs/model/Minecraft")
@@ -28,7 +26,6 @@ local function vec(v: { number }): any
return Common.compound({ { "x", v[1] }, { "y", v[2] }, { "z", v[3] } })
end
-- read(root, maxCells) -> { Region }, extra | nil, message
function Litematic.read(root: any, maxCells: number): ({ Common.Region }?, any)
if not Types.isObject(root.Regions) then
return nil, "no Regions"
@@ -106,8 +103,6 @@ function Litematic.read(root: any, maxCells: number): ({ Common.Region }?, any)
}
end
-- write(regions, version, dataVersion, base?, name?) -> the root compound | nil, message. base: the decoded root
-- (Metadata fields and each region's Position / Size signs and pending ticks are kept)
function Litematic.write(regions: { Common.Region }, version: number, dataVersion: number, base: any, title: string?): (any, string?)
local baseRegions = if type(base) == "table" and Types.isObject(base.Regions) then base.Regions else nil
local regs, order = {}, {}
@@ -163,7 +158,6 @@ function Litematic.write(regions: { Common.Region }, version: number, dataVersio
local b = if baseRegions then baseRegions[name] else nil
local bsize = if type(b) == "table" then xyz(b.Size) else nil
if bsize and math.abs(bsize[1]) == sx and math.abs(bsize[2]) == sy and math.abs(bsize[3]) == sz then
-- keep the source's corner and signs
for k = 1, 3 do
if bsize[k] < 0 then
size[k] = bsize[k]