First batch of null -> isEmpty() checks.

I most likely still missed a ton of checks...
This commit is contained in:
Gunther De Wachter
2017-06-26 05:15:25 +02:00
parent 370fc49357
commit da5879b667
117 changed files with 594 additions and 570 deletions
@@ -178,7 +178,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
this.readConfig();
}
else if( inv == this.patterns && ( removed != null || added != null ) )
else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) )
{
this.updateCraftingList();
}
@@ -264,7 +264,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private void addToSendList( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
return;
}
@@ -292,7 +292,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( final ItemStack p : this.config )
{
if( p != null )
if( !p.isEmpty() )
{
this.hasConfig = true;
break;
@@ -408,13 +408,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
IAEItemStack req = this.config.getAEStackInSlot( slot );
if( req != null && req.getStackSize() <= 0 )
{
this.config.setInventorySlotContents( slot, null );
this.config.setInventorySlotContents( slot, ItemStack.EMPTY );
req = null;
}
final ItemStack Stored = this.storage.getStackInSlot( slot );
if( req == null && Stored != null )
if( req == null && !Stored.isEmpty() )
{
final IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
this.requireWork[slot] = work.setStackSize( -work.getStackSize() );
@@ -422,7 +422,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
}
else if( req != null )
{
if( Stored == null ) // need to add stuff!
if( Stored.isEmpty() ) // need to add stuff!
{
this.requireWork[slot] = req.copy();
return;
@@ -474,7 +474,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private void addToCraftingList( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
return;
}
@@ -561,7 +561,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
for( int slot = 0; slot < this.storage.getSizeInventory(); slot++ )
{
this.onChangeInventory( this.storage, slot, InvOperation.markDirty, null, null );
this.onChangeInventory( this.storage, slot, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY );
}
}
@@ -621,23 +621,23 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
final ItemStack result = ad.addItems( whatToSend );
if( result == null )
if( result.isEmpty() )
{
whatToSend = null;
whatToSend = ItemStack.EMPTY;
}
else
{
whatToSend.setCount( whatToSend.getCount() - (whatToSend.getCount() - result.getCount()) );
}
if( whatToSend == null )
if( whatToSend.isEmpty() )
{
break;
}
}
}
if( whatToSend == null )
if( whatToSend.isEmpty() )
{
i.remove();
}
@@ -682,7 +682,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
else if( itemStack.getStackSize() > 0 )
{
// make sure strange things didn't happen...
if( adaptor.simulateAdd( itemStack.getItemStack() ) != null )
if( !adaptor.simulateAdd( itemStack.getItemStack() ).isEmpty() )
{
changed = true;
throw new GridAccessException();
@@ -693,7 +693,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
changed = true;
final ItemStack issue = adaptor.addItems( acquired.getItemStack() );
if( issue != null )
if( !issue.isEmpty() )
{
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
}
@@ -712,7 +712,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
// make sure strange things didn't happen...
final ItemStack canExtract = adaptor.simulateRemove( (int) diff, toStore.getItemStack(), null );
if( canExtract == null || canExtract.getCount() != diff )
if( canExtract.isEmpty() || canExtract.getCount() != diff )
{
changed = true;
throw new GridAccessException();
@@ -729,8 +729,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
// extract items!
changed = true;
final ItemStack removed = adaptor.removeItems( (int) diff, null, null );
if( removed == null )
final ItemStack removed = adaptor.removeItems( (int) diff, ItemStack.EMPTY, null );
if( removed.isEmpty() )
{
throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" );
}
@@ -949,7 +949,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
if( this.isBlocking() )
{
if( ad.simulateRemove( 1, null, null ) != null )
if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() )
{
continue;
}
@@ -960,7 +960,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( int x = 0; x < table.getSizeInventory(); x++ )
{
final ItemStack is = table.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
final ItemStack added = ad.addItems( is );
this.addToSendList( added );
@@ -1000,7 +1000,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
if( ad != null )
{
if( ad.simulateRemove( 1, null, null ) == null )
if( !ad.simulateRemove( 1, ItemStack.EMPTY, null ).isEmpty() )
{
allAreBusy = false;
break;
@@ -1029,12 +1029,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( int x = 0; x < table.getSizeInventory(); x++ )
{
final ItemStack is = table.getStackInSlot( x );
if( is == null )
if( is.isEmpty() )
{
continue;
}
if( ad.simulateAdd( is.copy() ) != null )
if( !ad.simulateAdd( is.copy() ).isEmpty() )
{
return false;
}
@@ -1062,7 +1062,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
{
for( final ItemStack is : this.waitingToSend )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -1071,7 +1071,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( final ItemStack is : this.upgrades )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -1079,7 +1079,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( final ItemStack is : this.storage )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -1087,7 +1087,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
for( final ItemStack is : this.patterns )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -1213,7 +1213,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
if( mop.getBlockPos().equals( directedTile.getPos() ) )
{
final ItemStack g = directedBlock.getPickBlock( directedBlockState, mop, hostWorld, directedTile.getPos(), null );
if( g != null )
if( !g.isEmpty() )
{
what = g;
}