1
0
Fork 0

Allow to light Nether portal with any fire

This commit is contained in:
Wuzzy 2017-09-19 15:45:23 +02:00
parent 3857ff43ef
commit 70198eb50b
8 changed files with 40 additions and 13 deletions

View File

@ -2,3 +2,4 @@ mcl_core
mcl_util
mcl_sounds
mcl_nether?
mcl_portals?

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
mcl_init
mcl_util
mcl_core
mcl_fire
mcl_nether
mcl_end
mcl_particles

View File

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

View File

@ -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,
})

View File

@ -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,
})