Fix on_equip crash

This commit is contained in:
Lizzy Fleckenstein 2021-04-25 13:29:22 +02:00
parent 58d67aace6
commit 939229cb21
1 changed files with 10 additions and 7 deletions

View File

@ -53,15 +53,18 @@ function mcl_armor.equip(itemstack, obj, swap)
if element then
local old_stack = inv:get_stack("armor", element.index)
local new_stack
if swap then
new_stack = itemstack
itemstack = old_stack
end
if swap or old_stack:is_empty() then
inv:set_stack("armor", element.index, new_stack or itemstack:take_item())
local new_stack
if swap then
new_stack = itemstack
itemstack = old_stack
else
new_stack = itemstack:take_item()
end
inv:set_stack("armor", element.index, new_stack)
mcl_armor.on_equip(new_stack, obj)
end
end