forked from VoxeLibre/VoxeLibre
Fix on_equip crash
This commit is contained in:
parent
58d67aace6
commit
939229cb21
|
@ -53,15 +53,18 @@ function mcl_armor.equip(itemstack, obj, swap)
|
||||||
|
|
||||||
if element then
|
if element then
|
||||||
local old_stack = inv:get_stack("armor", element.index)
|
local old_stack = inv:get_stack("armor", element.index)
|
||||||
|
|
||||||
|
if swap or old_stack:is_empty() then
|
||||||
local new_stack
|
local new_stack
|
||||||
|
|
||||||
if swap then
|
if swap then
|
||||||
new_stack = itemstack
|
new_stack = itemstack
|
||||||
itemstack = old_stack
|
itemstack = old_stack
|
||||||
|
else
|
||||||
|
new_stack = itemstack:take_item()
|
||||||
end
|
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)
|
mcl_armor.on_equip(new_stack, obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue