Add NBT hash to cache identifier
This commit is contained in:
parent
d7286030db
commit
93625e3147
@ -19,16 +19,18 @@ end)
|
|||||||
|
|
||||||
local nameCache = {}
|
local nameCache = {}
|
||||||
|
|
||||||
|
-- Get the name for an item in the cache
|
||||||
local function get_cache_name(item)
|
local function get_cache_name(item)
|
||||||
local n = item.name .. ":" .. item.damage
|
local n = item.name .. ":" .. item.damage
|
||||||
print(textutils.serialise(item))
|
if item.nbtHash then n = n .. "#" .. item.nbtHash end
|
||||||
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Gets the display name of the given item (in the given chest peripheral & slot)
|
-- Gets the display name of the given item (in the given chest peripheral & slot)
|
||||||
-- If its name is not cached, cache it.
|
-- If its name is not cached, cache it.
|
||||||
-- If it is, just return the cached name
|
-- If it is, just return the cached name
|
||||||
local function cache(item, chest, slot)
|
local function cache(item, chest, slot)
|
||||||
local idx = item.name .. ":" .. item.damage
|
local idx = get_cache_name(item)
|
||||||
|
|
||||||
if nameCache[idx] then
|
if nameCache[idx] then
|
||||||
return nameCache[idx]
|
return nameCache[idx]
|
||||||
|
Loading…
Reference in New Issue
Block a user