Iterator<IGridHost> i = cluster.getTiles();
while (i.hasNext())
{
IGridHost h = i.next();
if ( h == this )
places.add( new WorldCoord( this ) );
else
{
TileEntity te = (TileEntity) h;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
{
WorldCoord wc = new WorldCoord( te );
wc.add( d, 1 );
if ( worldObj.isAirBlock( wc.x, wc.y, wc.z ) )
places.add( wc );
}
}
}
Collections.shuffle( places );
if ( places.isEmpty() )
throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" );
for (IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ))
{
ais = ais.copy();
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
while (true)
{
IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, cluster.getActionSource() );
if ( g == null )
break;
WorldCoord wc = places.poll();
places.add( wc );
Platform.spawnDrops( worldObj, wc.x, wc.y, wc.z, Arrays.asList( g.getItemStack() ) );
}