From d085f0fb52206771b4d929f1fccc9c66139fbf35 Mon Sep 17 00:00:00 2001 From: Xiaochuan Ye Date: Mon, 17 Mar 2025 03:02:42 +0800 Subject: [PATCH] Document core.MAP_BLOCKSIZE constant in lua_api.md (#15911) --- doc/lua_api.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index ec10458a7..e1fb93a4d 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -1681,7 +1681,9 @@ roughly 1x1x1 meters in size. A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the fundamental region of a world that is stored in the world database, sent to -clients and handled by many parts of the engine. +clients and handled by many parts of the engine. This size is defined by the constant +`core.MAP_BLOCKSIZE` (=16). + 'mapblock' is preferred terminology to 'block' to help avoid confusion with 'node', however 'block' often appears in the API. @@ -1713,7 +1715,7 @@ node position (0,0,0) to node position (15,15,15). To calculate the blockpos of the mapblock that contains the node at 'nodepos', for each axis: -* blockpos = math.floor(nodepos / 16) +* blockpos = math.floor(nodepos / core.MAP_BLOCKSIZE) #### Converting blockpos to min/max node positions @@ -1721,9 +1723,9 @@ To calculate the min/max node positions contained in the mapblock at 'blockpos', for each axis: * Minimum: - nodepos = blockpos * 16 + nodepos = blockpos * core.MAP_BLOCKSIZE * Maximum: - nodepos = blockpos * 16 + 15 + nodepos = (blockpos + 1) * core.MAP_BLOCKSIZE - 1