From 21992dc2653616db974ebfc6f0c48e436592fa34 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 3 Jul 2021 12:10:32 +0000 Subject: [PATCH 1/4] Fix #1746 (make anvils destroy items when falling) --- mods/ITEMS/mcl_anvils/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index fbf6fb751..e641183de 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -276,6 +276,12 @@ local function damage_anvil_by_using(pos) end local function damage_anvil_by_falling(pos, distance) + for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.8)) do + local entity = object:get_luaentity() + if not object:is_player() and entity and entity.name == "__builtin:item" then + object:remove() + end + end local r = math.random(1, 100) if distance > 1 then if r <= (5*distance) then From d45e1c07bdb00f62d592d4984c63da789b8cdc2c Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 3 Jul 2021 12:19:49 +0000 Subject: [PATCH 2/4] Remove unnecessary code --- mods/ITEMS/mcl_anvils/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index e641183de..509e78321 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -278,7 +278,7 @@ end local function damage_anvil_by_falling(pos, distance) for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.8)) do local entity = object:get_luaentity() - if not object:is_player() and entity and entity.name == "__builtin:item" then + if entity and entity.name == "__builtin:item" then object:remove() end end From 4afdea56dbbca4ea0a9cc15343a64f8d1d18583d Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 5 Jul 2021 12:28:14 +0000 Subject: [PATCH 3/4] Move code of making anvils destroy items when falling --- mods/ENTITIES/mcl_falling_nodes/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index 01681a159..d527603de 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -19,7 +19,10 @@ local function deal_falling_damage(self, dtime) end self._hit = self._hit or {} for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do - if mcl_util.get_hp(obj) > 0 and not self._hit[obj] then + local entity = obj:get_luaentity() + if entity and entity.name == "__builtin:item" then + obj:remove() + elseif mcl_util.get_hp(obj) > 0 and not self._hit[obj] then self._hit[obj] = true local way = self._startpos.y - pos.y local damage = (way - 1) * 2 From 5cc4fe955fc083e86503fdf2c3d10302b70f3168 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 5 Jul 2021 12:30:01 +0000 Subject: [PATCH 4/4] Remove old code of making anvils destroy items when falling --- mods/ITEMS/mcl_anvils/init.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 509e78321..fbf6fb751 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -276,12 +276,6 @@ local function damage_anvil_by_using(pos) end local function damage_anvil_by_falling(pos, distance) - for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.8)) do - local entity = object:get_luaentity() - if entity and entity.name == "__builtin:item" then - object:remove() - end - end local r = math.random(1, 100) if distance > 1 then if r <= (5*distance) then