for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack sta = inventory.getStackInSlot(i);
if (sta != null) stacks.add(sta.copy());
inventory.setInventorySlotContents(i, null);
}
<BUG>for (ItemStack stack : stacks) {
InventoryUtils.insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, ANY_SLOT);

}
}</BUG>
@LuaCallable(description = "Swap two slots in the inventory")

for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack sta = inventory.getStackInSlot(i);
if (sta != null) stacks.add(sta.copy());
inventory.setInventorySlotContents(i, null);
}
for (ItemStack stack : stacks)
ItemDistribution.insertItemIntoInventory(inventory, stack, ForgeDirection.UNKNOWN, ANY_SLOT);
target.markDirty();
}
@LuaCallable(description = "Swap two slots in the inventory")
