From c4f4ede29a9c373bb40d64eb25eb0db0f181be28 Mon Sep 17 00:00:00 2001 From: kay27 Date: Wed, 17 Mar 2021 18:13:40 +0400 Subject: [PATCH] Fix errors with Nether portal destination calcs --- mods/CORE/mcl_init/init.lua | 2 +- mods/ITEMS/mcl_portals/portal_nether.lua | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mods/CORE/mcl_init/init.lua b/mods/CORE/mcl_init/init.lua index 80380d14..ca510b74 100644 --- a/mods/CORE/mcl_init/init.lua +++ b/mods/CORE/mcl_init/init.lua @@ -52,7 +52,7 @@ local function coordinate_to_block(x) end local function coordinate_to_chunk(x) - return math.floor((coordinate_to_block(x) + central_chunk_offset) / mcl_vars.chunksize) + return math.floor((coordinate_to_block(x) - central_chunk_offset) / mcl_vars.chunksize) end function mcl_vars.pos_to_block(pos) diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 25146219..7addbac1 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -394,10 +394,11 @@ local function ecb_scan_area(blockpos, action, calls_remaining, param) for i = 1, i_max do local px, pz = p0x + x, p0z + z minetest.log("action", "[mcl_portal] i=" ..tostring(i) .." px=" .. tostring(px) .." pz=" .. tostring(pz) .. " x:"..tostring(p1x) .."-"..tostring(p2x) .. " z:"..tostring(p1z) .."-"..tostring(p2z)) - if px >= p1x and pz >= p2z and px <= p2x and pz <= p2z then - local p = {x=px, y=p1y, z=pz} - local nodes = minetest.find_nodes_in_area_under_air(p, p, {"group:building_block"}) - minetest.log("action", "[mcl_portal] check " .. minetest.pos_to_string(p) .. ": " .. tostring(nodes and #nodes)) + if px >= p1x and pz >= p1z and px <= p2x and pz <= p2z then + local p1 = {x=px, y=p1y, z=pz} + local p2 = {x=px, y=p2y, z=pz} + local nodes = minetest.find_nodes_in_area_under_air(p1, p2, {"group:building_block"}) + minetest.log("action", "[mcl_portal] check " .. minetest.pos_to_string(p1) .. "-" .. minetest.pos_to_string(p2) .. ": " .. tostring(nodes and #nodes)) if nodes and #nodes > 3 then for j = 1, #nodes do local node = nodes[j] @@ -434,7 +435,7 @@ local function create_portal(pos, limit1, limit2, name, obj) -- we need to emerge the area here, but currently (mt5.4/mcl20.71) map generation is slow -- so we'll emerge single chunk only: 5x5x5 blocks, 80x80x80 nodes maximum - local pos1 = sub(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes) + local pos1 = add(mul(mcl_vars.pos_to_chunk(pos), mcl_vars.chunk_size_in_nodes), mcl_vars.central_chunk_offset_in_nodes) local pos2 = add(pos1, mcl_vars.chunk_size_in_nodes - 1) if limit1 and limit1.x and limit1.y and limit1.z then