fix(mod-api): validate active block storage

This commit is contained in:
Bo Layer
2026-08-23 03:20:43 -06:00
parent 3b7fc42858
commit d17f0725d8
4 changed files with 15 additions and 3 deletions
+6 -1
View File
@@ -146,8 +146,13 @@ function WorldAPI:activeBlockAt(mapId, bx, by)
if type(def.blocks) ~= "table" or type(map.blockAt) ~= "function" then
return nil, "block unavailable"
end
local stored = def.blocks[by * def.width + bx + 1]
if not validBlockCoordinate(stored) or stored < 0 then
return nil, "block unavailable"
end
local ok, blockId = pcall(map.blockAt, map, bx, by)
if not ok or not validBlockCoordinate(blockId) or blockId < 0 then
if not ok or not validBlockCoordinate(blockId) or blockId < 0
or blockId ~= stored then
return nil, "block unavailable"
end
return blockId