From aa8b50b7610a7e49ea896730ccf9b88e064bfc75 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 2 Nov 2026 01:18:32 +0300 Subject: [PATCH 1/6] specify translucent to base:drop, base:falling_block --- res/content/base/entities/drop.json | 3 ++- res/content/base/entities/falling_block.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/res/content/base/entities/drop.json b/res/content/base/entities/drop.json index 951ea5e6c..602d78589 100644 --- a/res/content/base/entities/drop.json +++ b/res/content/base/entities/drop.json @@ -14,5 +14,6 @@ ["radius", 0.3], ["radius", 1.6] ], - "blocking": false + "blocking": false, + "translucent": true } diff --git a/res/content/base/entities/falling_block.json b/res/content/base/entities/falling_block.json index b466c2a11..92446d2d8 100644 --- a/res/content/base/entities/falling_block.json +++ b/res/content/base/entities/falling_block.json @@ -4,5 +4,6 @@ ], "skeleton-name": "base:block", "hitbox": [0.98, 0.98, 0.98], - "solid": true + "solid": true, + "translucent": true } From da89e2d42dd80c0c2605de419304ee39048039ef Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 21 Nov 2026 19:17:37 +0300 Subject: [PATCH 2/6] add base:abstract_stairs and base:brick_stairs --- res/content/base/blocks/abstract_stairs.json | 48 +++++++++++++++ res/content/base/blocks/brick_stairs.json | 6 ++ res/content/base/content.json | 16 ++--- res/content/base/scripts/abstract_stairs.lua | 65 ++++++++++++++++++++ res/models/stairs.vcm | 2 +- res/models/stairs_inner_left.vcm | 3 + res/models/stairs_inner_right.vcm | 3 + res/models/stairs_outer_left.vcm | 2 + res/models/stairs_outer_right.vcm | 2 + 9 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 res/content/base/blocks/abstract_stairs.json create mode 100644 res/content/base/blocks/brick_stairs.json create mode 100644 res/content/base/scripts/abstract_stairs.lua create mode 100644 res/models/stairs_inner_left.vcm create mode 100644 res/models/stairs_inner_right.vcm create mode 100644 res/models/stairs_outer_left.vcm create mode 100644 res/models/stairs_outer_right.vcm diff --git a/res/content/base/blocks/abstract_stairs.json b/res/content/base/blocks/abstract_stairs.json new file mode 100644 index 000000000..b74d41273 --- /dev/null +++ b/res/content/base/blocks/abstract_stairs.json @@ -0,0 +1,48 @@ +{ + "hidden": true, + "model": "custom", + "model-name": "stairs", + "rotation": "stairs", + "uv-lock": true, + "hitboxes": [ + [0, 0.0, 0, 1, 0.5, 1.0], + [0, 0.5, 0, 1, 0.5, 0.5] + ], + "light-passing": true, + "state-based": { + "offset": 0, + "bits": 3, + "variants": [ + { + "model-name": "stairs_inner_left", + "hitboxes": [ + [0.0, 0.0, 0.0, 1.0, 0.5, 1.0], + [0.0, 0.5, 0.0, 1.0, 0.5, 0.5], + [0.0, 0.5, 0.5, 0.5, 0.5, 0.5] + ] + }, + { + "model-name": "stairs_inner_right", + "hitboxes": [ + [0.0, 0.0, 0.0, 1.0, 0.5, 1.0], + [0.0, 0.5, 0.0, 1.0, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5, 0.5, 0.5] + ] + }, + { + "model-name": "stairs_outer_left", + "hitboxes": [ + [0.0, 0.0, 0.0, 1.0, 0.5, 1.0], + [0.0, 0.5, 0.0, 0.5, 0.5, 0.5] + ] + }, + { + "model-name": "stairs_outer_right", + "hitboxes": [ + [0.0, 0.0, 0.0, 1.0, 0.5, 1.0], + [0.5, 0.5, 0.0, 0.5, 0.5, 0.5] + ] + } + ] + } +} diff --git a/res/content/base/blocks/brick_stairs.json b/res/content/base/blocks/brick_stairs.json new file mode 100644 index 000000000..2ab43124b --- /dev/null +++ b/res/content/base/blocks/brick_stairs.json @@ -0,0 +1,6 @@ +{ + "parent": "base:abstract_stairs", + "texture": "brick", + "hidden": false, + "base:durability": 10.5 +} diff --git a/res/content/base/content.json b/res/content/base/content.json index db13bae2b..efc7a92bf 100644 --- a/res/content/base/content.json +++ b/res/content/base/content.json @@ -1,8 +1,6 @@ { - "entities": [ - "drop", - "player", - "falling_block" + "items": [ + "bazalt_breaker" ], "blocks": [ "dirt", @@ -30,9 +28,13 @@ "torch", "wooden_door", "coal_ore", - "ice" + "ice", + "brick_stairs", + "abstract_stairs" ], - "items": [ - "bazalt_breaker" + "entities": [ + "drop", + "player", + "falling_block" ] } \ No newline at end of file diff --git a/res/content/base/scripts/abstract_stairs.lua b/res/content/base/scripts/abstract_stairs.lua new file mode 100644 index 000000000..f99a78d49 --- /dev/null +++ b/res/content/base/scripts/abstract_stairs.lua @@ -0,0 +1,65 @@ +-- variants +local DEFAULT = 0 +local INNER_LEFT = 1 +local INNER_RIGHT = 2 +local OUTER_LEFT = 3 +local OUTER_RIGHT = 4 + +local function get_stairs_info(id, x, y, z) + if block.get(x, y, z) ~= id then + return nil + end + local zx, _, zz = block.get_Z(x, y, z) + local _, half = block.get_Y(x, y, z) + return -zx, -zz, half +end + +local function detect_variant(id, x, y, z) + local bx, bz, half = get_stairs_info(id, x, y, z) + local lx, _, lz = block.get_X(x, y, z) + lx, lz = -lx, -lz + + local function is_oriented_same(ox, oz) + local nbx, nbz, nhalf = get_stairs_info(id, x + ox, y, z + oz) + return nbx == bx and nbz == bz and nhalf == half + end + + local function corner_side(ox, oz, sign) + local nbx, nbz, nhalf = get_stairs_info(id, x + ox, y, z + oz) + if nbx == nil or nhalf ~= half or nbx * bx + nbz * bz ~= 0 then + return nil + end + if is_oriented_same(nbx * sign, nbz * sign) then + return nil + end + return nbx == lx and nbz == lz + end + + local left = corner_side(bx, bz, -1) + if left ~= nil then + return left and OUTER_LEFT or OUTER_RIGHT + end + left = corner_side(-bx, -bz, 1) + if left ~= nil then + return left and INNER_LEFT or INNER_RIGHT + end + return DEFAULT +end + +local function refresh(x, y, z, keep_variant) + local variant = detect_variant(block.get(x, y, z), x, y, z) + if keep_variant and variant == DEFAULT then + return + end + if block.get_variant(x, y, z) ~= variant then + block.set_variant(x, y, z, variant) + end +end + +function on_placed(x, y, z) + refresh(x, y, z, false) +end + +function on_update(x, y, z) + refresh(x, y, z, true) +end diff --git a/res/models/stairs.vcm b/res/models/stairs.vcm index b13cd2d80..be317ba2e 100644 --- a/res/models/stairs.vcm +++ b/res/models/stairs.vcm @@ -1,4 +1,4 @@ @box from (0,0,0) to (1,0.5,1) delete (top,north) @box from (0,0.5,0) to (1,1,0.5) delete (bottom,north) -@rect from (0,0.5,0.5) right (1,0,0) up (0,0,0.5) texture "$2" +@rect from (1.0,0.5,1.0) right (-1,0,0) up (0,0,-0.5) texture "$2" @rect from (0,0,0) right (1,0,0) up (0,1,0) texture "$1" diff --git a/res/models/stairs_inner_left.vcm b/res/models/stairs_inner_left.vcm new file mode 100644 index 000000000..53401dbb2 --- /dev/null +++ b/res/models/stairs_inner_left.vcm @@ -0,0 +1,3 @@ +@box from (0,0,0) to (1,0.5,1) +@box from (0,0.5,0) to (1,1,0.5) delete (bottom) +@box from (0,0.5,0.5) to (0.5,1,1) delete (bottom,north) diff --git a/res/models/stairs_inner_right.vcm b/res/models/stairs_inner_right.vcm new file mode 100644 index 000000000..eebef1f53 --- /dev/null +++ b/res/models/stairs_inner_right.vcm @@ -0,0 +1,3 @@ +@box from (0,0,0) to (1,0.5,1) +@box from (0,0.5,0) to (1,1,0.5) delete (bottom) +@box from (0.5,0.5,0.5) to (1,1,1) delete (bottom,north) diff --git a/res/models/stairs_outer_left.vcm b/res/models/stairs_outer_left.vcm new file mode 100644 index 000000000..af0eb9cdf --- /dev/null +++ b/res/models/stairs_outer_left.vcm @@ -0,0 +1,2 @@ +@box from (0,0,0) to (1,0.5,1) +@box from (0,0.5,0) to (0.5,1,0.5) delete (bottom) diff --git a/res/models/stairs_outer_right.vcm b/res/models/stairs_outer_right.vcm new file mode 100644 index 000000000..becc7b689 --- /dev/null +++ b/res/models/stairs_outer_right.vcm @@ -0,0 +1,2 @@ +@box from (0,0,0) to (1,0.5,1) +@box from (0.5,0.5,0) to (1,1,0.5) delete (bottom) From 28cfd0da67bc58869791b9c69bac8390beefa5fc Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 21 Nov 2026 20:27:42 +0300 Subject: [PATCH 3/6] fix --- src/content/ContentLoader.cpp | 2 +- src/content/loading/BlockLoader.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/ContentLoader.cpp b/src/content/ContentLoader.cpp index 9ab0a379e..9ea13315e 100644 --- a/src/content/ContentLoader.cpp +++ b/src/content/ContentLoader.cpp @@ -288,7 +288,7 @@ void ContentLoader::loadContent(const dv::value& root) { ContentUnitLoader(*pack, builder.blocks, "blocks", [this](const Block& def) { - if (!def.abstract || !def.hidden) { + if (!def.abstract && !def.hidden) { bool created; auto& item = builder.items.create( def.name + BLOCK_ITEM_SUFFIX, &created diff --git a/src/content/loading/BlockLoader.cpp b/src/content/loading/BlockLoader.cpp index 85b35b348..2051fb910 100644 --- a/src/content/loading/BlockLoader.cpp +++ b/src/content/loading/BlockLoader.cpp @@ -287,7 +287,7 @@ template<> void ContentUnitLoader::loadUnit( def.tickInterval = 1; } - if (def.hidden && def.pickingItem == def.name + BLOCK_ITEM_SUFFIX) { + if ((def.abstract || def.hidden) && def.pickingItem == def.name + BLOCK_ITEM_SUFFIX) { def.pickingItem = CORE_EMPTY; } if (root.has("script-name") || def.scriptFile.empty()) { From 1d1174e34453eaf222053e66f552fd8ecb10e758 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 21 Nov 2026 20:28:03 +0300 Subject: [PATCH 4/6] use 'abstract' property instead of 'hidden' --- res/content/base/blocks/abstract_stairs.json | 2 +- res/content/base/blocks/brick_stairs.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/res/content/base/blocks/abstract_stairs.json b/res/content/base/blocks/abstract_stairs.json index b74d41273..f80b0488f 100644 --- a/res/content/base/blocks/abstract_stairs.json +++ b/res/content/base/blocks/abstract_stairs.json @@ -1,5 +1,5 @@ { - "hidden": true, + "abstract": true, "model": "custom", "model-name": "stairs", "rotation": "stairs", diff --git a/res/content/base/blocks/brick_stairs.json b/res/content/base/blocks/brick_stairs.json index 2ab43124b..5dfad99ea 100644 --- a/res/content/base/blocks/brick_stairs.json +++ b/res/content/base/blocks/brick_stairs.json @@ -1,6 +1,5 @@ { "parent": "base:abstract_stairs", "texture": "brick", - "hidden": false, "base:durability": 10.5 } From 14c53c6149d2f7bd2c230817e363d0381db1dc9d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 21 Nov 2026 21:50:39 +0300 Subject: [PATCH 5/6] fix VCM cull-face behaviour for 'rect' --- src/coders/vcm.cpp | 49 +++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index c4323f4ba..698645599 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -193,45 +193,36 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) { std::string texture = root.attr("texture", "$0").getText(); glm::vec3 normal; + glm::vec3 backNormal; if (root.has("normal")) { normal = root.attr("normal").asVec3(); + backNormal = normal; } else { normal = glm::cross(glm::normalize(right), glm::normalize(up)); + backNormal = -normal; } + glm::vec3 center = from + right * 0.5f + up * 0.5f; + UVRegion backRegion = region; + std::swap(backRegion.u1, backRegion.u2); + auto cullFace = root.attr("cull-face", "back").getText(); - if (cullFace == "front") { - normal *= -1.0f; - } else if (cullFace == "off") { + if (cullFace != "front") { builder.addRect( - texture, - shading, - from + right * 0.5f + up * 0.5f, - right * 0.5f, - up * 0.5f, - normal, - region + texture, shading, center, right * 0.5f, up * 0.5f, normal, region + ); + } + if (cullFace == "front" || cullFace == "off") { + builder.addRect( + texture, + shading, + center, + right * -0.5f, + up * 0.5f, + backNormal, + backRegion ); - builder.addRect( - texture, - shading, - from + right * 0.5f + up * 0.5f, - right * -0.5f, - up * -0.5f, - -normal, - region - ); - return; } - builder.addRect( - texture, - shading, - from + right * 0.5f + up * 0.5f, - right * 0.5f, - up * 0.5f, - normal, - region - ); } static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { From 5493da16e0a56fad1ba6d36f49166be186139585 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 21 Nov 2026 21:51:40 +0300 Subject: [PATCH 6/6] fix VCM cull-face behaviour for 'tri' --- src/coders/vcm.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index 698645599..234a1b06d 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -240,12 +240,15 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { glm::vec3 ba = pointB - pointA; glm::vec3 ca = pointC - pointA; glm::vec3 normal; + glm::vec3 backNormal; if (root.has("normal")) { normal = root.attr("normal").asVec3(); + backNormal = normal; } else { normal = glm::normalize(glm::cross(ba, ca)); + backNormal = -normal; } - + if (root.has("uv")) { root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6); } else { @@ -267,10 +270,10 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { if (cullFace == "front") { std::swap(pointB, pointC); std::swap(uvs[1], uvs[2]); - normal *= -1.0f; + normal = backNormal; } else if (cullFace == "off") { builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]); - builder.addTriangle(texture, shading, pointA, pointC, pointB, -normal, uvs[0], uvs[2], uvs[1]); + builder.addTriangle(texture, shading, pointA, pointC, pointB, backNormal, uvs[0], uvs[2], uvs[1]); return; } builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]);