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
@@ -504,14 +504,14 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
fuzz = fuzz.copy();
fuzz.setStackSize( g.getStackSize() );
final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.SIMULATE, this.machineSrc );
final ItemStack is = ais == null ? null : ais.getItemStack();
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
if( is != null && is.getCount() == g.getStackSize() )
if( !is.isEmpty() && is.getCount() == g.getStackSize() )
{
found = true;
break;
}
else if( is != null )
else if( !is.isEmpty() )
{
g = g.copy();
g.decStackSize( is.getCount() );
@@ -526,9 +526,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
else
{
final IAEItemStack ais = this.inventory.extractItems( g.copy(), Actionable.SIMULATE, this.machineSrc );
final ItemStack is = ais == null ? null : ais.getItemStack();
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
if( is == null || is.getCount() < g.getStackSize() )
if( is.isEmpty() || is.getCount() < g.getStackSize() )
{
return false;
}
@@ -693,9 +693,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
if( details.isValidItemForSlot( x, fuzz.getItemStack(), this.getWorld() ) )
{
final IAEItemStack ais = this.inventory.extractItems( fuzz, Actionable.MODULATE, this.machineSrc );
final ItemStack is = ais == null ? null : ais.getItemStack();
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
if( is != null )
if( !is.isEmpty() )
{
this.postChange( AEItemStack.create( is ), this.machineSrc );
ic.setInventorySlotContents( x, is );
@@ -708,9 +708,9 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
else
{
final IAEItemStack ais = this.inventory.extractItems( input[x].copy(), Actionable.MODULATE, this.machineSrc );
final ItemStack is = ais == null ? null : ais.getItemStack();
final ItemStack is = ais == null ? ItemStack.EMPTY : ais.getItemStack();
if( is != null )
if( !is.isEmpty() )
{
this.postChange( input[x], this.machineSrc );
ic.setInventorySlotContents( x, is );
@@ -735,7 +735,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
final ItemStack is = ic.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc );
}
@@ -764,7 +764,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
final ItemStack output = Platform.getContainerItem( ic.getStackInSlot( x ) );
if( output != null )
if( !output.isEmpty() )
{
final IAEItemStack cItem = AEItemStack.create( output );
this.postChange( cItem, this.machineSrc );
@@ -797,7 +797,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
final ItemStack is = ic.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc );
}
@@ -62,7 +62,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
for( int x = 0; x < upgrades.getSizeInventory(); x++ )
{
final ItemStack is = upgrades.getStackInSlot( x );
if( is != null && is.getItem() instanceof IUpgradeModule )
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
{
final Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is );
if( u != null )
@@ -84,7 +84,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
for( int x = 0; x < config.getSizeInventory(); x++ )
{
final ItemStack is = config.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
priorityList.add( AEItemStack.create( is ) );
}
@@ -43,7 +43,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
final CellConfig cc = new CellConfig( o );
for( final ItemStack is : cc )
{
if( is != null )
if( !is.isEmpty() )
{
final IAEItemStack i = AEItemStack.create( is );
i.setStackSize( Integer.MAX_VALUE );
@@ -75,7 +75,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
{
ItemStack out = null;
ItemStack out = ItemStack.EMPTY;
if( type == Actionable.SIMULATE )
{
@@ -91,7 +91,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
this.onTick();
}
if( out == null )
if( out.isEmpty() )
{
return null;
}
@@ -105,7 +105,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src )
{
ItemStack out = null;
ItemStack out = ItemStack.EMPTY;
if( type == Actionable.SIMULATE )
{
@@ -116,7 +116,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null );
}
if( out == null )
if( out.isEmpty() )
{
return null;
}
@@ -154,7 +154,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
high = Math.max( high, is.getSlot() );
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
final ItemStack oldIS = old == null ? null : old.itemStack;
final ItemStack oldIS = old == null ? ItemStack.EMPTY : old.itemStack;
if( this.isDifferent( newIS, oldIS ) )
{
@@ -177,8 +177,8 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
}
else
{
final int newSize = ( newIS == null ? 0 : newIS.getCount() );
final int diff = newSize - ( oldIS == null ? 0 : oldIS.getCount() );
final int newSize = ( newIS.isEmpty() ? 0 : newIS.getCount() );
final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getCount() );
final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance().storage().createItemStack( newIS ) : old.aeStack.copy() );
if( stack != null )
@@ -227,12 +227,12 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
private boolean isDifferent( final ItemStack a, final ItemStack b )
{
if( a == b && b == null )
if( a == b && b.isEmpty() )
{
return false;
}
if( ( a == null && b != null ) || ( a != null && b == null ) )
if( ( a.isEmpty() && !b.isEmpty() ) || ( !a.isEmpty() && b.isEmpty() ) )
{
return true;
}
@@ -344,9 +344,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
public CachedItemStack( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
this.itemStack = null;
this.itemStack = ItemStack.EMPTY;
this.aeStack = null;
}
else