Stacks of Air
cjm721 opened this issue · 38 comments
Issue description:
Multiple ItemStacks of Air in Storage
What happens:
Do not know what causes it but have been generating them semi often in my base.
What you expected to happen:
None to be generated
Steps to reproduce:
Do not know at this time
Version (make sure you are on the latest version before reporting):
- Minecraft: 1.11.2
- Forge: 13.20.02299
- Refined Storage: 1.4.6
Does this issue occur on a server? Yes
Should also be fixed with 571c2b1
Which storages are you using? If you are using external storage(s) too, tell me to what they're connected.
Also getting this, and a crash when trying to remove the "air" from the system.
The game crashed whilst updating screen events
Error: java.lang.IllegalArgumentException: ItemStack value must not be empty. 0xtile.air@0 minecraft:air
@LittleODie what storages are you using?
My setup has 2 64k drives. I have a basic setup with one importer connected to a "quantum quarry" from extrautils2. Since the quarry mines so quickly the Importer has 1 stack upgrade and 1 speed upgrade. I thought that the setup might be inputting things too fast causing the issues so I took the speed upgrades out and problem still persisted.
By the way I am getting air & the other issue reported of items not showing up in real-time in the grid. However the real-time issue is intermittent and ceased to be an issue after a few minutes.
also got some air. Disappeared after sleeping through the night though...
Only using a diskdrive with 4 8k drives.
Same problem, I have some external storage drawers connected, a few importers(mekanism machines, Environmental Tech miner) and one disk drive full of 64k disks.
- refinedstorage 1.4.16
- Minecraft 1.11.2
- Forge 13.20.0.2310
Same problem as well, though I am using a few external storage buses hooked up to storage drawer controllers, and some extra utilities drums. However, I don't crash when clicking on air. It just does nothing. The air in the system seems to increase whenever I'm using the autocrafting mechanic.
I am getting the same thing. Air :) think that maybe Actually Additions farmer harvested air from pams harvest craft mustard seed.
From which machines/tiles are you guys importing? Perhaps some mod is inserting empty stacks in the system.
Potentially related. I had the same air stacks issue and recently used the disk manipulator to move some small disks into larger. Afterwards the disks were not empty even though the RS system could see nothing on them. I dumped the nbt on the disk:
16k Storage Disk (refinedstorage:storage_disk - 9387:2) has NBT data
{Items:[],Stored:14,Protocol:1}
TAG_Compound (10) ('')
{
TAG_List (9) ('Items') (0 entries of TAG_End (0))
{
}
TAG_Int (3) ('Stored'): 14
TAG_Int (3) ('Protocol'): 1
}
I have removed mods from this world, so could the air be from removed mod items that were in the system? That might explain the air (forge replacing removed items) and then the 'empty' disks.
Air stacks are empty by definition (see ItemStack#isEmpty
).
If the item doesn't exist anymore Item.getItemById(tag.getInteger(NBT_ITEM_TYPE))
will return null
, giving the ItemStack
a null
item.
Then, we only put the stack in the storage list if !stack.isEmpty()
(and if the stack is null
it will be empty).
Is this still on open issue? I can re-pro this on 1.10 and 1.11 like clockwork. I have a system with some importers, external storage, and lots of auto-crafting for several mod's and machines. If I start off a fairly large auto craft to build me 20 64k storage drives (from ore to completed) I'll end up with pages of "air" in the system. I can also kick-off a large job to process a bunch of plates and machines for galacticraft and end up with the same thing. For what it's worth, I think its something to do with machines (and crafters) that have multiple output slots and you pull from all of the slots, some of which don't have anything, maybe air?
Well, I'm surprised it only got fixed by a server restart then. I tried relogging first and it was still like in the GIF :P
Obviously, the grid data isn't stored on your player data (so relogging won't do anything) but on the controller block. Break and replace would've done it.
My drives managed to get some air in them as well... Don't quite know how to reproduce, but it sure as hell is in there...
EDIT:
Jesus christ it's gotten worse...
GIFV of my grid with a million stacks of air
Still can reproduce with OpenComputers cable.
I've found what special with those cables. They have weird damage value: 11250603 and maxDamage: 0.
Maybe other bug reports are related?
upd:
yep, definitely related to damage value. OC cables store they color as damage value (in RGB). If i get cable with color #000000 - all works fine.
crash-2017-07-19_08.08.13-server.txt
I'm in 1.12 and I've had my drive fill up today with air stacks. I'm using multiple external storages, some on 64k drive blocks, some on quantum storage blocks. I've also got a couple of builder quarrys running, and about 20 thermal expansion machines running/processing
After removing the controller and replacing it, the air stacks in inventory vanished.
Connect external storage to colossal chest, give it -1 priority, then put storage disks into disk drive on network and start craft something that takes items from both inventories (this reproduces issue randomly)
Connect External storage to a storage with variable number of slots (Item Interface from Actually Additions or EnderRift), and try to interact with storage through grid. This guarantees reproducing of Air#0000
issue
MC 1.12, Forge 21.1.2443, RS 1.5.14, SSP
Suggestion: A new button with "Delete all Air in Inventories" on the grid which would purge the air-lines.
This bug is on storage disks. Using the rs disk manipulator helps. As @thundr said.
I'd like to chime in with the same problem, and add that my fps with too much air in the system goes to 0-1 when searching inside a grid. My system constantly adds more and more air to the system, the only way to get rid of it is take out and replace disks.
I rewrite this: https://github.com/raoulvdberge/refinedstorage/blob/mc1.11/src/main/java/com/raoulvdberge/refinedstorage/RSUtils.java#L135-L146 for test:
public static void writeItemStack(ByteBuf buf, ItemStack stack) {
try {
NBTTagCompound tag = stack.writeToNBT(new NBTTagCompound());
System.out.print("WRITE_TAG:");
System.out.println(tag);
new Exception("WRITE BY").printStackTrace();
ByteBufUtils.writeTag(buf, tag);
}catch (Exception e){
e.printStackTrace();
}
}
public static ItemStack readItemStack(ByteBuf buf) {
try {
NBTTagCompound tag = ByteBufUtils.readTag(buf);
ItemStack read = new ItemStack(tag);
System.out.print("READ_TAG:");
System.out.println(tag);
new Exception("READ BY").printStackTrace();
return read;
}catch (Exception e){
e.printStackTrace();
}
return ItemStack.EMPTY;
}
result:
WRITE_TAG:[15:26:14] [Server thread/INFO]: [STDOUT]: {id:"opencomputers:cable",Count:0b,Damage:0s}
[15:26:14] [Server thread/INFO]: [STDERR]: java.lang.Exception: WRITE BY
[15:26:14] [Server thread/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.RSUtils.writeItemStack(RSUtils.java:145)
[15:26:14] [Server thread/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.RSUtils.writeItemStack(RSUtils.java:173)
[15:26:14] [Server thread/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.network.MessageGridItemUpdate.lambda$new$0(MessageGridItemUpdate.java:39)
[15:26:14] [Server thread/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.network.MessageGridItemUpdate.toBytes(MessageGridItemUpdate.java:74)
...
READ_TAG:[15:26:14] [Netty Local Client IO #0/INFO]: [STDOUT]: {id:"opencomputers:cable",Count:0b,Damage:0s}
[15:26:14] [Netty Local Client IO #0/INFO]: [STDERR]: java.lang.Exception: READ BY
[15:26:14] [Netty Local Client IO #0/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.RSUtils.readItemStack(RSUtils.java:164)
[15:26:14] [Netty Local Client IO #0/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem.<init>(GridStackItem.java:26)
[15:26:14] [Netty Local Client IO #0/INFO]: [STDERR]: at com.raoulvdberge.refinedstorage.network.MessageGridItemUpdate.fromBytes(MessageGridItemUpdate.java:66)
ItemStack count is 0 in some cases, so item stack is empty/air.
@marcin212 Interesting, thanks for this, I need to figure out how there can end up be 0 of an item in the storage cache list.
/**
* Write the stack fields to a NBT object. Return the new NBT object.
*/
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
ResourceLocation resourcelocation = (ResourceLocation)Item.REGISTRY.getNameForObject(this.item);
nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
nbt.setByte("Count", (byte)this.stackSize);
nbt.setShort("Damage", (short)this.itemDamage);
if (this.stackTagCompound != null)
{
nbt.setTag("tag", this.stackTagCompound);
}
if (this.capabilities != null)
{
NBTTagCompound cnbt = this.capabilities.serializeNBT();
if (!cnbt.hasNoTags()) nbt.setTag("ForgeCaps", cnbt);
}
return nbt;
}
Look at Minecraft writeToNBT. It casts itemDamage
to short and stackSize
to byte. That's why my test had zero for itemstack. If you change the buf.writeInt(stack.getItemDamage());
to buf.writeInt((short)stack.getItemDamage());
then everything works(but requires more testing).
Sure, that might fix part of the issue.
But there is still one part that doesn't make sense: when breaking + replacing the controller the issue is fixed. That means the issue is not damage-related in some cases, since the entire cache is refreshed when you break + replace.
Air stacks are empty by definition (see ItemStack#isEmpty).
https://github.com/raoulvdberge/refinedstorage/blob/mc1.12/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/storage/StorageDiskItem.java#L56-L76
If the item doesn't exist anymore Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)) will return null, giving the ItemStack a null item.
Then, we only put the stack in the storage list if !stack.isEmpty() (and if the stack is null it will be empty).
I think that you can use: net.minecraft.inventory.ItemStackHelper.saveAllItems
and net.minecraft.inventory.ItemStackHelper.loadAllItems
Well, that was fun, pardon the sarcasm. So, while autocrafting solar panels from Solar Flux Reborn I noticed the Crafting Monitor said there was 183 blocks of air missing. O.o
http://i15.photobucket.com/albums/a395/llloyd4/2017-08-10_04.00.54_zps7ijeitl2.png
Then I shut down to the main menu and tried to reload my world to try and fix the air block problem and the game froze solid, no crash log or anything, I had to force Java to close to fix. I will include the last bits of the console hoping it'll help. O.o Note, this is NOT the entire console log, just the last page or two from world shut down to attempt world start. I'm not that cruel. >.<
@raoulvdberge breaking controller for OC cables doesn't work. https://img.bymarcin.com/2017-08-11_10-43-28_5KSWFmlNl67M2gSM.gif
@raoulvdberge I found issue. You enter here itemDamage but ItemStack constructor need metadata ItemStack(Item itemIn, int amount, int meta)
. Metadata not equal itemDamage. Example for OC cables:
System.out.println("DAMAGE:" + stack.getItemDamage() + "|" + stack.getItem().getMetadata(stack) + "|" + stack.getMetadata() );
//result [10:53:40] [Server thread/INFO]: [STDOUT]: DAMAGE:11250603|0|0
edit:
Here is same issue, I think.
That is just for OC cables. There is a seperate bug that happens on more than just OC cables, and it's fixed by breaking and replacing the controller.