From 70198eb50b1ea0af58878df4d818bb0ac0fd35b6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 19 Sep 2017 15:45:23 +0200 Subject: [PATCH] Allow to light Nether portal with any fire --- mods/ITEMS/mcl_fire/depends.txt | 1 + mods/ITEMS/mcl_fire/fire_charge.lua | 5 ++++- mods/ITEMS/mcl_fire/flint_and_steel.lua | 5 ++++- mods/ITEMS/mcl_fire/init.lua | 18 ++++++++++++++++-- mods/ITEMS/mcl_portals/depends.txt | 1 - mods/ITEMS/mcl_portals/init.lua | 2 ++ mods/ITEMS/mcl_portals/portal_nether.lua | 20 ++++++++++++-------- mods/ITEMS/mcl_tnt/init.lua | 1 + 8 files changed, 40 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_fire/depends.txt b/mods/ITEMS/mcl_fire/depends.txt index 3beb7648d0..3b66be9bbe 100644 --- a/mods/ITEMS/mcl_fire/depends.txt +++ b/mods/ITEMS/mcl_fire/depends.txt @@ -2,3 +2,4 @@ mcl_core mcl_util mcl_sounds mcl_nether? +mcl_portals? diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index 83612b8709..5cf25b774b 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -19,7 +19,10 @@ minetest.register_craftitem("mcl_fire:fire_charge", { if pointed_thing.type == "node" then local nodedef = minetest.registered_nodes[node.name] if nodedef and nodedef._on_ignite then - nodedef._on_ignite(user, pointed_thing) + local overwrite = nodedef._on_ignite(user, pointed_thing) + if not overwrite then + mcl_fire.set_fire(pointed_thing) + end else mcl_fire.set_fire(pointed_thing) end diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index 9737c3adf3..c835a1321a 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -25,7 +25,10 @@ minetest.register_tool("mcl_fire:flint_and_steel", { if pointed_thing.type == "node" then local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] if nodedef and nodedef._on_ignite then - nodedef._on_ignite(user, pointed_thing) + local overwrite = nodedef._on_ignite(user, pointed_thing) + if not overwrite then + mcl_fire.set_fire(pointed_thing) + end else mcl_fire.set_fire(pointed_thing) end diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 9991dfca60..3959b53a06 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -72,11 +72,18 @@ minetest.register_node("mcl_fire:fire", { end, drop = "", 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 + if under == "mcl_nether:magma" or under == "mcl_nether:netherrack" then minetest.swap_node(pos, {name = "mcl_fire:eternal_fire"}) end + + if minetest.get_modpath("mcl_portals") then + mcl_portals.light_nether_portal(pos) + end + minetest.get_node_timer(pos):start(math.random(3, 7)) end, _mcl_blast_resistance = 0, @@ -126,8 +133,13 @@ minetest.register_node("mcl_fire:eternal_fire", { -- Restart timer minetest.get_node_timer(pos):start(math.random(3, 7)) end, + -- Start burning timer and light Nether portal (if possible) on_construct = function(pos) minetest.get_node_timer(pos):start(math.random(3, 7)) + + if minetest.get_modpath("mcl_portals") then + mcl_portals.light_nether_portal(pos) + end end, sounds = {}, drop = "", @@ -395,8 +407,9 @@ local eternal_override = { 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 - mcl_fire.set_fire(pointed_thing) + return false end end, } @@ -409,8 +422,9 @@ local eternal_override_end = { 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 - mcl_fire.set_fire(pointed_thing) + return false end end, } diff --git a/mods/ITEMS/mcl_portals/depends.txt b/mods/ITEMS/mcl_portals/depends.txt index 3ba18d1cd1..dac4dd12e3 100644 --- a/mods/ITEMS/mcl_portals/depends.txt +++ b/mods/ITEMS/mcl_portals/depends.txt @@ -1,7 +1,6 @@ mcl_init mcl_util mcl_core -mcl_fire mcl_nether mcl_end mcl_particles diff --git a/mods/ITEMS/mcl_portals/init.lua b/mods/ITEMS/mcl_portals/init.lua index cf4716c409..2fd96afadb 100644 --- a/mods/ITEMS/mcl_portals/init.lua +++ b/mods/ITEMS/mcl_portals/init.lua @@ -1,5 +1,7 @@ -- Load files +mcl_portals = {} + -- Nether portal: -- Obsidian frame, activated by flint and steel dofile(minetest.get_modpath("mcl_portals").."/portal_nether.lua") diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index ede23c4601..e2fc4e4ef4 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -281,8 +281,13 @@ local function is_portal(pos) end end --- Light Nether portal and create target portal -local function make_portal(pos) +-- Attempts to light a Nether portal at pos and +-- select target position. +-- Pos can be any of the obsidian frame blocks or the inner part. +-- The frame MUST be filled only with air or any fire, which will be replaced with Nether portal blocks. +-- If no Nether portal can be lit, nothing happens. +-- Returns true on success and false on failure. +function mcl_portals.light_nether_portal(pos) -- Create Nether portal nodes local p1, p2 = is_portal(pos) if not p1 or not p2 then @@ -297,7 +302,8 @@ local function make_portal(pos) else p = {x = p1.x, y = y, z = p1.z + d} end - if minetest.get_node(p).name ~= "air" then + local nn = minetest.get_node(p).name + if nn ~= "air" and minetest.get_item_group(nn, "fire") ~= 1 then return false end end @@ -451,7 +457,7 @@ minetest.override_item("mcl_core:obsidian", { on_destruct = destroy_portal, _on_ignite = function(user, pointed_thing) local pos = pointed_thing.under - local portal_placed = make_portal(pos) + local portal_placed = mcl_portals.light_nether_portal(pos) if portal_placed and minetest.get_modpath("doc") then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal") @@ -460,11 +466,9 @@ minetest.override_item("mcl_core:obsidian", { if minetest.get_modpath("awards") and dim ~= "nether" and user:is_player() then awards.unlock(user:get_player_name(), "mcl:buildNetherPortal") end + return true else - local node = minetest.get_node(pointed_thing.above) - if node.name ~= "mcl_portals:portal" then - mcl_fire.set_fire(pointed_thing) - end + return false end end, }) diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 3acb865b93..6da3104d07 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -74,6 +74,7 @@ minetest.register_node("mcl_tnt:tnt", { }}, _on_ignite = function(player, pointed_thing) tnt.ignite(pointed_thing.under) + return true end, sounds = sounds, })