forked from VoxeLibre/VoxeLibre
Fix falling node falling forever on fences (hacky)
This commit is contained in:
parent
312652552e
commit
e227470474
|
@ -118,9 +118,28 @@ minetest.register_entity(":__builtin:falling_node", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:getvelocity()
|
||||||
|
-- Fix position if entity does not move
|
||||||
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
||||||
local npos = self.object:getpos()
|
local npos = vector.round(self.object:getpos())
|
||||||
self.object:setpos(vector.round(npos))
|
local npos2 = table.copy(npos)
|
||||||
|
npos2.y = npos2.y - 2
|
||||||
|
local lownode = minetest.get_node(npos2)
|
||||||
|
-- Special check required for fences, because of their overhigh collision box.
|
||||||
|
if minetest.get_item_group(lownode.name, "fence") == 1 then
|
||||||
|
-- Instantly stop the node if it is above a fence. This is needed
|
||||||
|
-- because the falling node collides early with a fence node.
|
||||||
|
-- Hacky, because the falling node will teleport a short distance, instead
|
||||||
|
-- of smoothly fall on the fence post.
|
||||||
|
local npos3 = table.copy(npos)
|
||||||
|
npos3.y = npos3.y - 1
|
||||||
|
minetest.add_node(npos3, self.node)
|
||||||
|
self.object:remove()
|
||||||
|
minetest.check_for_falling(npos3)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
-- Normal position fix (expected case)
|
||||||
|
self.object:setpos(npos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,11 +12,11 @@ local z2 = {-1/16, 4/16, 2/16, 1/16, 7/16, 0.5} --oben(quer) z
|
||||||
local z22 = {-1/16, -2/16, 2/16, 1/16, 1/16, 0.5} --unten(quer) z
|
local z22 = {-1/16, -2/16, 2/16, 1/16, 1/16, 0.5} --unten(quer) z
|
||||||
|
|
||||||
-- Collision box
|
-- Collision box
|
||||||
local cp = {-2/16, -0.5, -2/16, 2/16, 1, 2/16}
|
local cp = {-2/16, -0.5, -2/16, 2/16, 1.01, 2/16}
|
||||||
local cx1 = {-0.5, -2/16, -2/16, -2/16, 1, 2/16} --unten(quer) -x
|
local cx1 = {-0.5, -2/16, -2/16, -2/16, 1.01, 2/16} --unten(quer) -x
|
||||||
local cx2 = {2/16, -2/16, -2/16, 0.5, 1, 2/16} --unten(quer) x
|
local cx2 = {2/16, -2/16, -2/16, 0.5, 1.01, 2/16} --unten(quer) x
|
||||||
local cz1 = {-2/16, -2/16, -0.5, 2/16, 1, -2/16} --unten(quer) -z
|
local cz1 = {-2/16, -2/16, -0.5, 2/16, 1.01, -2/16} --unten(quer) -z
|
||||||
local cz2 = {-2/16, -2/16, 2/16, 2/16, 1, 0.5} --unten(quer) z
|
local cz2 = {-2/16, -2/16, 2/16, 2/16, 1.01, 0.5} --unten(quer) z
|
||||||
|
|
||||||
mcl_fences = {}
|
mcl_fences = {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue