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

View file

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

View file

@ -31,23 +31,22 @@ minetest.register_tool("mcl_fire:flint_and_steel", {
{pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8},
true
)
local used = false
local used = nil
if pointed_thing.type == "node" then
local nodedef = minetest.registered_nodes[get_node(pointed_thing.under).name]
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, false)
used = mcl_fire.set_fire(pointed_thing, user, false)
end
else
mcl_fire.set_fire(pointed_thing, user, false)
used = mcl_fire.set_fire(pointed_thing, user, false)
end
used = true
end
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)
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
end
return itemstack

View file

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