forked from VoxeLibre/VoxeLibre
Unbreaking for armor
This commit is contained in:
parent
a516eccd6d
commit
afa11c0723
|
@ -1 +1,2 @@
|
||||||
tt
|
tt
|
||||||
|
mcl_enchanting
|
||||||
|
|
|
@ -25,7 +25,7 @@ tt.register_snippet(function(itemstring)
|
||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
end)
|
end)
|
||||||
tt.register_snippet(function(itemstring)
|
tt.register_snippet(function(itemstring, _, itemstack)
|
||||||
local def = minetest.registered_items[itemstring]
|
local def = minetest.registered_items[itemstring]
|
||||||
local s = ""
|
local s = ""
|
||||||
local use = minetest.get_item_group(itemstring, "mcl_armor_uses")
|
local use = minetest.get_item_group(itemstring, "mcl_armor_uses")
|
||||||
|
@ -34,6 +34,12 @@ tt.register_snippet(function(itemstring)
|
||||||
s = s .. S("Armor points: @1", pts)
|
s = s .. S("Armor points: @1", pts)
|
||||||
s = s .. "\n"
|
s = s .. "\n"
|
||||||
end
|
end
|
||||||
|
if itemstack then
|
||||||
|
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||||
|
if unbreaking > 0 then
|
||||||
|
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
|
||||||
|
end
|
||||||
|
end
|
||||||
if use > 0 then
|
if use > 0 then
|
||||||
s = s .. S("Armor durability: @1", use)
|
s = s .. S("Armor durability: @1", use)
|
||||||
end
|
end
|
||||||
|
|
|
@ -518,6 +518,10 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
-- Damage armor
|
-- Damage armor
|
||||||
local use = stack:get_definition().groups["mcl_armor_uses"] or 0
|
local use = stack:get_definition().groups["mcl_armor_uses"] or 0
|
||||||
|
local unbreaking = mcl_enchanting.get_enchantment(stack, "unbreaking")
|
||||||
|
if unbreaking > 0 then
|
||||||
|
use = use / (0.6 + 0.4 / (unbreaking + 1))
|
||||||
|
end
|
||||||
if use > 0 then
|
if use > 0 then
|
||||||
local wear = armor_damage * math.floor(65536/use)
|
local wear = armor_damage * math.floor(65536/use)
|
||||||
stack:add_wear(wear)
|
stack:add_wear(wear)
|
||||||
|
|
|
@ -3,3 +3,4 @@ mcl_player
|
||||||
mcl_fire?
|
mcl_fire?
|
||||||
ethereal?
|
ethereal?
|
||||||
bakedclay?
|
bakedclay?
|
||||||
|
mcl_enchanting
|
||||||
|
|
Loading…
Reference in New Issue