1.7.10 compatibility
This commit is contained in:
@@ -81,27 +81,30 @@ function ChestAdapter:listItems()
|
|||||||
local cache = { }
|
local cache = { }
|
||||||
local items = { }
|
local items = { }
|
||||||
|
|
||||||
for _,v in pairs(self.getAllStacks(false)) do
|
-- getAllStacks sometimes fails
|
||||||
convertItem(v)
|
pcall(function()
|
||||||
local key = table.concat({ v.name, v.damage, v.nbtHash }, ':')
|
for _,v in pairs(self.getAllStacks(false)) do
|
||||||
|
convertItem(v)
|
||||||
|
local key = table.concat({ v.name, v.damage, v.nbtHash }, ':')
|
||||||
|
|
||||||
local entry = cache[key]
|
local entry = cache[key]
|
||||||
if not entry then
|
if not entry then
|
||||||
cache[key] = v
|
cache[key] = v
|
||||||
|
|
||||||
if not itemDB:get(v) then
|
if not itemDB:get(v) then
|
||||||
itemDB:add(v)
|
itemDB:add(v)
|
||||||
|
end
|
||||||
|
table.insert(items, v)
|
||||||
|
else
|
||||||
|
entry.count = entry.count + v.count
|
||||||
end
|
end
|
||||||
table.insert(items, v)
|
|
||||||
else
|
|
||||||
entry.count = entry.count + v.count
|
|
||||||
end
|
end
|
||||||
end
|
itemDB:flush()
|
||||||
itemDB:flush()
|
if not Util.empty(items) then
|
||||||
if not Util.empty(items) then
|
self.cache = cache
|
||||||
self.cache = cache
|
return items
|
||||||
return items
|
end
|
||||||
end
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:getItemInfo(item)
|
function ChestAdapter:getItemInfo(item)
|
||||||
@@ -119,19 +122,21 @@ function ChestAdapter:craftItems()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:provide(item, qty, slot, direction)
|
function ChestAdapter:provide(item, qty, slot, direction)
|
||||||
for key,stack in pairs(self.getAllStacks(false)) do
|
pcall(function()
|
||||||
if stack.id == item.name and
|
for key,stack in Util.rpairs(self.getAllStacks(false)) do
|
||||||
stack.dmg == item.damage and
|
if stack.id == item.name and
|
||||||
stack.nbt_hash == item.nbtHash then
|
stack.dmg == item.damage and
|
||||||
|
stack.nbt_hash == item.nbtHash then
|
||||||
|
|
||||||
local amount = math.min(qty, stack.qty)
|
local amount = math.min(qty, stack.qty)
|
||||||
self.pushItemIntoSlot(direction or self.direction, key, amount, slot)
|
self.pushItemIntoSlot(direction or self.direction, key, amount, slot)
|
||||||
qty = qty - amount
|
qty = qty - amount
|
||||||
if qty <= 0 then
|
if qty <= 0 then
|
||||||
break
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChestAdapter:extract(slot, qty, toSlot)
|
function ChestAdapter:extract(slot, qty, toSlot)
|
||||||
|
|||||||
Reference in New Issue
Block a user