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
@@ -220,7 +220,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
{
for( final ItemStack is : options )
{
if( is != null && is.getItem() != null )
if( !is.isEmpty() && is.getItem() != null )
{
replacement = is.copy();
break;
@@ -301,7 +301,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" );
}
if( upgrades != null && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof IUpgradeModule )
if( upgrades != null && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof IUpgradeModule )
{
final IUpgradeModule um = (IUpgradeModule) player.getHeldItemMainhand().getItem();
final Upgrades u = um.getType( player.getHeldItemMainhand() );
@@ -362,7 +362,7 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
private String nameOf( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
return "null";
}
@@ -80,8 +80,8 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
final InventoryPlayer inv = player.inventory;
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( null );
if( is != null )
ItemStack is = AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.getCount() ).orElse( ItemStack.EMPTY );
if( !is.isEmpty() )
{
for( int s = 0; s < player.inventory.getSizeInventory(); s++ )
{
@@ -237,11 +237,11 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
final IItemList<IAEItemStack> list = inv.getAvailableItems( StorageChannel.ITEMS.createList() );
if( list.isEmpty() && ia != null )
{
playerInventory.setInventorySlotContents( playerInventory.currentItem, null );
playerInventory.setInventorySlotContents( playerInventory.currentItem, ItemStack.EMPTY );
// drop core
final ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
if( extraB != null )
if( !extraB.isEmpty() )
{
player.dropItem( extraB, false );
}
@@ -252,7 +252,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
{
final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex );
final ItemStack leftStack = ia.addItems( upgradeStack );
if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule )
if( !leftStack.isEmpty() && upgradeStack.getItem() instanceof IUpgradeModule )
{
player.dropItem( upgradeStack, false );
}
@@ -262,7 +262,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
{
final ItemStack extraA = ia.addItems( is );
if( extraA != null )
if( !extraA.isEmpty() )
{
player.dropItem( extraA, false );
}
@@ -75,7 +75,7 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
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 )
@@ -97,7 +97,7 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
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 ) );
}