mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-24 20:03:45 +01:00
Move eternal fire ignition code to the actual node
This commit is contained in:
parent
c6a471e5a7
commit
b4f1d2c521
@ -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", {
|
||||
|
@ -1,5 +1,4 @@
|
||||
mcl_core
|
||||
mcl_util
|
||||
mcl_sounds
|
||||
mcl_nether?
|
||||
mcl_portals?
|
||||
|
@ -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)
|
||||
|
@ -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", {
|
||||
|
Loading…
Reference in New Issue
Block a user