From 744b47088b839e10b3d227e549eb720f2514d01c Mon Sep 17 00:00:00 2001 From: JoseDouglas26 Date: Sun, 16 Jun 2024 18:33:19 +0200 Subject: [PATCH] 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 Co-authored-by: JoseDouglas26 Co-committed-by: JoseDouglas26 --- mods/ITEMS/mcl_fire/fire_charge.lua | 7 ++++--- mods/ITEMS/mcl_fire/flint_and_steel.lua | 9 ++++----- mods/ITEMS/mcl_fire/init.lua | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_fire/fire_charge.lua b/mods/ITEMS/mcl_fire/fire_charge.lua index 4d18e44ed..446d5878d 100644 --- a/mods/ITEMS/mcl_fire/fire_charge.lua +++ b/mods/ITEMS/mcl_fire/fire_charge.lua @@ -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 diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index e88e34df2..ca8def983 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -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 diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 70e0769c4..02fa29061 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -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({