Doors can't push nodes into players directly.

This commit is contained in:
Aaron Suen 2019-12-18 19:52:07 -05:00
parent c1d3ca04c8
commit b66c636aa7
3 changed files with 28 additions and 20 deletions

View File

@ -19,8 +19,6 @@ ISSUES: Bugs, Cleanup and Refinements
- Dirt->sand leeching
- Time for an audit again...
- Glass not cooling when water flows above (should).
- Totes should not deploy if ents or interact-players are in the way.
- Retest conservation of fuel at full strength, consider reinstating?
@ -29,9 +27,6 @@ ISSUES: Bugs, Cleanup and Refinements
- Flammables should respond via AISM when bathed in fire or igniting
liquids like molten glass or rock.
- Nodes pushed by doors shouldn't move to collide with players/ents
either, just like doors themselves.
- API for allowing mods to customize player texture.
- Maybe nodecore.register_on_player_textures(layers) where
layers is an array of entries, each having {name = "",

View File

@ -349,3 +349,26 @@ function nodecore.rate_adjustment(...)
end
return rate
end
function nodecore.obstructed(minpos, maxpos)
if not maxpos then
maxpos = {x = minpos.x + 0.5, y = minpos.y + 0.5, z = minpos.z + 0.5}
minpos = {x = minpos.x - 0.5, y = minpos.y - 0.5, z = minpos.z - 0.5}
end
local avgpos = vector.multiply(vector.add(minpos, maxpos), 0.5)
local radius = 4 + vector.distance(minpos, maxpos) / 2
for _, obj in pairs(minetest.get_objects_inside_radius(avgpos, radius)) do
local op = obj:get_pos()
local cb = obj:get_properties().collisionbox
if maxpos.x > op.x + cb[1] and minpos.x < op.x + cb[4]
and maxpos.y > op.y + cb[2] and minpos.y < op.y + cb[5]
and maxpos.z > op.z + cb[3] and minpos.z < op.z + cb[6]
then
local lua = obj.get_luaentity and obj:get_luaentity()
if not ((lua and lua.is_stack) or (not nodecore.interact(obj))
or (not nodecore.player_visible(obj))) then
return obj
end
end
end
end

View File

@ -23,8 +23,9 @@ local function conveytrace(okay, seg, u)
local w = convey[u.tkey2]
if w then return w end
if nodecore.buildable_to(u.to2) then
local ok = (not nodecore.obstructed(u.to2)) or nil
for x in pairs(seg) do
okay[x] = true
okay[x] = ok
end
u.to = u.to2
u.tkey = u.tkey2
@ -34,8 +35,9 @@ local function conveytrace(okay, seg, u)
local w = convey[u.tkey]
if w then return w end
if nodecore.buildable_to(u.to) then
local ok = (not nodecore.obstructed(u.to)) or nil
for x in pairs(seg) do
okay[x] = true
okay[x] = ok
end
end
end
@ -181,19 +183,7 @@ function nodecore.operate_door(pos, node, dir)
}
end
for _, obj in pairs(minetest.get_objects_inside_radius(to, 2.5)) do
local op = obj:get_pos()
local cb = obj:get_properties().collisionbox
if to.x + 0.5 > op.x + cb[1] and to.x - 0.5 < op.x + cb[4]
and to.y + 0.5 > op.y + cb[2] and to.y - 0.5 < op.y + cb[5]
and to.z + 0.5 > op.z + cb[3] and to.z - 0.5 < op.z + cb[6]
then
local lua = obj.get_luaentity and obj:get_luaentity()
if not ((lua and lua.is_stack) or (not nodecore.interact(obj))) then
return
end
end
end
if nodecore.obstructed(to) then return end
local str = minetest.pos_to_string(to)
if squelch[str] then return end