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
@@ -36,7 +36,7 @@ public class IMCBlackListSpatial implements IIMCProcessor
{
final ItemStack is = m.getItemStackValue();
if( is != null )
if( !is.isEmpty() )
{
final Block blk = Block.getBlockFromItem( is.getItem() );
if( blk != null )
@@ -54,7 +54,7 @@ public class IMCP2PAttunement implements IIMCProcessor
if( type != null )
{
final ItemStack is = m.getItemStackValue();
if( is != null )
if( !is.isEmpty() )
{
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
}
@@ -92,7 +92,7 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition
{
final ItemStackSrc is = this.colors[color.ordinal()];
if( comparableItem == null || is == null )
if( comparableItem.isEmpty() || is == null )
{
return false;
}
@@ -53,7 +53,7 @@ public class CellRegistry implements ICellRegistry
@Override
public boolean isCellHandled( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
return false;
}
@@ -70,7 +70,7 @@ public class CellRegistry implements ICellRegistry
@Override
public ICellHandler getHandler( final ItemStack is )
{
if( is == null )
if( is.isEmpty() )
{
return null;
}
@@ -87,7 +87,7 @@ public class CellRegistry implements ICellRegistry
@Override
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final StorageChannel chan )
{
if( is == null )
if( is.isEmpty() )
{
return null;
}
@@ -42,13 +42,13 @@ public class CreativeCellHandler implements ICellHandler
@Override
public boolean isCell( final ItemStack is )
{
return is != null && is.getItem() instanceof ItemCreativeStorageCell;
return !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell;
}
@Override
public IMEInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final StorageChannel channel )
{
if( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell )
if( channel == StorageChannel.ITEMS && !is.isEmpty() && is.getItem() instanceof ItemCreativeStorageCell )
{
return CreativeCellInventory.getCell( is );
}
@@ -229,7 +229,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene
private ItemStack copy( final ItemStack is )
{
if( is != null )
if( !is.isEmpty() )
{
return is.copy();
}
@@ -182,11 +182,11 @@ public final class InscriberRegistry implements IInscriberRegistry
{
throw new IllegalStateException( "Input must have a size." );
}
if( this.output == null )
if( this.output.isEmpty() )
{
throw new IllegalStateException( "Output must be defined." );
}
if( this.topOptional == null && this.bottomOptional == null )
if( this.topOptional.isEmpty() && this.bottomOptional.isEmpty() )
{
throw new IllegalStateException( "One optional must be defined." );
}
@@ -124,7 +124,7 @@ public enum Achievements
Achievements( final int x, final int y, final IItemDefinition which, final AchievementType type )
{
this.stack = which.maybeStack( 1 ).orElse( null );
this.stack = which.maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.type = type;
this.x = x;
this.y = y;
@@ -255,7 +255,7 @@ public enum GuiBridge implements IGuiHandler
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
if( ID.type.isItem() )
{
ItemStack it = null;
ItemStack it = ItemStack.EMPTY;
if( stem )
{
it = player.inventory.getCurrentItem();
@@ -295,7 +295,7 @@ public enum GuiBridge implements IGuiHandler
private Object getGuiObject( final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z )
{
if( it != null )
if( !it.isEmpty() )
{
if( it.getItem() instanceof IGuiItem )
{
@@ -437,7 +437,7 @@ public enum GuiBridge implements IGuiHandler
final boolean stem = ( ( ordinal >> 3 ) & 1 ) == 1;
if( ID.type.isItem() )
{
ItemStack it = null;
ItemStack it = ItemStack.EMPTY;
if( stem )
{
it = player.inventory.getCurrentItem();
@@ -510,7 +510,7 @@ public enum GuiBridge implements IGuiHandler
if( this.type.isItem() )
{
final ItemStack it = player.inventory.getCurrentItem();
if( it != null && it.getItem() instanceof IGuiItem )
if( !it.isEmpty() && it.getItem() instanceof IGuiItem )
{
final Object myItem = ( (IGuiItem) it.getItem() ).getGuiObject( it, w, pos );
if( this.CorrectTileOrPart( myItem ) )
@@ -106,7 +106,7 @@ public class PacketClick extends AppEngPacket
final IComparableDefinition maybeMemoryCard = items.memoryCard();
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
if( is != null )
if( !is.isEmpty() )
{
if( is.getItem() instanceof ToolNetworkTool )
{
@@ -167,7 +167,7 @@ public class PacketInventoryAction extends AppEngPacket
{
if( this.slotItem == null )
{
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( null );
AppEng.proxy.getPlayers().get( 0 ).inventory.setItemStack( ItemStack.EMPTY );
}
else
{
@@ -150,7 +150,7 @@ public class PacketJEIRecipe extends AppEngPacket
{
final ItemStack is = r.getCraftingResult( testInv );
if( is != null )
if( !is.isEmpty() )
{
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
final IItemList all = storage.getStorageList();
@@ -161,13 +161,13 @@ public class PacketJEIRecipe extends AppEngPacket
final ItemStack patternItem = testInv.getStackInSlot( x );
ItemStack currentItem = craftMatrix.getStackInSlot( x );
if( currentItem != null )
if( !currentItem.isEmpty() )
{
testInv.setInventorySlotContents( x, currentItem );
final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : null;
final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : ItemStack.EMPTY;
testInv.setInventorySlotContents( x, patternItem );
if( newItemStack == null || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
if( newItemStack.isEmpty() || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
{
final IAEItemStack in = AEItemStack.create( currentItem );
if( in != null )
@@ -179,7 +179,7 @@ public class PacketJEIRecipe extends AppEngPacket
}
else
{
craftMatrix.setInventorySlotContents( x, null );
craftMatrix.setInventorySlotContents( x, ItemStack.EMPTY );
}
currentItem = craftMatrix.getStackInSlot( x );
@@ -188,14 +188,14 @@ public class PacketJEIRecipe extends AppEngPacket
}
// True if we need to fetch an item for the recipe
if( patternItem != null && currentItem == null )
if( !patternItem.isEmpty() && currentItem.isEmpty() )
{
// Grab from network by recipe
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getActionSource(), storage, player.world, r, is, testInv, patternItem, x, all, realForFake, filter );
// If that doesn't get it, grab exact items from network (?)
// TODO see if this code is necessary
if( whichItem == null )
if( whichItem.isEmpty() )
{
for( int y = 0; y < this.recipe[x].length; y++ )
{
@@ -217,7 +217,7 @@ public class PacketJEIRecipe extends AppEngPacket
}
// If that doesn't work, grab from the player's inventory
if( whichItem == null && playerInventory != null )
if( whichItem.isEmpty() && playerInventory != null )
{
whichItem = this.extractItemFromPlayerInventory( player, realForFake, patternItem );
}