fireflies - backport Use add_wear_by_uses to fix incorrect uses counts

* backporting d7dd15782c
  to fix https://github.com/minetest/minetest_game/pull/2959
  but will only work for recent engines.. 0.4.16/5.2.X will still
  suffers from such problem
This commit is contained in:
mckaygerhard 2023-06-20 01:17:12 -04:00
parent e655f5ecff
commit c232511346

View File

@ -4,6 +4,8 @@
local m_eth = minetest.get_modpath("ethereal") local m_eth = minetest.get_modpath("ethereal")
-- detecting cretive engine over creative privilegies -- detecting cretive engine over creative privilegies
local m_cre = minetest.get_modpath("creative") local m_cre = minetest.get_modpath("creative")
-- check recent versions
local is_55 = has_feature("dynamic_add_media_table")
-- firefly -- firefly
minetest.register_node("fireflies:firefly", { minetest.register_node("fireflies:firefly", {
@ -59,7 +61,7 @@ minetest.register_tool("fireflies:bug_net", {
end end
if not m_cre then if not m_cre then
if creative.is_enabled_for(player:get_player_name()) then if creative.is_enabled_for(player:get_player_name()) then
itemstack:add_wear(256) if is_55 then itemstack:add_wear(256) else itemstack:add_wear_by_uses(256) end
return itemstack return itemstack
end end
end end