From ebd506de0946ed8e1e65717aa5225971515571d4 Mon Sep 17 00:00:00 2001 From: ostermine Date: Thu, 12 Nov 2026 01:19:22 +0300 Subject: [PATCH] fix block positions rounded to float in ray casts and routes iendpoint of block.raycast, entities.raycast and world.raycast and nodes of a pathfinding route are integer block positions, but they were pushed to Lua through glm::vec3. An odd coordinate above 16.7M came back as a neighbour block. --- src/logic/scripting/lua/libs/libblock.cpp | 2 +- src/logic/scripting/lua/libs/libentity.cpp | 2 +- src/logic/scripting/lua/libs/libpathfinding.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logic/scripting/lua/libs/libblock.cpp b/src/logic/scripting/lua/libs/libblock.cpp index aff5af7c5..cdde30d18 100644 --- a/src/logic/scripting/lua/libs/libblock.cpp +++ b/src/logic/scripting/lua/libs/libblock.cpp @@ -598,7 +598,7 @@ static int l_raycast(lua::State* L) { lua::pushnumber(L, glm::distance(start, end)); lua::setfield(L, "length"); - lua::pushvec3(L, iend); + lua::pushvec(L, iend); lua::setfield(L, "iendpoint"); lua::pushinteger(L, voxel->id); diff --git a/src/logic/scripting/lua/libs/libentity.cpp b/src/logic/scripting/lua/libs/libentity.cpp index cc889c023..a809b3d4b 100644 --- a/src/logic/scripting/lua/libs/libentity.cpp +++ b/src/logic/scripting/lua/libs/libentity.cpp @@ -184,7 +184,7 @@ static int l_push_ray( lua::pushnumber(L, ray ? ray->distance : glm::distance(start, end)); lua::setfield(L, "length"); - lua::pushvec3(L, iend); + lua::pushvec(L, iend); lua::setfield(L, "iendpoint"); lua::pushinteger(L, block); diff --git a/src/logic/scripting/lua/libs/libpathfinding.cpp b/src/logic/scripting/lua/libs/libpathfinding.cpp index 55f5a3fc3..c1831be9c 100644 --- a/src/logic/scripting/lua/libs/libpathfinding.cpp +++ b/src/logic/scripting/lua/libs/libpathfinding.cpp @@ -36,7 +36,7 @@ static int l_is_enabled(lua::State* L) { static int push_route(lua::State* L, const voxels::Route& route) { lua::createtable(L, route.nodes.size(), 1); for (int i = 0; i < route.nodes.size(); i++) { - lua::pushvec3(L, route.nodes[i].pos); + lua::pushvec(L, route.nodes[i].pos); lua::rawseti(L, i + 1); } lua::pushinteger(L, route.totalVisited);