mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-25 19:02:26 +01:00
Fix armor being taken even if it cannot be equipped
This commit is contained in:
parent
222104b3cb
commit
f9c2d710e2
@ -43,22 +43,25 @@ function mcl_armor.equip(itemstack, obj, swap)
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local element = mcl_armor.elements[def._mcl_armor_element or ""]
|
||||
local inv = mcl_util.get_inventory(obj, true)
|
||||
|
||||
if element and inv then
|
||||
if not inv or inv:get_size("armor") == 0 then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local element = mcl_armor.elements[def._mcl_armor_element or ""]
|
||||
|
||||
if element then
|
||||
local old_stack = inv:get_stack("armor", element.index)
|
||||
local new_stack
|
||||
|
||||
if swap then
|
||||
new_stack = itemstack
|
||||
itemstack = old_stack
|
||||
else
|
||||
new_stack = itemstack:take_item()
|
||||
end
|
||||
|
||||
if swap or old_stack:is_empty() then
|
||||
inv:set_stack("armor", element.index, new_stack)
|
||||
inv:set_stack("armor", element.index, new_stack or itemstack:take_item())
|
||||
mcl_armor.on_equip(new_stack, obj)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user