From b4f1d2c521bd1eb090f5c5b2a3145660f0b4b41c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 11 Nov 2017 19:52:11 +0100 Subject: [PATCH] Move eternal fire ignition code to the actual node --- mods/ITEMS/mcl_core/nodes_base.lua | 20 ++++++++++++ mods/ITEMS/mcl_fire/depends.txt | 1 - mods/ITEMS/mcl_fire/init.lua | 50 +++--------------------------- mods/ITEMS/mcl_nether/init.lua | 28 +++++++++++++++++ 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/mods/ITEMS/mcl_core/nodes_base.lua b/mods/ITEMS/mcl_core/nodes_base.lua index 9d793d3fe..0aa6a041e 100644 --- a/mods/ITEMS/mcl_core/nodes_base.lua +++ b/mods/ITEMS/mcl_core/nodes_base.lua @@ -563,6 +563,26 @@ minetest.register_node("mcl_core:bedrock", { drop = '', _mcl_blast_resistance = 18000000, _mcl_hardness = -1, + + -- Eternal fire on top of bedrock, if in the End dimension + after_destruct = function(pos) + 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(player, pointed_thing) + local pos = pointed_thing.under + local _, dim = mcl_util.y_to_layer(pos.y) + local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} + local fn = minetest.get_node(flame_pos) + if dim == "end" and fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then + minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) + return true + else + return false + end + end, }) minetest.register_node("mcl_core:cobble", { diff --git a/mods/ITEMS/mcl_fire/depends.txt b/mods/ITEMS/mcl_fire/depends.txt index 3b66be9bb..bb7417e62 100644 --- a/mods/ITEMS/mcl_fire/depends.txt +++ b/mods/ITEMS/mcl_fire/depends.txt @@ -1,5 +1,4 @@ mcl_core mcl_util mcl_sounds -mcl_nether? mcl_portals? diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 3959b53a0..fd66cf957 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -74,9 +74,11 @@ minetest.register_node("mcl_fire:fire", { sounds = {}, -- Turn into eternal fire on special blocks, light Nether portal (if possible), start burning timer on_construct = function(pos) - local under = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name + local bpos = {x=pos.x, y=pos.y-1, z=pos.z} + local under = minetest.get_node(bpos).name - if under == "mcl_nether:magma" or under == "mcl_nether:netherrack" then + local _, dim = mcl_util.y_to_layer(bpos.y) + if under == "mcl_nether:magma" or under == "mcl_nether:netherrack" or (under == "mcl_core:bedrock" and dim == "end") then minetest.swap_node(pos, {name = "mcl_fire:eternal_fire"}) end @@ -391,50 +393,6 @@ else -- Fire enabled end --- Spawn eternal fire when fire starts on netherrack or magma block. --- Also on bedrock when it's in the end. - -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(player, pointed_thing) - local pos = pointed_thing.under - local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} - local fn = minetest.get_node(flame_pos) - if fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then - minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) - return true - else - return false - end - end, -} -local eternal_override_end = { - after_destruct = eternal_override.after_destruct, - _on_ignite = function(player, pointed_thing) - local pos = pointed_thing.under - local _, dim = mcl_util.y_to_layer(pos.y) - local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} - local fn = minetest.get_node(flame_pos) - if dim == "end" and fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then - minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) - return true - else - return false - end - end, -} - -minetest.override_item("mcl_core:bedrock", eternal_override_end) -if minetest.get_modpath("mcl_nether") then - minetest.override_item("mcl_nether:netherrack", eternal_override) - minetest.override_item("mcl_nether:magma", eternal_override) -end - -- Set pointed_thing on (normal) fire mcl_fire.set_fire = function(pointed_thing) local n = minetest.get_node(pointed_thing.above) diff --git a/mods/ITEMS/mcl_nether/init.lua b/mods/ITEMS/mcl_nether/init.lua index 2ca9d9440..813cf5088 100644 --- a/mods/ITEMS/mcl_nether/init.lua +++ b/mods/ITEMS/mcl_nether/init.lua @@ -35,6 +35,26 @@ minetest.register_node("mcl_nether:quartz_ore", { _mcl_hardness = 3, }) +-- For eternal fire on top of netherrack and magma blocks +-- (this code does not require a dependency on mcl_fire) +local eternal_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 +local eternal_on_ignite = function(player, pointed_thing) + local pos = pointed_thing.under + local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} + local fn = minetest.get_node(flame_pos) + if fn.name == "air" and not minetest.is_protected(flame_pos, "fire") and pointed_thing.under.y < pointed_thing.above.y then + minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) + return true + else + return false + end +end + minetest.register_node("mcl_nether:netherrack", { description = "Netherrack", _doc_items_longdesc = "Netherrack is a stone-like block home to the Nether. Starting a fire on this block will create an eternal fire.", @@ -45,6 +65,10 @@ minetest.register_node("mcl_nether:netherrack", { sounds = mcl_sounds.node_sound_stone_defaults(), _mcl_blast_resistance = 2, _mcl_hardness = 0.4, + + -- Eternal fire on top + after_destruct = eternal_after_destruct, + _on_ignite = eternal_on_ignite, }) minetest.register_node("mcl_nether:magma", { @@ -67,6 +91,10 @@ minetest.register_node("mcl_nether:magma", { end, _mcl_blast_resistance = 2.5, _mcl_hardness = 0.5, + + -- Eternal fire on top + after_destruct = eternal_after_destruct, + _on_ignite = eternal_on_ignite, }) minetest.register_node("mcl_nether:soul_sand", {