Fix armor not actually protecting lol
This commit is contained in:
parent
49e7def70a
commit
5d9bb7cacd
|
@ -39,7 +39,7 @@ function minetest.register_on_player_hpchange(func, modifier)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_damage.register_modifier(func, priority)
|
function mcl_damage.register_modifier(func, priority)
|
||||||
table.insert(mcl_damage, {func = func, priority = priority or 0})
|
table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_damage.get_mcl_damage_reason(mt_reason)
|
function mcl_damage.get_mcl_damage_reason(mt_reason)
|
||||||
|
@ -86,8 +86,9 @@ function mcl_damage.get_mcl_damage_reason(mt_reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_reason.source = mcl_reason.source or mcl_reason.direct
|
mcl_reason.source = mcl_reason.source or mcl_reason.direct
|
||||||
|
|
||||||
mcl_reason.flags = mcl_damage.types[mcl_reason.type]
|
mcl_reason.flags = mcl_damage.types[mcl_reason.type]
|
||||||
|
|
||||||
|
return mcl_reason
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_damage.register_type(name, def)
|
function mcl_damage.register_type(name, def)
|
||||||
|
|
|
@ -24,9 +24,9 @@ function mcl_armor.damage_modifier(obj, hp_change, reason)
|
||||||
|
|
||||||
if inv then
|
if inv then
|
||||||
for name, element in pairs(mcl_armor.elements) do
|
for name, element in pairs(mcl_armor.elements) do
|
||||||
local itemstack = inventory:get_stack("armor", element.index)
|
local itemstack = inv:get_stack("armor", element.index)
|
||||||
if not stack:is_empty() then
|
if not itemstack:is_empty() then
|
||||||
local itemname = stack:get_name()
|
local itemname = itemstack:get_name()
|
||||||
local enchantments = mcl_enchanting.get_enchantments(itemstack)
|
local enchantments = mcl_enchanting.get_enchantments(itemstack)
|
||||||
|
|
||||||
if not flags.bypasses_armor then
|
if not flags.bypasses_armor then
|
||||||
|
@ -34,7 +34,7 @@ function mcl_armor.damage_modifier(obj, hp_change, reason)
|
||||||
toughness = toughness + minetest.get_item_group(itemname, "mcl_armor_toughness")
|
toughness = toughness + minetest.get_item_group(itemname, "mcl_armor_toughness")
|
||||||
|
|
||||||
mcl_util.use_item_durability(itemstack, uses)
|
mcl_util.use_item_durability(itemstack, uses)
|
||||||
inventory:set_stack("armor", element.index, itemstack)
|
inv:set_stack("armor", element.index, itemstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not flags.bypasses_magic then
|
if not flags.bypasses_magic then
|
||||||
|
@ -90,14 +90,10 @@ function mcl_armor.damage_modifier(obj, hp_change, reason)
|
||||||
|
|
||||||
local thorns_item = thorns_pieces[math.random(#thorns_pieces)]
|
local thorns_item = thorns_pieces[math.random(#thorns_pieces)]
|
||||||
mcl_util.use_item_durability(thorns_item.itemstack, 2)
|
mcl_util.use_item_durability(thorns_item.itemstack, 2)
|
||||||
inventory:set_stack("armor", thorns_item.index, thorns_item.itemstack)
|
inv:set_stack("armor", thorns_item.index, thorns_item.itemstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_armor.update(obj)
|
mcl_armor.update(obj)
|
||||||
|
|
||||||
return -math.floor(damage + 0.5)
|
return -math.floor(damage + 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_damage.register_modifier(function(player, hp_change, _, reason)
|
|
||||||
return mcl_armor.damage_modifier(player, hp_change, reason)
|
|
||||||
end)
|
|
||||||
|
|
|
@ -140,4 +140,6 @@ minetest.register_on_joinplayer(function(player)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
mcl_damage.register_modifier(function(player, hp_change, _, reason)
|
||||||
|
return mcl_armor.damage_modifier(player, hp_change, reason)
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue