mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 22:22:25 +01:00
Use add_wear_by_uses to fix incorrect uses counts (#2959)
This commit is contained in:
parent
b4392aeb1f
commit
d7dd15782c
@ -66,7 +66,7 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
|
|||||||
if not minetest.is_creative_enabled(player_name) then
|
if not minetest.is_creative_enabled(player_name) then
|
||||||
-- wear tool
|
-- wear tool
|
||||||
local wdef = itemstack:get_definition()
|
local wdef = itemstack:get_definition()
|
||||||
itemstack:add_wear(65535/(uses-1))
|
itemstack:add_wear_by_uses(uses)
|
||||||
-- tool break sound
|
-- tool break sound
|
||||||
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||||
minetest.sound_play(wdef.sound.breaks, {pos = pt.above,
|
minetest.sound_play(wdef.sound.breaks, {pos = pt.above,
|
||||||
|
@ -114,7 +114,7 @@ minetest.register_tool("fire:flint_and_steel", {
|
|||||||
if not minetest.is_creative_enabled(player_name) then
|
if not minetest.is_creative_enabled(player_name) then
|
||||||
-- Wear tool
|
-- Wear tool
|
||||||
local wdef = itemstack:get_definition()
|
local wdef = itemstack:get_definition()
|
||||||
itemstack:add_wear(1000)
|
itemstack:add_wear_by_uses(66)
|
||||||
|
|
||||||
-- Tool break sound
|
-- Tool break sound
|
||||||
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
|
||||||
|
@ -108,7 +108,7 @@ minetest.register_tool("fireflies:bug_net", {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not minetest.is_creative_enabled(player_name) then
|
if not minetest.is_creative_enabled(player_name) then
|
||||||
itemstack:add_wear(256)
|
itemstack:add_wear_by_uses(256)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -141,7 +141,7 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not minetest.is_creative_enabled(player_name) then
|
if not minetest.is_creative_enabled(player_name) then
|
||||||
itemstack:add_wear(65535 / ((uses or 200) - 1))
|
itemstack:add_wear_by_uses(uses or 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
|
Loading…
Reference in New Issue
Block a user