mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Fix armor not actually protecting lol
This commit is contained in:
parent
49e7def70a
commit
5d9bb7cacd
3 changed files with 11 additions and 12 deletions
|
@ -39,7 +39,7 @@ function minetest.register_on_player_hpchange(func, modifier)
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
function mcl_damage.get_mcl_damage_reason(mt_reason)
|
||||
|
@ -86,8 +86,9 @@ function mcl_damage.get_mcl_damage_reason(mt_reason)
|
|||
end
|
||||
|
||||
mcl_reason.source = mcl_reason.source or mcl_reason.direct
|
||||
|
||||
mcl_reason.flags = mcl_damage.types[mcl_reason.type]
|
||||
|
||||
return mcl_reason
|
||||
end
|
||||
|
||||
function mcl_damage.register_type(name, def)
|
||||
|
|
|
@ -24,9 +24,9 @@ function mcl_armor.damage_modifier(obj, hp_change, reason)
|
|||
|
||||
if inv then
|
||||
for name, element in pairs(mcl_armor.elements) do
|
||||
local itemstack = inventory:get_stack("armor", element.index)
|
||||
if not stack:is_empty() then
|
||||
local itemname = stack:get_name()
|
||||
local itemstack = inv:get_stack("armor", element.index)
|
||||
if not itemstack:is_empty() then
|
||||
local itemname = itemstack:get_name()
|
||||
local enchantments = mcl_enchanting.get_enchantments(itemstack)
|
||||
|
||||
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")
|
||||
|
||||
mcl_util.use_item_durability(itemstack, uses)
|
||||
inventory:set_stack("armor", element.index, itemstack)
|
||||
inv:set_stack("armor", element.index, itemstack)
|
||||
end
|
||||
|
||||
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)]
|
||||
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
|
||||
|
||||
mcl_armor.update(obj)
|
||||
|
||||
return -math.floor(damage + 0.5)
|
||||
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)
|
||||
|
||||
|
||||
mcl_damage.register_modifier(function(player, hp_change, _, reason)
|
||||
return mcl_armor.damage_modifier(player, hp_change, reason)
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue