mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-03-24 04:50:35 +01:00
Fix blockage in mvps object movement
This commit is contained in:
parent
d8322fccc8
commit
807e6d5f0b
@ -253,7 +253,8 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
|||||||
return true, nodes, oldstack
|
return true, nodes, oldstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns whether the given area intersects any nodes in the given set of position hashes.
|
-- Returns whether the given area intersects any nodes in the given set of position hashes,
|
||||||
|
-- or any walkable nodes in the map if no set is given.
|
||||||
local function area_intersects_nodes(min_pos, max_pos, positions)
|
local function area_intersects_nodes(min_pos, max_pos, positions)
|
||||||
min_pos = vector.round(min_pos)
|
min_pos = vector.round(min_pos)
|
||||||
max_pos = vector.round(max_pos)
|
max_pos = vector.round(max_pos)
|
||||||
@ -261,8 +262,15 @@ local function area_intersects_nodes(min_pos, max_pos, positions)
|
|||||||
while pos.x <= max_pos.x do
|
while pos.x <= max_pos.x do
|
||||||
while pos.y <= max_pos.y do
|
while pos.y <= max_pos.y do
|
||||||
while pos.z <= max_pos.z do
|
while pos.z <= max_pos.z do
|
||||||
if positions[minetest.hash_node_position(pos)] then
|
if positions then
|
||||||
return true
|
if positions[minetest.hash_node_position(pos)] then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
if def.walkable then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
pos.z = pos.z + 1
|
pos.z = pos.z + 1
|
||||||
end
|
end
|
||||||
@ -351,15 +359,13 @@ function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
|||||||
if ok then
|
if ok then
|
||||||
local ent = obj:get_luaentity()
|
local ent = obj:get_luaentity()
|
||||||
if obj:is_player() or (ent and not mesecon.is_mvps_unmov(ent.name)) then
|
if obj:is_player() or (ent and not mesecon.is_mvps_unmov(ent.name)) then
|
||||||
local np = vector.add(obj_pos, dir)
|
|
||||||
-- Move only if destination is not solid or object is inside stack:
|
-- Move only if destination is not solid or object is inside stack:
|
||||||
local nn = minetest.get_node(np)
|
-- (A small bias is added to prevent rounding issues.)
|
||||||
local node_def = minetest.registered_nodes[nn.name]
|
local min_pos = vector.offset(obj_pos, cbox[1] + 0.01, cbox[2] + 0.01, cbox[3] + 0.01)
|
||||||
local obj_offset = dir_l * (obj_pos[dir_k] - pos[dir_k])
|
local max_pos = vector.offset(obj_pos, cbox[4] - 0.01, cbox[5] - 0.01, cbox[6] - 0.01)
|
||||||
if (node_def and not node_def.walkable) or
|
if not area_intersects_nodes(vector.add(min_pos, dir), vector.add(max_pos, dir)) or
|
||||||
(obj_offset >= 0 and
|
area_intersects_nodes(min_pos, max_pos, moved_positions) then
|
||||||
obj_offset <= #nodestack - 0.5) then
|
obj:move_to(vector.add(obj_pos, dir))
|
||||||
obj:move_to(np)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user