recipe nbts + item get/add helper

This commit is contained in:
kepler155c@gmail.com
2019-01-04 00:29:03 -05:00
parent d0a7a6e488
commit 6606975f5b
7 changed files with 62 additions and 41 deletions

View File

@@ -57,12 +57,8 @@ function page.tabs.inventory:enable()
for k, item in pairs(inv) do
local key = itemDB:makeKey(item)
if not list[key] then
local cItem = itemDB:get(item)
if not cItem then
cItem = itemDB:add(ni.getInventory().getItemMeta(k))
end
local cItem = itemDB:get(item, function() return ni.getInventory().getItemMeta(k) end)
if cItem then
cItem = Util.shallowCopy(cItem)
cItem.key = makeKey(cItem)
list[key] = cItem
end
@@ -138,10 +134,7 @@ Event.onInterval(5, function()
if empty then
for k,v in pairs(inv) do
local item = itemDB:get(v)
if not item then
item = itemDB:add(ni.getInventory().getItemMeta(k))
end
local item = itemDB:get(v, function() ni.getInventory().getItemMeta(k) end)
if item then
if context.state.autostore[makeKey(item)] then
ni.getInventory().pushItems(target, k, v.count, slot)