diff --git a/src/logic/scripting/lua/libs/libentity.cpp b/src/logic/scripting/lua/libs/libentity.cpp index 50711cf01..7e68ac5ff 100644 --- a/src/logic/scripting/lua/libs/libentity.cpp +++ b/src/logic/scripting/lua/libs/libentity.cpp @@ -287,7 +287,7 @@ static int l_world_raycast(lua::State* L) { entityRaycast.ignoredUid = lua::tointeger(L, -1); lua::pop(L); } - if (lua::getfield(L, "ignore_entities")) { + if (lua::getfield(L, "filter_entities")) { load_entities_filter(L, -1, filteredEntities); blocksRaycast.filter = &filteredEntities; lua::pop(L); @@ -301,6 +301,10 @@ static int l_world_raycast(lua::State* L) { blocksRaycast.filter = &filteredBlocks; lua::pop(L); } + if (lua::getfield(L, "blocks_exclusion")) { + blocksRaycast.blocksFilterExcludeMode = lua::toboolean(L, -1); + lua::pop(L); + } if (lua::getfield(L, "nonselect_blocks", 1)) { blocksRaycast.includeNonSelectable = lua::toboolean(L, -1); lua::pop(L); diff --git a/src/voxels/blocks_agent.cpp b/src/voxels/blocks_agent.cpp index 0ffd92276..81a752a70 100644 --- a/src/voxels/blocks_agent.cpp +++ b/src/voxels/blocks_agent.cpp @@ -267,10 +267,10 @@ static inline voxel* raycast_blocks( auto filter = settings.filter; const auto& def = blocks.require(voxel->id); - if (voxel->id != BLOCK_AIR - && (def.selectable || includeNonSelectable) - && (filter == nullptr || filter->empty() || - filter->find(def.rt.id) == filter->end())) { + if (voxel->id != BLOCK_AIR && + (def.selectable || includeNonSelectable) && + (filter == nullptr || (filter->find(def.rt.id) == filter->end()) == + settings.blocksFilterExcludeMode)) { end = start + t * dir; iend = {ix, iy, iz}; diff --git a/src/voxels/blocks_agent.hpp b/src/voxels/blocks_agent.hpp index 3ac4c74d5..22144c618 100644 --- a/src/voxels/blocks_agent.hpp +++ b/src/voxels/blocks_agent.hpp @@ -414,6 +414,7 @@ inline void set_rotation( struct RaycastSettings { const std::set* filter = nullptr; + bool blocksFilterExcludeMode = true; bool includeNonSelectable = false; };