1
0
Fork 0

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

View File

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

View File

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

View File

@ -395,7 +395,8 @@ end
-- Set pointed_thing on (normal) fire. -- Set pointed_thing on (normal) fire.
-- * pointed_thing: Pointed thing to ignite -- * pointed_thing: Pointed thing to ignite
-- * player: Player who sets fire or nil if nobody -- * 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 local pname
if player == nil then if player == nil then
pname = "" pname = ""
@ -403,6 +404,10 @@ mcl_fire.set_fire = function(pointed_thing, player)
pname = player:get_player_name() pname = player:get_player_name()
end end
local n = minetest.get_node(pointed_thing.above) 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 if minetest.is_protected(pointed_thing.above, pname) then
minetest.record_protection_violation(pointed_thing.above, pname) minetest.record_protection_violation(pointed_thing.above, pname)
return return