1
0
Fork 0

Generalize item destruction logic

This commit is contained in:
Wuzzy 2017-02-16 19:32:42 +01:00
parent afb186996e
commit 73cdd17a7c
3 changed files with 10 additions and 5 deletions

1
API.md
View File

@ -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

View File

@ -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", {

View File

@ -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