Don't allow to set fire on fire

This commit is contained in:
Wuzzy 2020-03-24 19:53:08 +01:00
parent f5268ea598
commit b56ead7a23
3 changed files with 10 additions and 5 deletions

@ -31,10 +31,10 @@ minetest.register_craftitem("mcl_fire:fire_charge", {
if nodedef and nodedef._on_ignite then
local overwrite = nodedef._on_ignite(user, pointed_thing)
if not overwrite then
mcl_fire.set_fire(pointed_thing, user)
mcl_fire.set_fire(pointed_thing, user, false)
end
else
mcl_fire.set_fire(pointed_thing, user)
mcl_fire.set_fire(pointed_thing, user, false)
end
if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item()

@ -36,10 +36,10 @@ minetest.register_tool("mcl_fire:flint_and_steel", {
if nodedef and nodedef._on_ignite then
local overwrite = nodedef._on_ignite(user, pointed_thing)
if not overwrite then
mcl_fire.set_fire(pointed_thing, user)
mcl_fire.set_fire(pointed_thing, user, false)
end
else
mcl_fire.set_fire(pointed_thing, user)
mcl_fire.set_fire(pointed_thing, user, false)
end
used = true
end

@ -395,7 +395,8 @@ end
-- Set pointed_thing on (normal) fire.
-- * pointed_thing: Pointed thing to ignite
-- * player: Player who sets fire or nil if nobody
mcl_fire.set_fire = function(pointed_thing, player)
-- * allow_on_fire: If false, can't ignite fire on fire (default: true)
mcl_fire.set_fire = function(pointed_thing, player, allow_on_fire)
local pname
if player == nil then
pname = ""
@ -403,6 +404,10 @@ mcl_fire.set_fire = function(pointed_thing, player)
pname = player:get_player_name()
end
local n = minetest.get_node(pointed_thing.above)
local nu = minetest.get_node(pointed_thing.under)
if allow_on_fire == false and minetest.get_item_group(nu.name, "fire") ~= 0 then
return
end
if minetest.is_protected(pointed_thing.above, pname) then
minetest.record_protection_violation(pointed_thing.above, pname)
return