aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
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,
}
---