First batch of null -> isEmpty() checks.
I most likely still missed a ton of checks...
This commit is contained in:
@@ -210,7 +210,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
{
|
||||
inv.setInventorySlotContents( x, null );
|
||||
inv.setInventorySlotContents( x, ItemStack.EMPTY );
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
}
|
||||
else
|
||||
{
|
||||
inv.setInventorySlotContents( x, null );
|
||||
inv.setInventorySlotContents( x, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,11 +126,11 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
final boolean matchA = ( top == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( bot == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
||||
( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
|
||||
final boolean matchB = ( bot == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( null ) ) ) && // and...
|
||||
( top == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( null ) ) );
|
||||
final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot, recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
|
||||
( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
|
||||
|
||||
if( matchA || matchB )
|
||||
{
|
||||
@@ -151,9 +151,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||
}
|
||||
}
|
||||
|
||||
if( ( s == this.top && bot != null ) || ( s == this.bottom && top != null ) )
|
||||
if( ( s == this.top && !bot.isEmpty() ) || ( s == this.bottom && !top.isEmpty() ) )
|
||||
{
|
||||
ItemStack otherSlot = null;
|
||||
ItemStack otherSlot = ItemStack.EMPTY;
|
||||
if( s == this.top )
|
||||
{
|
||||
otherSlot = this.bottom.getStack();
|
||||
@@ -174,13 +174,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
|
||||
boolean isValid = false;
|
||||
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
|
||||
{
|
||||
if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( null ), otherSlot ) )
|
||||
if( Platform.itemComparisons().isSameItem( recipe.getTopOptional().orElse( ItemStack.EMPTY ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( null ) );
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getBottomOptional().orElse( ItemStack.EMPTY ) );
|
||||
}
|
||||
else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( null ), otherSlot ) )
|
||||
else if( Platform.itemComparisons().isSameItem( recipe.getBottomOptional().orElse( ItemStack.EMPTY ), otherSlot ) )
|
||||
{
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( null ) );
|
||||
isValid = Platform.itemComparisons().isSameItem( is, recipe.getTopOptional().orElse( ItemStack.EMPTY ) );
|
||||
}
|
||||
|
||||
if( isValid )
|
||||
|
||||
@@ -204,7 +204,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
if( inv != null )
|
||||
{
|
||||
final ItemStack is = inv.server.getStackInSlot( slot );
|
||||
final boolean hasItemInHand = player.inventory.getItemStack() != null;
|
||||
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorPlayerHand( player );
|
||||
|
||||
@@ -220,7 +220,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
if( hasItemInHand )
|
||||
{
|
||||
ItemStack inSlot = theSlot.getStackInSlot( 0 );
|
||||
if( inSlot == null )
|
||||
if( inSlot.isEmpty() )
|
||||
{
|
||||
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
|
||||
}
|
||||
@@ -229,12 +229,12 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getItemStack().copy();
|
||||
|
||||
theSlot.setInventorySlotContents( 0, null );
|
||||
player.inventory.setItemStack( null );
|
||||
theSlot.setInventorySlotContents( 0, ItemStack.EMPTY );
|
||||
player.inventory.setItemStack( ItemStack.EMPTY );
|
||||
|
||||
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
|
||||
|
||||
if( player.inventory.getItemStack() == null )
|
||||
if( player.inventory.getItemStack().isEmpty() )
|
||||
{
|
||||
player.inventory.setItemStack( inSlot );
|
||||
}
|
||||
@@ -256,24 +256,24 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
|
||||
if( hasItemInHand )
|
||||
{
|
||||
ItemStack extra = playerHand.removeItems( 1, null, null );
|
||||
if( extra != null )
|
||||
ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
extra = interfaceSlot.addItems( extra );
|
||||
}
|
||||
if( extra != null )
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
playerHand.addItems( extra );
|
||||
}
|
||||
}
|
||||
else if( is != null )
|
||||
else if( !is.isEmpty() )
|
||||
{
|
||||
ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, null, null );
|
||||
if( extra != null )
|
||||
ItemStack extra = interfaceSlot.removeItems( ( is.getCount() + 1 ) / 2, ItemStack.EMPTY, null );
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
extra = playerHand.addItems( extra );
|
||||
}
|
||||
if( extra != null )
|
||||
if( !extra.isEmpty() )
|
||||
{
|
||||
interfaceSlot.addItems( extra );
|
||||
}
|
||||
@@ -300,7 +300,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
|
||||
if( player.capabilities.isCreativeMode && !hasItemInHand )
|
||||
{
|
||||
player.inventory.setItemStack( is == null ? null : is.copy() );
|
||||
player.inventory.setItemStack( is.isEmpty() ? ItemStack.EMPTY : is.copy() );
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -357,12 +357,12 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
|
||||
private boolean isDifferent( final ItemStack a, final ItemStack b )
|
||||
{
|
||||
if( a == null && b == null )
|
||||
if( a.isEmpty() && b.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( a == null || b == null )
|
||||
if( a.isEmpty() || b.isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -388,9 +388,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
final ItemStack is = inv.server.getStackInSlot( x + offset );
|
||||
|
||||
// "update" client side.
|
||||
inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() );
|
||||
inv.client.setInventorySlotContents( x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() );
|
||||
|
||||
if( is != null )
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
is.writeToNBT( itemNBT );
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
|
||||
final IInventory mac = this.getUpgradeable().getInventoryByName( "mac" );
|
||||
|
||||
final ItemStack is = mac.getStackInSlot( 10 );
|
||||
if( is == null )
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||
{
|
||||
if( currentItem != this.civ.getItemStack() )
|
||||
{
|
||||
if( currentItem != null )
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( this.civ.getItemStack(), currentItem ) )
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ public class ContainerNetworkStatus extends AEBaseContainer
|
||||
{
|
||||
final IGridBlock blk = machine.getGridBlock();
|
||||
final ItemStack is = blk.getMachineRepresentation();
|
||||
if( is != null && is.getItem() != null )
|
||||
if( !is.isEmpty() && is.getItem() != null )
|
||||
{
|
||||
final IAEItemStack ais = AEItemStack.create( is );
|
||||
ais.setStackSize( 1 );
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ContainerNetworkTool extends AEBaseContainer
|
||||
|
||||
if( currentItem != this.toolInv.getItemStack() )
|
||||
{
|
||||
if( currentItem != null )
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( this.toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
|
||||
@@ -190,14 +190,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if( output != null && !this.isPattern( output ) )
|
||||
if( !output.isEmpty() && !this.isPattern( output ) )
|
||||
{
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if( output == null )
|
||||
else if( output.isEmpty() )
|
||||
{
|
||||
output = this.patternSlotIN.getStack();
|
||||
if( output == null || !this.isPattern( output ) )
|
||||
if( output.isEmpty() || !this.isPattern( output ) )
|
||||
{
|
||||
return; // no blanks.
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
output.setCount( output.getCount() );
|
||||
if( output.getCount() == 0 )
|
||||
{
|
||||
this.patternSlotIN.putStack( null );
|
||||
this.patternSlotIN.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
@@ -250,7 +250,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
for( int x = 0; x < this.craftingSlots.length; x++ )
|
||||
{
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if( input[x] != null )
|
||||
if( !input[x].isEmpty() )
|
||||
{
|
||||
hasValue = true;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
{
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
|
||||
if( out != null && out.getCount() > 0 )
|
||||
if( !out.isEmpty() && out.getCount() > 0 )
|
||||
{
|
||||
return new ItemStack[] { out };
|
||||
}
|
||||
@@ -284,7 +284,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
{
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if( out != null && out.getCount() > 0 )
|
||||
if( !out.isEmpty() && out.getCount() > 0 )
|
||||
{
|
||||
list.add( out );
|
||||
hasValue = true;
|
||||
@@ -302,7 +302,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
|
||||
private boolean isPattern( final ItemStack output )
|
||||
{
|
||||
if( output == null )
|
||||
if( output.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
inv = playerInv;
|
||||
}
|
||||
|
||||
if( inv.simulateAdd( out.getItemStack() ) != null )
|
||||
if( !inv.simulateAdd( out.getItemStack() ).isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -381,7 +381,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
|
||||
for( int x = 0; x < 9; x++ )
|
||||
{
|
||||
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() );
|
||||
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].getItemStack() );
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe( ic, p.world );
|
||||
@@ -398,7 +398,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
|
||||
for( int x = 0; x < ic.getSizeInventory(); x++ )
|
||||
{
|
||||
if( ic.getStackInSlot( x ) != null )
|
||||
if( !ic.getStackInSlot( x ).isEmpty() )
|
||||
{
|
||||
final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.world, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) );
|
||||
real.setInventorySlotContents( x, pulled );
|
||||
@@ -416,7 +416,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
{
|
||||
final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
|
||||
|
||||
if( failed != null )
|
||||
if( !failed.isEmpty() )
|
||||
{
|
||||
p.dropItem( failed, false );
|
||||
}
|
||||
@@ -434,7 +434,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
for( int x = 0; x < real.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack failed = real.getStackInSlot( x );
|
||||
if( failed != null )
|
||||
if( !failed.isEmpty() )
|
||||
{
|
||||
this.getCellInventory().injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.getPatternTerminal() ) );
|
||||
}
|
||||
@@ -498,12 +498,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
{
|
||||
for( final Slot s : this.craftingSlots )
|
||||
{
|
||||
s.putStack( null );
|
||||
s.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
for( final Slot s : this.outputSlots )
|
||||
{
|
||||
s.putStack( null );
|
||||
s.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
|
||||
compound.setString( "InscribeName", this.myName );
|
||||
|
||||
return namePressStack;
|
||||
} ).orElse( null );
|
||||
} ).orElse( ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
|
||||
public ItemStack decrStackSize( final int var1, final int var2 )
|
||||
{
|
||||
final ItemStack is = this.getStackInSlot( 0 );
|
||||
if( is != null )
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
if( this.makePlate() )
|
||||
{
|
||||
@@ -272,7 +272,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
this.inSlot.setInventorySlotContents( 0, null );
|
||||
this.inSlot.setInventorySlotContents( 0, ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
final SecurityPermissions permission = SecurityPermissions.valueOf( value );
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if( a != null && a.getItem() instanceof IBiometricCard )
|
||||
if( !a.isEmpty() && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if( bc.hasPermission( a, permission ) )
|
||||
@@ -102,7 +102,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
this.setPermissionMode( 0 );
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if( a != null && a.getItem() instanceof IBiometricCard )
|
||||
if( !a.isEmpty() && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
{
|
||||
networkEncodable.setEncryptionKey( term, String.valueOf( this.securityBox.getSecurityKey() ), "" );
|
||||
|
||||
this.wirelessIn.putStack( null );
|
||||
this.wirelessIn.putStack( ItemStack.EMPTY );
|
||||
this.wirelessOut.putStack( term );
|
||||
|
||||
// update the two slots in question...
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
|
||||
for( int x = 0; x < inv.getSizeInventory(); x++ )
|
||||
{
|
||||
inv.setInventorySlotContents( x, null );
|
||||
inv.setInventorySlotContents( x, ItemStack.EMPTY );
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
|
||||
}
|
||||
else
|
||||
{
|
||||
inv.setInventorySlotContents( x, null );
|
||||
inv.setInventorySlotContents( x, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
for( int x = 0; x < pi.getSizeInventory(); x++ )
|
||||
{
|
||||
final ItemStack pii = pi.getStackInSlot( x );
|
||||
if( pii != null && pii.getItem() instanceof ToolNetworkTool )
|
||||
if( !pii.isEmpty() && pii.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
this.lockPlayerInventorySlot( x );
|
||||
this.tbSlot = x;
|
||||
@@ -204,7 +204,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
if( o instanceof OptionalSlotFake )
|
||||
{
|
||||
final OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if( !fs.isEnabled() && fs.getDisplayStack() != null )
|
||||
if( !fs.isEnabled() && !fs.getDisplayStack().isEmpty() )
|
||||
{
|
||||
fs.clearStack();
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
||||
|
||||
if( currentItem != this.tbInventory.getItemStack() )
|
||||
{
|
||||
if( currentItem != null )
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
if( Platform.itemComparisons().isEqualItem( this.tbInventory.getItemStack(), currentItem ) )
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ContainerWireless extends AEBaseContainer
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
final int boosters = this.boosterSlot.getStack() == null ? 0 : this.boosterSlot.getStack().getCount();
|
||||
final int boosters = this.boosterSlot.getStack().isEmpty() ? 0 : this.boosterSlot.getStack().getCount();
|
||||
|
||||
this.setRange( (long) ( 10 * AEConfig.instance().wireless_getMaxRange( boosters ) ) );
|
||||
this.setDrain( (long) ( 100 * AEConfig.instance().wireless_getPowerDrain( boosters ) ) );
|
||||
|
||||
Reference in New Issue
Block a user