From a8dd5f42c4b76e0be457b02621fc287919d44eb0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 9 May 2017 17:49:38 +0200 Subject: [PATCH] _on_ignite, +eternal fire when igniting netherrack --- mods/ITEMS/mcl_fire/depends.txt | 1 + mods/ITEMS/mcl_fire/flint_and_steel.lua | 16 ++++++++-------- mods/ITEMS/mcl_fire/init.lua | 23 ++++++++++++++++++++++- mods/ITEMS/mcl_tnt/init.lua | 3 +++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_fire/depends.txt b/mods/ITEMS/mcl_fire/depends.txt index 97bf5106..a9b74053 100644 --- a/mods/ITEMS/mcl_fire/depends.txt +++ b/mods/ITEMS/mcl_fire/depends.txt @@ -1,2 +1,3 @@ mcl_core mcl_sounds +mcl_nether? diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index 001f2b3b..afc1850d 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -13,22 +13,22 @@ minetest.register_tool("mcl_fire:flint_and_steel", { "fire_flint_and_steel", {pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8} ) + local used = false if pointed_thing.type == "node" then - if minetest.get_node(pointed_thing.under).name == "mcl_tnt:tnt" then - tnt.ignite(pointed_thing.under) - if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/65) -- 65 uses - end + local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] + if nodedef._on_ignite then + nodedef._on_ignite(pointed_thing.under, user) else mcl_fire.set_fire(pointed_thing) - if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/65) -- 65 uses - end end + used = true end if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then minetest.sound_play(idef.sound.breaks, {pos=user:getpos(), gain=0.5}) end + if not minetest.setting_getbool("creative_mode") and used == true then + itemstack:add_wear(65535/65) -- 65 uses + end return itemstack end, sound = { breaks = "default_tool_breaks" }, diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 6299e470..9bd13040 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -291,7 +291,28 @@ else -- Fire enabled end --- Set pointed_thing on fire +-- Spawn eternal fire when using flint and steel on netherrack + +local eternal_override = { + after_destruct = function(pos, oldnode) + pos.y = pos.y + 1 + if minetest.get_node(pos).name == "mcl_fire:eternal_fire" then + minetest.remove_node(pos) + end + end, + _on_ignite = function(pos, player) + local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} + if minetest.get_node(flame_pos).name == "air" then + minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) + end + end, +} + +if minetest.get_modpath("mcl_nether") then + minetest.override_item("mcl_nether:netherrack", eternal_override) +end + +-- Set pointed_thing on (normal) fire mcl_fire.set_fire = function(pointed_thing) local n = minetest.get_node(pointed_thing.above) if n.name ~= "" and n.name == "air" and not minetest.is_protected(pointed_thing.above, "fire") then diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 5e040805..d607cd25 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -54,6 +54,9 @@ minetest.register_node("mcl_tnt:tnt", { mesecons = {effector = { action_on = tnt.ignite }}, + _on_ignite = function(pos, player) + tnt.ignite(pos) + end, sounds = mcl_sounds.node_sound_wood_defaults(), })