Fixes flint and steel adding wear when not setting node on fire (#4368)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4368
Reviewed-by: teknomunk <teknomunk@protonmail.com>
Co-authored-by: JoseDouglas26 <josedouglas20002014@gmail.com>
Co-committed-by: JoseDouglas26 <josedouglas20002014@gmail.com>
This commit is contained in:
JoseDouglas26 2024-06-16 18:33:19 +02:00 committed by the-real-herowl
parent 6654c86fb2
commit 744b47088b
3 changed files with 9 additions and 9 deletions

@ -27,18 +27,19 @@ minetest.register_craftitem("mcl_fire:fire_charge", {
end end
-- Ignite/light fire -- Ignite/light fire
local used = nil
local node = get_node(pointed_thing.under) local node = get_node(pointed_thing.under)
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local nodedef = minetest.registered_nodes[node.name] local nodedef = minetest.registered_nodes[node.name]
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, false) used = mcl_fire.set_fire(pointed_thing, user, false)
end end
else else
mcl_fire.set_fire(pointed_thing, user, false) used = mcl_fire.set_fire(pointed_thing, user, false)
end end
if not minetest.is_creative_enabled(user:get_player_name()) then if not minetest.is_creative_enabled(user:get_player_name()) and used then
itemstack:take_item() itemstack:take_item()
end end
end end

@ -31,23 +31,22 @@ minetest.register_tool("mcl_fire:flint_and_steel", {
{pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8}, {pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8},
true true
) )
local used = false local used = nil
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local nodedef = minetest.registered_nodes[get_node(pointed_thing.under).name] local nodedef = minetest.registered_nodes[get_node(pointed_thing.under).name]
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, false) used = mcl_fire.set_fire(pointed_thing, user, false)
end end
else else
mcl_fire.set_fire(pointed_thing, user, false) used = mcl_fire.set_fire(pointed_thing, user, false)
end end
used = true
end end
if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then
minetest.sound_play(idef.sound.breaks, {pos=user:get_pos(), gain=0.5}, true) minetest.sound_play(idef.sound.breaks, {pos=user:get_pos(), gain=0.5}, true)
end end
if (not minetest.is_creative_enabled(user:get_player_name())) and used == true then if (not minetest.is_creative_enabled(user:get_player_name())) and used then
itemstack:add_wear(65535/65) -- 65 uses itemstack:add_wear(65535/65) -- 65 uses
end end
return itemstack return itemstack

@ -469,7 +469,7 @@ function mcl_fire.set_fire(pointed_thing, player, allow_on_fire)
return return
end end
add_node(pointed_thing.above, {name="mcl_fire:fire"}) return add_node(pointed_thing.above, {name="mcl_fire:fire"})
end end
minetest.register_lbm({ minetest.register_lbm({