1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-12 04:45:25 +01:00

Implement get_node with a get_node_raw (#14384)

Add /bench_bulk_get_node
Considerably improves the execution speed of core.get_node
This commit is contained in:
DS
2024-03-03 15:53:23 +01:00
committed by GitHub
parent 879f7e9f03
commit d4d4712361
4 changed files with 90 additions and 49 deletions

View File

@@ -736,3 +736,22 @@ core.noneitemdef_default = { -- This is used for the hand and unknown items
on_drop = nil,
on_use = nil,
}
--
-- get_node implementation
--
local get_node_raw = core.get_node_raw
core.get_node_raw = nil
function core.get_node(pos)
local content, param1, param2 = get_node_raw(pos.x, pos.y, pos.z)
return {name = core.get_name_from_content_id(content), param1 = param1, param2 = param2}
end
function core.get_node_or_nil(pos)
local content, param1, param2, pos_ok = get_node_raw(pos.x, pos.y, pos.z)
return pos_ok and
{name = core.get_name_from_content_id(content), param1 = param1, param2 = param2}
or nil
end