ME Bridge Deletes NBT Data on exportItem(item: table, direction: string) -> number, err: string
zeziba opened this issue ยท 0 comments
Describe
Using the following code to move items, the me bridge deletes nbt data.
As a note, I have tried from a directly connected dire/chest to a sub-netted drive/chest both cause this issue.
NOT ONLY BOOKS
Will delete the data off apotheosis items ect.
local DEBUG = true
local LOGGING = false
-- Helper
function string:contains(sub)
return self:find(sub, 1, true) ~= nil
end
function string:count(value)
local t = self.gsub(self, ("[^%s]"):format(value), "")
if DEBUG then print(("\t\t\t(\"%s\"):count(\"%s\") = %d"):format(self, value, #t)) end
return #t
end
function table.contains(tbl, value)
-- For single depth tables that only contain strings
if tbl ~= nil then
for _, v in pairs(tbl) do
if string.find(v, value) then return true end
end
end
return false
end
function table.print(tbl)
for k, v in pairs(tbl) do
print(("%s: %s"):format(k, v))
end
return false
end
-- Overrides
local _print = print
print = function(...) if DEBUG then _print(...) end end
local label = "ME-EXPORTER"
os.setComputerLabel(label)
-- Connect to me system
local me = peripheral.find("meBridge")
-- Conenction to storage from ME Bridge
local dir_to_chest = "up"
local accepted_items = {
"minecraft:enchanted_book"
}
local tags = {
-- "forge:armor",
-- "forge:tools"
"forge:books"
}
local taboo_items = {
"Elytra"
}
-- Function to determine if should run main
local span = 10 -- Time in ms to wait to run
function FormatItem(tag, item)
if DEBUG then print(("Name: %s\n\tNBT: "):format(tag)); table.print(item.nbt) read(); end
item.nbt = {}
return item
end
function ExportItem(tag, item)
local num, err
local itemToMove = FormatItem(tag, item)
if DEBUG then
print(("\n\n----------\nItem: %s\n\tCount: %s\n\tNBT: %s\n----------\n\n"):format(itemToMove.name, itemToMove.count, itemToMove.nbt))
print("Press Enter to Accept Item Move")
read()
end
num, err = me.exportItem(itemToMove, dir_to_chest)
return num, err
end
function ExamineInventory()
local me_inv = me.listItems()
for i=1, #me_inv do
local item = me_inv[i]
if item == nil then do break end end
-- if DEBUG then
-- for k, v in pairs(item) do
-- print(("%s\t\t%s"):format(k, v))
-- end
-- read()
-- end
for _, tag in pairs(tags) do
if table.contains(item.tags, tag) then
if DEBUG then table.print(item.tags) end
if table.contains(accepted_items, item.name) then
ExportItem(tag, item)
do break end
end
end
end
end
end
function Main()
_print(("Attempting to run inventory managment will sleep for %d after"):format(span))
ExamineInventory()
sleep(span)
Main() -- Main loop
end
parallel.waitForAny(Main, function()
os.pullEventRaw("terminate")
end)
Version is
AdvancedPeripherals-0.7.25r.jar
cc-tweaked-1.19.2-1.101.2.jar
AE2WTLib-12.8.5.jar
AEAdditions-1.19.2-4.0.3.jar
appliedenergistics2-forge-12.9.2.jar
megacells-forge-2.0.0-beta.7-1.19.2.jar
Steps to reproduce
Using the above code.
- Create a enchanted book
- Have an empty ae2 system
- Place enchanted book in the ae2 network, main or sub network connected to me bridge
- Run management code
- Watch it delete nbt data off what ever is filtered for
Looked at some closed issues
#416
#424
Both seem related but alas I have not looked at the respective code in this repository as I was baffled by the nbt data just going poof.
Also as an aside, the configuration for the device is a cc advanced computer on the bottom, then the bridge then a barrel on top
So,
[' B ',
' M ',
' C '
]
B = minecraft:barrel
M = advancedperipherials:me_bridge
C = computercraft:computer_advanced
Did try in other configurations but this is what I was using when I encountered the issue.
Multiplayer?
Yes
Version
1.19.2-0.7.24b (Latest 1.19.2)
Minecraft, Forge and maybe other related mods versions
43.2.6
Screenshots or Videos
No response
Crashlog/log
No response