Try to update Milo for 1.19

Removes Milo trying to access damage on items (`nil` because of The
Flattening). We might also need to reimplement showing durability in the
item's display name - I got a little too carried away with removing
mentions of "damage". Also renames nbtHash to nbt to be consistent with
new CC:T naming. I tried not to touch anything related to MiloRemote for
now, and there are probably still many bugs remaining that need to be
ironed out. Most of the basic functionality works now, though.
This commit is contained in:
Kan18
2022-12-24 15:33:01 +04:00
parent 2461d060e0
commit 2f67fb2ef8
16 changed files with 101 additions and 100 deletions

View File

@@ -93,7 +93,7 @@ function Milo:getMatches(item, flags)
local count = 0
local items = self:listItems()
if not flags.ignoreDamage and not flags.ignoreNbtHash then
if not flags.ignoreNbt then
local key = item.key or itemDB:makeKey(item)
local v = items[key]
if v then
@@ -104,8 +104,7 @@ function Milo:getMatches(item, flags)
else
for key,v in pairs(items) do
if item.name == v.name and
(flags.ignoreDamage or item.damage == v.damage) and
(flags.ignoreNbtHash or item.nbtHash == v.nbtHash) then
(flags.ignoreNbt or item.nbt == v.nbt) then
t[key] = Util.shallowCopy(v)
count = count + v.count
@@ -125,7 +124,7 @@ function Milo:getTurtleInventory()
for i, v in pairs(self.context.turtleInventory.adapter.list()) do
list[i] = itemDB:get(v, function()
return self.context.turtleInventory.adapter.getItemMeta(i)
return self.context.turtleInventory.adapter.getItemDetail(i)
end)
end
@@ -277,22 +276,15 @@ function Milo:learnRecipe()
for _,v1 in pairs(results) do
for _,v2 in pairs(ingredients) do
if v1.name == v2.name and
v1.nbtHash == v2.nbtHash and
(v1.damage == v2.damage or
(v1.maxDamage > 0 and v2.maxDamage > 0 and
v1.damage ~= v2.damage)) then
v1.nbt == v2.nbt then
if not newRecipe.crafingTools then
newRecipe.craftingTools = { }
end
local tool = Util.shallowCopy(v2)
if tool.maxDamage > 0 then
tool.damage = '*'
v2.damage = '*'
end
--[[
Turtles can only craft one item at a time using a tool :(
]]--
]] -- Todo: check if this still applies
maxCount = 1
newRecipe.craftingTools[itemDB:makeKey(tool)] = true