aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-09-03 22:05:07 -0400
committerJude Melton-Houghton <jwmhjwmh@gmail.com>2022-12-24 08:24:59 -0500
commit5c248c2d7de3db54e85f7c388743a2eb8e36fee4 (patch)
treeb0d27690b3e852b207345dc5e00dc4457a7e6268 /builtin
parent7701e70dc92262c41d68cf1c9f7fbd0c333e5c52 (diff)
downloadminetest-5c248c2d7de3db54e85f7c388743a2eb8e36fee4.tar.xz
Add callback on_mapblocks_changed
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/misc_s.lua5
-rw-r--r--builtin/game/register.lua11
-rw-r--r--builtin/profiler/instrumentation.lua1
3 files changed, 14 insertions, 3 deletions
diff --git a/builtin/game/misc_s.lua b/builtin/game/misc_s.lua
index 67a0ec684..93d2bafa8 100644
--- a/builtin/game/misc_s.lua
+++ b/builtin/game/misc_s.lua
@@ -8,10 +8,9 @@
-- Misc. API functions
--
+-- This must match the implementation in src/script/common/c_converter.h
function core.hash_node_position(pos)
- return (pos.z + 32768) * 65536 * 65536
- + (pos.y + 32768) * 65536
- + pos.x + 32768
+ return (pos.z + 0x8000) * 0x100000000 + (pos.y + 0x8000) * 0x10000 + (pos.x + 0x8000)
end
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index f0a6cb49a..cc58cad31 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -633,6 +633,17 @@ core.registered_on_player_inventory_actions, core.register_on_player_inventory_a
core.registered_allow_player_inventory_actions, core.register_allow_player_inventory_action = make_registration()
core.registered_on_rightclickplayers, core.register_on_rightclickplayer = make_registration()
core.registered_on_liquid_transformed, core.register_on_liquid_transformed = make_registration()
+core.registered_on_mapblocks_changed, core.register_on_mapblocks_changed = make_registration()
+
+core.register_on_mods_loaded(function()
+ core.after(0, function()
+ setmetatable(core.registered_on_mapblocks_changed, {
+ __newindex = function()
+ error("on_mapblocks_changed callbacks must be registered at load time")
+ end,
+ })
+ end)
+end)
--
-- Compatibility for on_mapgen_init()
diff --git a/builtin/profiler/instrumentation.lua b/builtin/profiler/instrumentation.lua
index f80314b32..80f1c66af 100644
--- a/builtin/profiler/instrumentation.lua
+++ b/builtin/profiler/instrumentation.lua
@@ -43,6 +43,7 @@ local register_functions = {
register_on_item_eat = 0,
register_on_punchplayer = 0,
register_on_player_hpchange = 0,
+ register_on_mapblocks_changed = 0,
}
---