use math.ceil() instead of math.round()

This commit is contained in:
Araca 2024-03-28 17:37:08 +01:00 committed by Araca
parent 50f3f2c5c8
commit 2c25c94199
2 changed files with 3 additions and 3 deletions

View file

@ -86,7 +86,7 @@ tt.register_snippet(function(itemstring, toolcaps, itemstack)
local real_uses = base_uses * math.pow(3, maxlevel) local real_uses = base_uses * math.pow(3, maxlevel)
if real_uses < 65535 then if real_uses < 65535 then
if itemstack then if itemstack then
local remaining_uses = math.round(real_uses - (itemstack:get_wear() * base_uses) / 65535) local remaining_uses = math.ceil(real_uses - (itemstack:get_wear() * base_uses) / 65535)
miningusesstr = remaining_uses .. "/" .. real_uses miningusesstr = remaining_uses .. "/" .. real_uses
else else
miningusesstr = S("@1 uses", real_uses) miningusesstr = S("@1 uses", real_uses)

View file

@ -41,7 +41,7 @@ tt.register_snippet(function(itemstring, _, itemstack)
if unbreaking > 0 then if unbreaking > 0 then
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1))) use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
end end
remaining_uses = math.round(use - (itemstack:get_wear() * use) / 65535) remaining_uses = math.ceil(use - (itemstack:get_wear() * use) / 65535)
end end
if use > 0 then if use > 0 then
if use ~= remaining_uses then if use ~= remaining_uses then
@ -117,7 +117,7 @@ tt.register_snippet(function(itemstring, _, itemstack)
if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then
local stack = itemstack or ItemStack(itemstring) local stack = itemstack or ItemStack(itemstring)
local use = mcl_util.calculate_durability(stack) local use = mcl_util.calculate_durability(stack)
local remaining_use = math.round(use - (stack:get_wear() * use) / 65535) local remaining_use = math.ceil(use - (stack:get_wear() * use) / 65535)
return S("Durability: @1", S("@1 uses", remaining_use .."/".. use)) return S("Durability: @1", S("@1 uses", remaining_use .."/".. use))
end end
end) end)