ws-voxel: model/schematic (.schem v1-3, .schematic, .litematic read + write), codecs/model/Minecraft (block states, default colours, legacy ids, packed arrays)
Types change (backward compatible): Types.Voxels gains optional blocks (VoxelBlocks: exact block states as u16 indices into a state palette, block entities, entities) and colors (exact u32 RGBA per cell). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c908ed9ad7
commit
166f3f8eee
11 files changed
+524
-40
No files matched your search
@@ -53,21 +53,18 @@ Legacy.RENAMED = {
|
||||
melon_block = "melon", lit_pumpkin = "jack_o_lantern", slime = "slime_block", magma = "magma_block",
|
||||
red_nether_brick = "red_nether_bricks", nether_brick = "nether_bricks", end_bricks = "end_stone_bricks",
|
||||
mob_spawner = "spawner", web = "cobweb", snow_layer = "snow", snow = "snow_block", noteblock = "note_block",
|
||||
quartz_ore = "nether_quartz_ore", reeds = "sugar_cane", waterlily = "lily_pad", flowing_water = "water",
|
||||
flowing_lava = "lava", tallgrass = "short_grass", grass_path = "dirt_path", double_stone_slab = "smooth_stone",
|
||||
stone_slab = "smooth_stone_slab", deadbush = "dead_bush", yellow_flower = "dandelion",
|
||||
|
||||
quartz_ore = "nether_quartz_ore", reeds = "sugar_cane", waterlily = "lily_pad",
|
||||
tallgrass = "short_grass", grass_path = "dirt_path", double_stone_slab = "smooth_stone",
|
||||
stone_slab = "smooth_stone_slab", deadbush = "dead_bush", yellow_flower = "dandelion",
|
||||
fence = "oak_fence", fence_gate = "oak_fence_gate",
|
||||
wooden_door = "oak_door", trapdoor = "oak_trapdoor", wooden_pressure_plate = "oak_pressure_plate",
|
||||
wooden_button = "oak_button", stone_stairs = "cobblestone_stairs", standing_sign = "oak_sign",
|
||||
wall_sign = "oak_wall_sign", golden_rail = "powered_rail", portal = "nether_portal", piston_extension = "moving_piston",
|
||||
|
||||
silver_shulker_box = "light_gray_shulker_box", silver_glazed_terracotta = "light_gray_glazed_terracotta",
|
||||
|
||||
monster_egg = "infested_stone",
|
||||
standing_banner = "white_banner", wall_banner = "white_wall_banner", skull = "skeleton_skull",
|
||||
bed = "red_bed",
|
||||
}
|
||||
} :: { [string]: string }
|
||||
|
||||
-- legacy names whose data value selects the variant: the modern names by data value (0-based)
|
||||
local DYED = "white orange magenta light_blue yellow lime pink gray light_gray cyan purple blue brown green red black"
|
||||
@@ -105,7 +102,7 @@ Legacy.VARIANTS = {
|
||||
stained_hardened_clay = dyed("terracotta"),
|
||||
concrete = dyed("concrete"),
|
||||
concrete_powder = dyed("concrete_powder"),
|
||||
}
|
||||
Legacy.MASK = { log = 4, log2 = 4, leaves = 4, leaves2 = 4, sapling = 8, wooden_slab = 8, quartz_block = 8, double_plant = 8 }
|
||||
} :: { [string]: { string } }
|
||||
Legacy.MASK = { log = 4, log2 = 4, leaves = 4, leaves2 = 4, sapling = 8, wooden_slab = 8, quartz_block = 8, double_plant = 8 } :: { [string]: number }
|
||||
|
||||
return Legacy
|
||||
@@ -121,18 +121,18 @@ end
|
||||
|
||||
local EXACT: { [string]: { number } } = {}
|
||||
for name, h in string.gmatch(Colors.BLOCKS, "([%w_]+)=(%x+)") do
|
||||
EXACT[name] = hex(h)
|
||||
EXACT[name :: string] = hex(h :: string)
|
||||
end
|
||||
local WOOL, CONCRETE, TERRACOTTA = list(Colors.WOOL), list(Colors.CONCRETE), list(Colors.TERRACOTTA)
|
||||
local PLANKS, BARK, LEAVES = list(Colors.PLANKS), list(Colors.BARK), list(Colors.LEAVES)
|
||||
-- longest prefixes first, so light_blue wins over blue and dark_oak over oak
|
||||
local function byLength(names: { string }): { { any } }
|
||||
local out = {}
|
||||
local out: { { any } } = {}
|
||||
for i, n in names do
|
||||
table.insert(out, { n, i })
|
||||
end
|
||||
table.sort(out, function(a, b)
|
||||
return #a[1] > #b[1]
|
||||
table.sort(out, function(a: { any }, b: { any }): boolean
|
||||
return #(a[1] :: string) > #(b[1] :: string)
|
||||
end)
|
||||
return out
|
||||
end
|
||||
@@ -141,8 +141,8 @@ local SUFFIXES = {
|
||||
"_wall_hanging_sign", "_hanging_sign", "_wall_sign", "_sign", "_fence_gate", "_fence", "_pressure_plate", "_button",
|
||||
"_trapdoor", "_door", "_stairs", "_slab", "_wall", "_pane", "_carpet", "_wall_banner", "_banner", "_bars",
|
||||
}
|
||||
local PREFIXES = { "waxed_", "potted_", "infested_", "lit_", "unlit_", "unpowered_", "powered_", "chipped_", "damaged_" }
|
||||
local CORAL = { tube = hex("3157d0"), brain = hex("cf5b9f"), bubble = hex("a118a0"), fire = hex("a6252f"), horn = hex("d8c53e") }
|
||||
local PREFIXES = { "waxed_", "potted_", "flowing_", "infested_", "lit_", "unlit_", "unpowered_", "powered_", "chipped_", "damaged_" }
|
||||
local CORAL: { [string]: { number } } = { tube = hex("3157d0"), brain = hex("cf5b9f"), bubble = hex("a118a0"), fire = hex("a6252f"), horn = hex("d8c53e") }
|
||||
local FALLBACK = hex("909090")
|
||||
|
||||
local function mix(c: { number }, w: { number }, t: number): { number }
|
||||
|
||||
Reference in new issue
Block a user