1
0
Fork 0

Merge branch 'master' of ssh://git.minetest.land:29418/MineClone2/MineClone2

formspec-v4
AFCMS 2021-04-08 09:10:35 +02:00
commit e228c1d70b
2 changed files with 20 additions and 13 deletions

View File

@ -1,6 +1,9 @@
-- TODO: whenever it becomes possible to fully implement kelp without the
-- plantlike_rooted limitation, please update accordingly.
--
-- TODO: whenever it becomes possible to make kelp grow infinitely without
-- resorting to making intermediate kelp stem node, please update accordingly.
--
-- TODO: In MC, you can't actually destroy kelp by bucket'ing water in the middle.
-- However, because of the plantlike_rooted hack, we'll just allow it for now.
@ -191,17 +194,18 @@ end
-- Converts param2 to kelp height.
-- For the special case where the max param2 is reached, interpret that as the
-- 16th kelp stem.
function kelp.get_height(param2)
return math_floor(param2 / 16)
return param2 ~= 255 and math_floor(param2 / 16) or 16 -- 256/16
end
-- Obtain pos and node of the tip of kelp.
function kelp.get_tip(pos, param2)
-- Optional params: param2
local height = kelp.get_height(param2 or mt_get_node(pos).param2)
local pos_tip = {x=pos.x, y=pos.y, z=pos.z}
pos_tip.y = pos_tip.y + height + 1
function kelp.get_tip(pos, height)
-- Optional params: height
local height = height or kelp.get_height(mt_get_node(pos).param2)
local pos_tip = {x=pos.x, y=pos.y+height+1, z=pos.z}
return pos_tip, mt_get_node(pos_tip), height
end
@ -227,7 +231,8 @@ end
-- Obtain next param2.
function kelp.next_param2(param2)
return param2+16 - param2 % 16
-- param2 max value is 255, so adding to 256 causes overflow.
return math_min(param2+16 - param2 % 16, 255);
end
@ -526,7 +531,7 @@ function kelp.kelp_on_place(itemstack, placer, pointed_thing)
-- When placed on kelp.
if mt_get_item_group(nu_name, "kelp") == 1 then
pos_tip,node_tip = kelp.get_tip(pos_under, node_under.param2)
pos_tip,node_tip = kelp.get_tip(pos_under, kelp.get_height(node_under.param2))
def_tip = mt_registered_nodes[node_tip.name]
-- When placed on surface.

View File

@ -490,10 +490,12 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
end
if param.next_chunk_1 and param.next_chunk_2 and param.next_pos then
local pos1, pos2, pos = param.next_chunk_1, param.next_chunk_2, param.next_pos
log("action", "[mcl_portals] Making additional search in chunk below, because current one doesn't contain any air space for portal, target pos "..pos_to_string(pos))
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = pos, pos1 = pos1, pos2 = pos2, name=name, obj=obj})
return
local pos1, pos2, p = param.next_chunk_1, param.next_chunk_2, param.next_pos
if p.x >= pos1.x and p.x <= pos2.x and p.y >= pos1.y and p.y <= pos2.y and p.z >= pos1.z and p.z <= pos2.z then
log("action", "[mcl_portals] Making additional search in chunk below, because current one doesn't contain any air space for portal, target pos "..pos_to_string(p))
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = p, pos1 = pos1, pos2 = pos2, name=name, obj=obj})
return
end
end
log("action", "[mcl_portals] found no space, reverting to target pos "..pos_to_string(pos).." - creating a portal")
@ -536,7 +538,7 @@ local function create_portal(pos, limit1, limit2, name, obj)
-- Basically the copy of code above, with minor additions to continue the search in single additional chunk below:
local next_chunk_1 = {x = pos1.x, y = pos1.y - mcl_vars.chunk_size_in_nodes, z = pos1.z}
local next_chunk_2 = add(next_chunk_1, mcl_vars.chunk_size_in_nodes - 1)
local next_pos = {x = pos.x, y=next_chunk_2.y, z = pos.z}
local next_pos = {x = pos.x, y=max(next_chunk_2.y, limit1.y), z = pos.z}
if limit1 and limit1.x and limit1.y and limit1.z then
pos1 = {x = max(min(limit1.x, pos.x), pos1.x), y = max(min(limit1.y, pos.y), pos1.y), z = max(min(limit1.z, pos.z), pos1.z)}
next_chunk_1 = {x = max(min(limit1.x, next_pos.x), next_chunk_1.x), y = max(min(limit1.y, next_pos.y), next_chunk_1.y), z = max(min(limit1.z, next_pos.z), next_chunk_1.z)}