1
0
Fork 0

Fix falling node falling forever on fences (hacky)

This commit is contained in:
Wuzzy 2017-12-01 22:22:00 +01:00
parent 312652552e
commit e227470474
2 changed files with 26 additions and 7 deletions

View File

@ -118,9 +118,28 @@ minetest.register_entity(":__builtin:falling_node", {
return
end
local vel = self.object:getvelocity()
-- Fix position if entity does not move
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
local npos = self.object:getpos()
self.object:setpos(vector.round(npos))
local npos = vector.round(self.object:getpos())
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
})

View File

@ -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
-- Collision box
local cp = {-2/16, -0.5, -2/16, 2/16, 1, 2/16}
local cx1 = {-0.5, -2/16, -2/16, -2/16, 1, 2/16} --unten(quer) -x
local cx2 = {2/16, -2/16, -2/16, 0.5, 1, 2/16} --unten(quer) x
local cz1 = {-2/16, -2/16, -0.5, 2/16, 1, -2/16} --unten(quer) -z
local cz2 = {-2/16, -2/16, 2/16, 2/16, 1, 0.5} --unten(quer) z
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.01, 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.01, -2/16} --unten(quer) -z
local cz2 = {-2/16, -2/16, 2/16, 2/16, 1.01, 0.5} --unten(quer) z
mcl_fences = {}