From 73cdd17a7c69e9347fde1dbfee333405b9f031c9 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 16 Feb 2017 19:32:42 +0100 Subject: [PATCH] Generalize item destruction logic --- API.md | 1 + mods/CORE/mcl_core/nodes.lua | 4 ++-- mods/ENTITIES/mcl_item_entity/init.lua | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/API.md b/API.md index c1eb2894..d4831272 100644 --- a/API.md +++ b/API.md @@ -22,6 +22,7 @@ This section explains all the used groups in this subgame. * `soil_sugarcane=1`: Sugar canes will grow on this near water * `soil_nether_wart=1`: Nether wart will grow on this * `disable_suffocation=1`: Disables suffocation for full solid cubes (1) +* `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed #### Footnotes diff --git a/mods/CORE/mcl_core/nodes.lua b/mods/CORE/mcl_core/nodes.lua index 3d14db62..c079f062 100644 --- a/mods/CORE/mcl_core/nodes.lua +++ b/mods/CORE/mcl_core/nodes.lua @@ -1198,7 +1198,7 @@ minetest.register_node("mcl_core:lava_flowing", { liquid_range = 4, damage_per_second = 4*2, post_effect_color = {a=192, r=255, g=64, b=0}, - groups = {lava=3, liquid=2, igniter=3, not_in_creative_inventory=1}, + groups = {lava=3, liquid=2, igniter=3, destroys_items=1, not_in_creative_inventory=1}, }) minetest.register_node("mcl_core:lava_source", { @@ -1234,7 +1234,7 @@ minetest.register_node("mcl_core:lava_source", { damage_per_second = 4*2, post_effect_color = {a=192, r=255, g=64, b=0}, stack_max = 64, - groups = {lava=3, liquid=2, igniter=3, not_in_creative_inventory=1}, + groups = {lava=3, liquid=2, igniter=3, destroys_items=1, not_in_creative_inventory=1}, }) minetest.register_node("mcl_core:cobble", { diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 969e172a..bf9798f3 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -361,10 +361,14 @@ core.register_entity(":__builtin:item", { return end - -- Destroy item in lava and other igniters + -- Destroy item in lava or special nodes local nn = node.name - if (minetest.registered_nodes[nn] and minetest.registered_nodes[nn].damage_per_second > 0) or nn == "maptools:igniter" then - minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.5}) + local def = minetest.registered_nodes[nn] + if (def and def.groups and (def.groups.lava or def.groups.destroys_items == 1)) then + -- Special effect for lava + if def.groups.lava then + minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.5}) + end self.object:remove() return end