Add theoretical support for larger nether portals
parent
0ae2c5b25f
commit
82f851e20d
|
@ -8,8 +8,8 @@ local nobj_cave = nil
|
||||||
-- Portal frame sizes
|
-- Portal frame sizes
|
||||||
local FRAME_SIZE_X_MIN = 4
|
local FRAME_SIZE_X_MIN = 4
|
||||||
local FRAME_SIZE_Y_MIN = 5
|
local FRAME_SIZE_Y_MIN = 5
|
||||||
local FRAME_SIZE_X_MAX = 23
|
local FRAME_SIZE_X_MAX = 4 -- TODO: 23
|
||||||
local FRAME_SIZE_Y_MAX = 23
|
local FRAME_SIZE_Y_MAX = 5 -- TODO: 23
|
||||||
|
|
||||||
local TELEPORT_DELAY = 3 -- seconds before teleporting in Nether portal
|
local TELEPORT_DELAY = 3 -- seconds before teleporting in Nether portal
|
||||||
local TELEPORT_COOLOFF = 4 -- after object was teleported, for this many seconds it won't teleported again
|
local TELEPORT_COOLOFF = 4 -- after object was teleported, for this many seconds it won't teleported again
|
||||||
|
@ -273,16 +273,21 @@ end
|
||||||
|
|
||||||
local function is_portal(pos)
|
local function is_portal(pos)
|
||||||
local xsize, ysize = FRAME_SIZE_X_MIN-1, FRAME_SIZE_Y_MIN-1
|
local xsize, ysize = FRAME_SIZE_X_MIN-1, FRAME_SIZE_Y_MIN-1
|
||||||
for d = -xsize, xsize do
|
for sx = FRAME_SIZE_X_MIN, FRAME_SIZE_X_MAX do
|
||||||
for y = -ysize, ysize do
|
local xsize = sx - 1
|
||||||
local px = {x = pos.x + d, y = pos.y + y, z = pos.z}
|
for sy = FRAME_SIZE_Y_MIN, FRAME_SIZE_Y_MAX do
|
||||||
local pz = {x = pos.x, y = pos.y + y, z = pos.z + d}
|
local ysize = sy - 1
|
||||||
|
for d = -xsize, xsize do
|
||||||
if check_portal(px, {x = px.x + xsize, y = px.y + ysize, z = px.z}) then
|
for y = -ysize, ysize do
|
||||||
return px, {x = px.x + xsize, y = px.y + ysize, z = px.z}
|
local px = {x = pos.x + d, y = pos.y + y, z = pos.z}
|
||||||
end
|
local pz = {x = pos.x, y = pos.y + y, z = pos.z + d}
|
||||||
if check_portal(pz, {x = pz.x, y = pz.y + ysize, z = pz.z + xsize}) then
|
if check_portal(px, {x = px.x + xsize, y = px.y + ysize, z = px.z}) then
|
||||||
return pz, {x = pz.x, y = pz.y + ysize, z = pz.z + xsize}
|
return px, {x = px.x + xsize, y = px.y + ysize, z = px.z}
|
||||||
|
end
|
||||||
|
if check_portal(pz, {x = pz.x, y = pz.y + ysize, z = pz.z + xsize}) then
|
||||||
|
return pz, {x = pz.x, y = pz.y + ysize, z = pz.z + xsize}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -349,7 +354,8 @@ function mcl_portals.light_nether_portal(pos)
|
||||||
target.y = find_nether_target_y(target.x, target.z)
|
target.y = find_nether_target_y(target.x, target.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
local dmin, dmax, ymin, ymax = 0, FRAME_SIZE_X_MIN - 1, p1.y, p2.y
|
local dmin, ymin, ymax = 0, p1.y, p2.y
|
||||||
|
local dmax = math.max(math.abs(p1.x - p2.x), math.abs(p1.z - p2.z))
|
||||||
for d = dmin, dmax do
|
for d = dmin, dmax do
|
||||||
for y = ymin, ymax do
|
for y = ymin, ymax do
|
||||||
if not ((d == dmin or d == dmax) and (y == ymin or y == ymax)) then
|
if not ((d == dmin or d == dmax) and (y == ymin or y == ymax)) then
|
||||||
|
|
Loading…
Reference in New Issue