From e0be7a8d8c9f8d54d7af1b6b976fefc941ebba1f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 26 Jul 2026 21:46:03 +0300 Subject: [PATCH 1/7] fix custom model blocks render (with some conditions) --- src/content/ContentBuilder.cpp | 13 +++++++------ src/frontend/ContentGfxCache.cpp | 9 ++++++++- src/graphics/render/BlocksRenderer.cpp | 1 - 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/content/ContentBuilder.cpp b/src/content/ContentBuilder.cpp index ce77434ed..25029963b 100644 --- a/src/content/ContentBuilder.cpp +++ b/src/content/ContentBuilder.cpp @@ -26,17 +26,18 @@ std::unique_ptr ContentBuilder::build() { def.rt.tags.insert(tags.add(tag)); } + auto isSolid = [](const Variant& variant) { + return variant.model.type == BlockModelType::BLOCK || + variant.culling == CullingMode::OPTIONAL; + }; + if (def.variants) { for (auto& variant : def.variants->variants) { - variant.rt.solid = - variant.model.type == BlockModelType::BLOCK || - def.explictlySolid; + variant.rt.solid = isSolid(variant) || def.explictlySolid; } def.defaults = def.variants->variants.at(0); } else { - def.defaults.rt.solid = - def.defaults.model.type == BlockModelType::BLOCK || - def.explictlySolid; + def.defaults.rt.solid = isSolid(def.defaults) || def.explictlySolid; } const float EPSILON = 0.01f; diff --git a/src/frontend/ContentGfxCache.cpp b/src/frontend/ContentGfxCache.cpp index b8ce69a5f..9cdcdf70e 100644 --- a/src/frontend/ContentGfxCache.cpp +++ b/src/frontend/ContentGfxCache.cpp @@ -30,6 +30,7 @@ void ContentGfxCache::refreshVariant( uint8_t variantIndex, const Atlas& atlas ) { + std::unordered_map optionalTextures; bool denseRender = settings.denseRender.get(); for (uint side = 0; side < 6; side++) { std::string tex = variant.textureFaces[side]; @@ -43,6 +44,7 @@ void ContentGfxCache::refreshVariant( texOpaque = tex; } else if (variant.culling == CullingMode::OPTIONAL && !denseRender) { tex = texOpaque; + optionalTextures[variant.textureFaces[side]] = texOpaque; } size_t index = getRegionIndex(def.rt.id, variantIndex, side, false); sideregions[index] = atlas.get(tex); @@ -56,7 +58,12 @@ void ContentGfxCache::refreshVariant( if (pos == std::string::npos) { continue; } - if (auto region = atlas.getIf(mesh.texture.substr(pos+1))) { + std::string texture = mesh.texture.substr(pos+1); + const auto& found = optionalTextures.find(texture); + if (found != optionalTextures.end()) { + texture = found->second; + } + if (auto region = atlas.getIf(texture)) { for (auto& vertex : mesh.vertices) { vertex.uv = region->apply(vertex.uv); } diff --git a/src/graphics/render/BlocksRenderer.cpp b/src/graphics/render/BlocksRenderer.cpp index 0aae42010..33ecc8e17 100644 --- a/src/graphics/render/BlocksRenderer.cpp +++ b/src/graphics/render/BlocksRenderer.cpp @@ -538,7 +538,6 @@ void BlocksRenderer::render( break; } case BlockModelType::CUSTOM: { - if (!denseRender) blockCustomModel( {x, y, z}, def, From 0e31bdb83faba49112c4b6f536e7b22402aba6f5 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 20:06:40 +0300 Subject: [PATCH 2/7] fix base:drop hitbox size (revert part of previous change) --- res/content/base/scripts/components/drop.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/res/content/base/scripts/components/drop.lua b/res/content/base/scripts/components/drop.lua index 39bd03ceb..335b81d89 100644 --- a/res/content/base/scripts/components/drop.lua +++ b/res/content/base/scripts/components/drop.lua @@ -10,7 +10,7 @@ dropitem = ARGS if dropitem.item then dropitem.id = item.index(dropitem.item) end -if dropitem then +if dropitem then timer = dropitem.pickup_delay or timer end if SAVED_DATA.item then @@ -26,6 +26,7 @@ function on_save() end if vc.is_client() then + local SCALE = 0.3 local scale = {1, 1, 1} local rotation = mat4.rotate({ math.random(), math.random(), math.random() @@ -35,7 +36,7 @@ if vc.is_client() then local matrix = mat4.idt() rig:set_model(0, item.model_name(dropitem.id)) local bodysize = math.min(scale[1], scale[2], scale[3]) - body:set_size({scale[1], bodysize, scale[3]}) + body:set_size(vec3.mul({scale[1], bodysize, scale[3]}, SCALE)) mat4.mul(matrix, rotation, matrix) mat4.scale(matrix, scale, matrix) rig:set_matrix(0, matrix) From 17095011e66be4ccc044dfa2c1b8fd449e2ab0cc Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 21:10:38 +0300 Subject: [PATCH 3/7] update doc/*/entity-properties.md --- doc/en/entity-properties.md | 2 +- doc/ru/entity-properties.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/entity-properties.md b/doc/en/entity-properties.md index 8bc4d5d37..4934e4264 100644 --- a/doc/en/entity-properties.md +++ b/doc/en/entity-properties.md @@ -61,7 +61,7 @@ Determines how the physics engine will work with it. ### *blocking* -Determines whether the entity blocks installation of blocks. +If true - the entity blocks the placement of a block that intersects with the entity's hitbox. *In the future will also block other entities movement.* diff --git a/doc/ru/entity-properties.md b/doc/ru/entity-properties.md index de10cfd32..47126a258 100644 --- a/doc/ru/entity-properties.md +++ b/doc/ru/entity-properties.md @@ -61,7 +61,7 @@ ### Блокирование - *blocking* -Определяет блокирует ли сущность установку блоков. +Определяет блокирует ли сущность установку блока, пересекающегося с хитбоксом сущности. *В будущем будет также блокировать движение других сущностей.* From 439d95355d954c06fcb3aab09c9ed928afdd4f8a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 21:24:40 +0300 Subject: [PATCH 4/7] add 'selectable' entity property --- src/content/loading/EntityLoader.cpp | 1 + src/objects/Entities.cpp | 2 +- src/objects/EntityDef.hpp | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/content/loading/EntityLoader.cpp b/src/content/loading/EntityLoader.cpp index 5741b2079..e785fb0fe 100644 --- a/src/content/loading/EntityLoader.cpp +++ b/src/content/loading/EntityLoader.cpp @@ -89,6 +89,7 @@ template<> void ContentUnitLoader::loadUnit( root.at("skeleton-name").get(def.skeletonName); root.at("material").get(def.material); root.at("blocking").get(def.blocking); + root.at("selectable").get(def.selectable); root.at("solid").get(def.solid); root.at("mass").get(def.mass); root.at("elasticity").get(def.elasticity); diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index fafd99fe5..f0e3e5340 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -176,7 +176,7 @@ std::optional Entities::rayCast( for (auto [entity, eid, transform, body] : view.each()) { if (eid.uid == settings.ignoredUid || !body.enabled || - (settings.solidEntitiesOnly && !eid.def.solid)) { + (settings.solidEntitiesOnly && !eid.def.solid) || !eid.def.selectable) { continue; } if (settings.entitiesFilter) { diff --git a/src/objects/EntityDef.hpp b/src/objects/EntityDef.hpp index 6ecb1c917..59aed2d7e 100644 --- a/src/objects/EntityDef.hpp +++ b/src/objects/EntityDef.hpp @@ -42,6 +42,9 @@ struct EntityDef { /// @brief Solid entity material material std::string material; + /// @brief Can the entity be interacted with cursor (on_attack, on_use) + bool selectable = true; + /// @brief Does entity prevent blocks setup bool blocking = true; From 35113777de3e9f250e15b37067f3cc4945d8969f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 21:31:48 +0300 Subject: [PATCH 5/7] add 'nonselect_entities' raycast parameter --- src/logic/scripting/lua/libs/libentity.cpp | 4 ++++ src/objects/Entities.cpp | 3 ++- src/objects/Entities.hpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/logic/scripting/lua/libs/libentity.cpp b/src/logic/scripting/lua/libs/libentity.cpp index 110aee123..4434136ba 100644 --- a/src/logic/scripting/lua/libs/libentity.cpp +++ b/src/logic/scripting/lua/libs/libentity.cpp @@ -311,6 +311,10 @@ static int l_world_raycast(lua::State* L) { entityRaycast.entityFilterExcludeMode = lua::toboolean(L, -1); lua::pop(L); } + if (lua::getfield(L, "nonselect_entities", 1)) { + entityRaycast.includeNonSelectable = lua::toboolean(L, -1); + lua::pop(L); + } if (lua::getfield(L, "filter_blocks", 1)) { load_blocks_filter(L, -1, filteredBlocks); blocksRaycast.filter = &filteredBlocks; diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index f0e3e5340..0902ae85a 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -176,7 +176,8 @@ std::optional Entities::rayCast( for (auto [entity, eid, transform, body] : view.each()) { if (eid.uid == settings.ignoredUid || !body.enabled || - (settings.solidEntitiesOnly && !eid.def.solid) || !eid.def.selectable) { + (settings.solidEntitiesOnly && !eid.def.solid) || + (!eid.def.selectable && !settings.includeNonSelectable)) { continue; } if (settings.entitiesFilter) { diff --git a/src/objects/Entities.hpp b/src/objects/Entities.hpp index 0d003ffb1..382790b95 100644 --- a/src/objects/Entities.hpp +++ b/src/objects/Entities.hpp @@ -85,6 +85,7 @@ public: bool solidEntitiesOnly = false; bool entityFilterExcludeMode = false; const std::set* entitiesFilter = nullptr; + bool includeNonSelectable = false; }; struct RaycastResult { From 2b5acfde6279526f476ca58e40407bba415779c0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 21:38:27 +0300 Subject: [PATCH 6/7] update doc/*/libworld.md & update doc/*/entity-properties.md --- doc/en/entity-properties.md | 4 ++++ doc/en/scripting/builtins/libworld.md | 2 ++ doc/ru/entity-properties.md | 6 +++++- doc/ru/scripting/builtins/libworld.md | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/en/entity-properties.md b/doc/en/entity-properties.md index 4934e4264..b0aee9aea 100644 --- a/doc/en/entity-properties.md +++ b/doc/en/entity-properties.md @@ -67,6 +67,10 @@ If true - the entity blocks the placement of a block that intersects with the en Default value: *true*. +### *selectable* + +If set to `false` the cursor will ignore the entity, passing the ray. + ### *sensors* A sensor is an area attached to a physical body that detects the entry of other bodies into it. diff --git a/doc/en/scripting/builtins/libworld.md b/doc/en/scripting/builtins/libworld.md index 54b44fe15..5ff749cb8 100644 --- a/doc/en/scripting/builtins/libworld.md +++ b/doc/en/scripting/builtins/libworld.md @@ -92,6 +92,8 @@ world.raycast( -- exclusion filtering mode: -- if true, filter_entities defines the list of ignored entity types entities_exclusion: bool = false, + -- include entities with selectable=false + nonselect_blocks: bool = false; [==[ additional parameters (blocks) ]==] -- id of the block types used for filtering diff --git a/doc/ru/entity-properties.md b/doc/ru/entity-properties.md index 47126a258..2f5ca3791 100644 --- a/doc/ru/entity-properties.md +++ b/doc/ru/entity-properties.md @@ -61,12 +61,16 @@ ### Блокирование - *blocking* -Определяет блокирует ли сущность установку блока, пересекающегося с хитбоксом сущности. +Определяет, блокирует ли сущность установку блока, пересекающегося с хитбоксом сущности. *В будущем будет также блокировать движение других сущностей.* Значение по-умолчанию: *true*. +### Выделяемость - *selectable* + +При значении в `false` курсор будет игнорировать cущность, пропуская луч далее. + ### Список сенсоров - *sensors* Сенсор - область пространства, привязанная к физическому телу, детектирующее попадание в него других тел. diff --git a/doc/ru/scripting/builtins/libworld.md b/doc/ru/scripting/builtins/libworld.md index 6b945aa76..52812f295 100644 --- a/doc/ru/scripting/builtins/libworld.md +++ b/doc/ru/scripting/builtins/libworld.md @@ -91,6 +91,8 @@ world.raycast( -- исключающий режим фильтрации: -- при значении (true) filter_entities определяет список игнорируемых entities_exclusion: bool = false, + -- учитывать сущности с selectable=false + nonselect_entities: bool = false; [==[ дополнительные параметры (блоки) ]==] -- id типов блоков используемых для фильтрации From 2f90083ac62db210d08b5893fc0a1e66c9811528 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Jul 2026 22:17:18 +0300 Subject: [PATCH 7/7] fix doc/en/scripting/buiiltins/libworld.md --- doc/en/scripting/builtins/libworld.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/scripting/builtins/libworld.md b/doc/en/scripting/builtins/libworld.md index 5ff749cb8..72bfaf8e4 100644 --- a/doc/en/scripting/builtins/libworld.md +++ b/doc/en/scripting/builtins/libworld.md @@ -93,7 +93,7 @@ world.raycast( -- if true, filter_entities defines the list of ignored entity types entities_exclusion: bool = false, -- include entities with selectable=false - nonselect_blocks: bool = false; + nonselect_entities: bool = false; [==[ additional parameters (blocks) ]==] -- id of the block types used for filtering