fuzzy recipe ingredients

This commit is contained in:
kepler155c
2018-02-20 01:22:25 -05:00
parent cfc1502f2a
commit 6eff117d4a

View File

@@ -30,7 +30,7 @@ local function safeString(text)
return text return text
end end
local function makeKey(item) function itemDB:makeKey(item)
return table.concat({ item.name, item.damage or '*', item.nbtHash }, ':') return table.concat({ item.name, item.damage or '*', item.nbtHash }, ':')
end end
@@ -55,14 +55,14 @@ function itemDB:get(key)
key = self:splitKey(key) key = self:splitKey(key)
end end
local item = TableDB.get(self, makeKey(key)) local item = TableDB.get(self, self:makeKey(key))
if item then if item then
return item return item
end end
-- try finding an item that has damage values -- try finding an item that has damage values
if type(key.damage) == 'number' then if type(key.damage) == 'number' then
item = TableDB.get(self, makeKey({ name = key.name, nbtHash = key.nbtHash })) item = TableDB.get(self, self:makeKey({ name = key.name, nbtHash = key.nbtHash }))
if item and item.maxDamage then if item and item.maxDamage then
item = Util.shallowCopy(item) item = Util.shallowCopy(item)
item.damage = key.damage item.damage = key.damage
@@ -126,7 +126,7 @@ function itemDB:add(baseItem)
end end
end end
TableDB.add(self, makeKey(nItem), nItem) TableDB.add(self, self:makeKey(nItem), nItem)
nItem = Util.shallowCopy(nItem) nItem = Util.shallowCopy(nItem)
nItem.damage = baseItem.damage nItem.damage = baseItem.damage
nItem.nbtHash = baseItem.nbtHash nItem.nbtHash = baseItem.nbtHash