From 516b6a4868b19de42842949fc1364d332cbbf29b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 8 Jan 2017 00:22:10 +0100 Subject: [PATCH] Fix crash when water tries to dig attached node --- mods/default/functions.lua | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 5846af76cf..1030f25cb2 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -97,6 +97,21 @@ end -- ABMs + +local function drop_attached_node(p) + local nn = minetest.get_node(p).name + minetest.remove_node(p) + for _, item in pairs(minetest.get_node_drops(nn, "")) do + local pos = { + x = p.x + math.random()/2 - 0.25, + y = p.y + math.random()/2 - 0.25, + z = p.z + math.random()/2 - 0.25, + } + minetest.add_item(pos, item) + end +end + +-- Remove attached nodes next to flowing water minetest.register_abm({ nodenames = {"group:dig_by_water"}, neighbors = {"group:water"}, @@ -107,19 +122,16 @@ minetest.register_abm({ for zp=-1,1 do local p = {x=pos.x+xp, y=pos.y, z=pos.z+zp} local n = minetest.get_node(p) - -- On verifie si il y a de l'eau if (n.name=="default:water_flowing") then - drop_attached_node(pos) - minetest.dig_node(pos) - break + drop_attached_node(pos) + minetest.dig_node(pos) + break end end end - -- cas rare for yp=-1,1 do local p = {x=pos.x, y=pos.y+yp, z=pos.z} local n = minetest.get_node(p) - -- On verifie si il y a de l'eau if (n.name=="default:water_flowing") then drop_attached_node(pos) minetest.dig_node(pos)