Closed TheMuso closed 6 years ago
Jupp, thanks. I'm not entirely sure for what reason I've changed those lines in 436817a316acba33f7839d67b3b0085bb25278ba. But the database stuff is obviously unrelated and working without this. Grr, I should have written a better commit message then.
When iterating over a table of inventory slots in lua, the iteration operation ends when null is encountered, as there is no conversion from null to nil. Directly referencing a table element that represents an empty inventory slot also causes a traceback to occur.
This commit copies all ItemStacks, even empty ones, which are in fact ItemStack.EMPTY, and can be identified by the name minecraft:air in lua programs. Doing this allows iteration over a table representing an inventory to complete successfully, and direct referencing of all table elements is possible.
How to test:
Running this script against a build of the mod from git master, you will notice the iteration stops at the empty slot, and the script will only report the slots it found items in before encountering something that it doesn't know how to deal with.
Running this script against my branch will allow the iteratino to complete successfully, reporting number of filled slots, and number of total slots.