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
@@ -39,7 +39,7 @@ public class ItemCraftingStorage extends AEBaseItemBlock
@Override
public ItemStack getContainerItem( final ItemStack itemStack )
{
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( null );
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack( 1 ).orElse( ItemStack.EMPTY );
}
@Override
@@ -18,6 +18,7 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.property.IExtendedBlockState;
+10 -10
View File
@@ -92,7 +92,7 @@ public abstract class AEBaseGui extends GuiContainer
private GuiScrollbar myScrollBar = null;
private boolean disableShiftClick = false;
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
private ItemStack dbl_whichItem;
private ItemStack dbl_whichItem = ItemStack.EMPTY;
private Slot bl_clicked;
private boolean subGui;
@@ -304,7 +304,7 @@ public abstract class AEBaseGui extends GuiContainer
this.getScrollBar().click( this, x - this.guiLeft, y - this.guiTop );
}
if( slot instanceof SlotFake && itemstack != null )
if( slot instanceof SlotFake && !itemstack.isEmpty() )
{
this.drag_click.add( slot );
if( this.drag_click.size() > 1 )
@@ -453,7 +453,7 @@ public abstract class AEBaseGui extends GuiContainer
action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel())
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getShowCraftingLabel() )
{
action = InventoryAction.AUTO_CRAFT;
}
@@ -499,21 +499,21 @@ public abstract class AEBaseGui extends GuiContainer
{
this.disableShiftClick = true;
if( this.dbl_whichItem == null || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
if( this.dbl_whichItem.isEmpty() || this.bl_clicked != slot || this.dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
{
// some simple double click logic.
this.bl_clicked = slot;
this.dbl_clickTimer = Stopwatch.createStarted();
if( slot != null )
{
this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null;
this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
}
else
{
this.dbl_whichItem = null;
this.dbl_whichItem = ItemStack.EMPTY;
}
}
else if( this.dbl_whichItem != null )
else if( !this.dbl_whichItem.isEmpty() )
{
// a replica of the weird broken vanilla feature.
@@ -540,7 +540,7 @@ public abstract class AEBaseGui extends GuiContainer
{
final Slot theSlot = this.getSlotUnderMouse();
if( this.mc.player.inventory.getItemStack() == null && theSlot != null )
if( this.mc.player.inventory.getItemStack().isEmpty() && theSlot != null )
{
for( int j = 0; j < 9; ++j )
{
@@ -728,7 +728,7 @@ public abstract class AEBaseGui extends GuiContainer
try
{
final ItemStack is = s.getStack();
if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is == null ) && ( ( (AppEngSlot) s ).shouldDisplay() ) )
if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is.isEmpty() ) && ( ( (AppEngSlot) s ).shouldDisplay() ) )
{
final AppEngSlot aes = (AppEngSlot) s;
if( aes.getIcon() >= 0 )
@@ -776,7 +776,7 @@ public abstract class AEBaseGui extends GuiContainer
}
}
if( is != null && s instanceof AppEngSlot )
if( !is.isEmpty() && s instanceof AppEngSlot )
{
if( ( (AppEngSlot) s ).getIsValid() == hasCalculatedValidness.NotAvailable )
{
@@ -44,7 +44,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
public List<String> handleItemTooltip( final ItemStack stack, final int mouseX, final int mouseY, final List<String> currentToolTip )
{
if( stack != null )
if( !stack.isEmpty() )
{
final Slot s = this.getSlot( mouseX, mouseY );
if( s instanceof SlotME )
@@ -101,7 +101,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
protected void renderToolTip( final ItemStack stack, final int x, final int y )
{
final Slot s = this.getSlot( x, y );
if( s instanceof SlotME && stack != null )
if( s instanceof SlotME && !stack.isEmpty() )
{
final int BigNumber = AEConfig.instance().useTerminalUseLargeFont() ? 999 : 9999;
@@ -33,7 +33,7 @@ class Size1Slot extends Slot
public ItemStack getStack()
{
ItemStack orgStack = delegate.getStack();
if( orgStack != null )
if( !orgStack.isEmpty() )
{
ItemStack modifiedStack = orgStack.copy();
modifiedStack.setCount( 1 );
@@ -140,7 +140,7 @@ public class GuiCellWorkbench extends GuiUpgradeable
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
final ItemStack is = inv.getStackInSlot( x );
if( is != null && is.getItem() instanceof IUpgradeModule )
if( !is.isEmpty() && is.getItem() instanceof IUpgradeModule )
{
if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY )
{
@@ -107,23 +107,23 @@ public class GuiCraftAmount extends AEBaseGui
if( target instanceof PartTerminal )
{
myIcon = parts.terminal().maybeStack( 1 ).orElse( null );
myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_ME;
}
if( target instanceof PartCraftingTerminal )
{
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null );
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if( target instanceof PartPatternTerminal )
{
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null );
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if( this.originalGui != null && myIcon != null )
if( this.originalGui != null && !myIcon.isEmpty() )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) );
}
@@ -57,7 +57,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU
private GuiTabButton originalGuiBtn;
private GuiBridge originalGui;
private ItemStack myIcon = null;
private ItemStack myIcon = ItemStack.EMPTY;
public GuiCraftingStatus( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
@@ -70,28 +70,28 @@ public class GuiCraftingStatus extends GuiCraftingCPU
if( target instanceof WirelessTerminalGuiObject )
{
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( null );
myIcon = definitions.items().wirelessTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if( target instanceof PartTerminal )
{
myIcon = parts.terminal().maybeStack( 1 ).orElse( null );
myIcon = parts.terminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_ME;
}
if( target instanceof PartCraftingTerminal )
{
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( null );
myIcon = parts.craftingTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if( target instanceof PartPatternTerminal )
{
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( null );
myIcon = parts.patternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY );
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
@@ -131,7 +131,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU
// selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
if( this.myIcon != null )
if( !this.myIcon.isEmpty() )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), this.itemRender ) );
this.originalGuiBtn.setHideEdge( 13 );
+1 -1
View File
@@ -84,7 +84,7 @@ public class ItemRepo
if( idx >= this.dsp.size() )
{
return null;
return ItemStack.EMPTY;
}
return this.dsp.get( idx );
}
@@ -63,11 +63,11 @@ public class SlotDisconnected extends AppEngSlot
if( Platform.isClient() )
{
final ItemStack is = super.getStack();
if( is != null && is.getItem() instanceof ItemEncodedPattern )
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern )
{
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
final ItemStack out = iep.getOutput( is );
if( out != null )
if( !out.isEmpty() )
{
return out;
}
+3 -3
View File
@@ -60,7 +60,7 @@ public class SlotME extends Slot
{
return this.mySlot.getStack();
}
return null;
return ItemStack.EMPTY;
}
@Override
@@ -68,7 +68,7 @@ public class SlotME extends Slot
{
if( this.mySlot.hasPower() )
{
return this.getStack() != null;
return !this.getStack().isEmpty();
}
return false;
}
@@ -88,7 +88,7 @@ public class SlotME extends Slot
@Override
public ItemStack decrStackSize( final int par1 )
{
return null;
return ItemStack.EMPTY;
}
@Override
@@ -44,7 +44,7 @@ public class StackSizeRenderer
public void renderStackSize( FontRenderer fontRenderer, IAEItemStack aeStack, ItemStack is, int xPos, int yPos )
{
if( is != null )
if( !is.isEmpty() )
{
final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
@@ -132,15 +132,15 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
int items = 0;
if( tile.getStackInSlot( 0 ) != null )
if( !tile.getStackInSlot( 0 ).isEmpty() )
{
items++;
}
if( tile.getStackInSlot( 1 ) != null )
if( !tile.getStackInSlot( 1 ).isEmpty() )
{
items++;
}
if( tile.getStackInSlot( 2 ) != null )
if( !tile.getStackInSlot( 2 ).isEmpty() )
{
items++;
}
@@ -151,7 +151,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
{
ItemStack is = tile.getStackInSlot( 3 );
if( is == null )
if( is.isEmpty() )
{
final IInscriberRecipe ir = tile.getTask();
if( ir != null )
@@ -177,7 +177,7 @@ public class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
private void renderItem( ItemStack sis, final float o, final AEBaseTile tile, final VertexBuffer tess, final double x, final double y, final double z )
{
if( sis != null )
if( !sis.isEmpty() )
{
sis = sis.copy();
@@ -224,8 +224,8 @@ public abstract class AEBaseContainer extends Container
// client doesn't need to re-send, makes for lower overhead rapid packets.
if( Platform.isClient() )
{
final ItemStack a = stack == null ? null : stack.getItemStack();
final ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack();
final ItemStack a = stack == null ? ItemStack.EMPTY : stack.getItemStack();
final ItemStack b = this.clientRequestedTargetItem == null ? ItemStack.EMPTY : this.clientRequestedTargetItem.getItemStack();
if( Platform.itemComparisons().isSameItem( a, b ) )
{
@@ -483,7 +483,7 @@ public abstract class AEBaseContainer extends Container
{
ItemStack tis = clickSlot.getStack();
if( tis == null )
if( tis.isEmpty() )
{
return ItemStack.EMPTY;
}
@@ -533,7 +533,7 @@ public abstract class AEBaseContainer extends Container
*/
if( selectedSlots.isEmpty() && clickSlot.isPlayerSide() )
{
if( tis != null )
if( !tis.isEmpty() )
{
// target slots in the container...
for( final Object inventorySlot : this.inventorySlots )
@@ -547,7 +547,7 @@ public abstract class AEBaseContainer extends Container
{
break;
}
else if( destination == null )
else if( destination.isEmpty() )
{
cs.putStack( tis.copy() );
cs.onSlotChanged();
@@ -559,7 +559,7 @@ public abstract class AEBaseContainer extends Container
}
}
if( tis != null )
if( !tis.isEmpty() )
{
// find partials..
for( final Slot d : selectedSlots )
@@ -595,7 +595,7 @@ public abstract class AEBaseContainer extends Container
if( tis.getCount() <= 0 )
{
clickSlot.putStack( null );
clickSlot.putStack( ItemStack.EMPTY );
d.onSlotChanged();
// if ( hasMETiles ) updateClient();
@@ -647,7 +647,7 @@ public abstract class AEBaseContainer extends Container
if( tis.getCount() <= 0 )
{
clickSlot.putStack( null );
clickSlot.putStack( ItemStack.EMPTY );
d.onSlotChanged();
// if ( worldEntity != null )
@@ -683,7 +683,7 @@ public abstract class AEBaseContainer extends Container
if( tis.getCount() <= 0 )
{
clickSlot.putStack( null );
clickSlot.putStack( ItemStack.EMPTY );
d.onSlotChanged();
// if ( worldEntity != null )
@@ -703,7 +703,7 @@ public abstract class AEBaseContainer extends Container
}
}
clickSlot.putStack( tis != null ? tis.copy() : null );
clickSlot.putStack( !tis.isEmpty() ? tis.copy() : ItemStack.EMPTY );
}
this.updateSlot( clickSlot );
@@ -766,9 +766,9 @@ public abstract class AEBaseContainer extends Container
{
case PICKUP_OR_SET_DOWN:
if( hand == null )
if( hand.isEmpty() )
{
s.putStack( null );
s.putStack( ItemStack.EMPTY );
}
else
{
@@ -778,7 +778,7 @@ public abstract class AEBaseContainer extends Container
break;
case PLACE_SINGLE:
if( hand != null )
if( !hand.isEmpty() )
{
final ItemStack is = hand.copy();
is.setCount( 1 );
@@ -789,9 +789,9 @@ public abstract class AEBaseContainer extends Container
case SPLIT_OR_PLACE_SINGLE:
ItemStack is = s.getStack();
if( is != null )
if( !is.isEmpty() )
{
if( hand == null )
if( hand.isEmpty() )
{
is.setCount( Math.max( 1, is.getCount() - 1 ) );
}
@@ -807,7 +807,7 @@ public abstract class AEBaseContainer extends Container
s.putStack( is );
}
else if( hand != null )
else if( !hand.isEmpty() )
{
is = hand.copy();
is.setCount( 1 );
@@ -866,7 +866,7 @@ public abstract class AEBaseContainer extends Container
myItem.setCount( (int) ais.getStackSize() );
myItem = adp.simulateAdd( myItem );
if( myItem != null )
if( !myItem.isEmpty() )
{
ais.setStackSize( ais.getStackSize() - myItem.getCount() );
}
@@ -887,7 +887,7 @@ public abstract class AEBaseContainer extends Container
final int releaseQty = 1;
final ItemStack isg = player.inventory.getItemStack();
if( isg != null && releaseQty > 0 )
if( !isg.isEmpty() && releaseQty > 0 )
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( isg );
ais.setStackSize( 1 );
@@ -899,7 +899,7 @@ public abstract class AEBaseContainer extends Container
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
final ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
if( fail == null )
if( fail.isEmpty() )
{
this.getCellInventory().extractItems( extracted, Actionable.MODULATE, this.getActionSource() );
}
@@ -921,7 +921,7 @@ public abstract class AEBaseContainer extends Container
int liftQty = 1;
final ItemStack item = player.inventory.getItemStack();
if( item != null )
if( !item.isEmpty() )
{
if( item.getCount() >= item.getMaxStackSize() )
{
@@ -943,7 +943,7 @@ public abstract class AEBaseContainer extends Container
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
final ItemStack fail = ia.addItems( ais.getItemStack() );
if( fail != null )
if( !fail.isEmpty() )
{
this.getCellInventory().injectItems( ais, Actionable.MODULATE, this.getActionSource() );
}
@@ -959,7 +959,7 @@ public abstract class AEBaseContainer extends Container
return;
}
if( player.inventory.getItemStack() == null )
if( player.inventory.getItemStack().isEmpty() )
{
if( slotItem != null )
{
@@ -972,7 +972,7 @@ public abstract class AEBaseContainer extends Container
}
else
{
player.inventory.setItemStack( null );
player.inventory.setItemStack( ItemStack.EMPTY );
}
this.updateHeld( player );
}
@@ -987,7 +987,7 @@ public abstract class AEBaseContainer extends Container
}
else
{
player.inventory.setItemStack( null );
player.inventory.setItemStack( ItemStack.EMPTY );
}
this.updateHeld( player );
}
@@ -999,7 +999,7 @@ public abstract class AEBaseContainer extends Container
return;
}
if( player.inventory.getItemStack() == null )
if( player.inventory.getItemStack().isEmpty() )
{
if( slotItem != null )
{
@@ -1021,7 +1021,7 @@ public abstract class AEBaseContainer extends Container
}
else
{
player.inventory.setItemStack( null );
player.inventory.setItemStack( ItemStack.EMPTY );
}
this.updateHeld( player );
}
@@ -1037,7 +1037,7 @@ public abstract class AEBaseContainer extends Container
is.setCount( is.getCount() - 1 );
if( is.getCount() <= 0 )
{
player.inventory.setItemStack( null );
player.inventory.setItemStack( ItemStack.EMPTY );
}
this.updateHeld( player );
}
@@ -1074,7 +1074,7 @@ public abstract class AEBaseContainer extends Container
myItem.setCount( (int) ais.getStackSize() );
myItem = adp.simulateAdd( myItem );
if( myItem != null )
if( !myItem.isEmpty() )
{
ais.setStackSize( ais.getStackSize() - myItem.getCount() );
}
@@ -1123,7 +1123,7 @@ public abstract class AEBaseContainer extends Container
this.getActionSource() );
if( ais == null )
{
return null;
return ItemStack.EMPTY;
}
return ais.getItemStack();
}
@@ -1202,42 +1202,42 @@ public abstract class AEBaseContainer extends Container
final ItemStack isB = b.getStack();
// something to do?
if( isA == null && isB == null )
if( isA.isEmpty() && isB.isEmpty() )
{
return;
}
// can take?
if( isA != null && !a.canTakeStack( this.getInventoryPlayer().player ) )
if( !isA.isEmpty() && !a.canTakeStack( this.getInventoryPlayer().player ) )
{
return;
}
if( isB != null && !b.canTakeStack( this.getInventoryPlayer().player ) )
if( !isB.isEmpty() && !b.canTakeStack( this.getInventoryPlayer().player ) )
{
return;
}
// swap valid?
if( isB != null && !a.isItemValid( isB ) )
if( !isB.isEmpty() && !a.isItemValid( isB ) )
{
return;
}
if( isA != null && !b.isItemValid( isA ) )
if( !isA.isEmpty() && !b.isItemValid( isA ) )
{
return;
}
ItemStack testA = isB == null ? null : isB.copy();
ItemStack testB = isA == null ? null : isA.copy();
ItemStack testA = isB.isEmpty() ? ItemStack.EMPTY : isB.copy();
ItemStack testB = isA.isEmpty() ? ItemStack.EMPTY : isA.copy();
// can put some back?
if( testA != null && testA.getCount() > a.getSlotStackLimit() )
if( !testA.isEmpty() && testA.getCount() > a.getSlotStackLimit() )
{
if( testB != null )
if( !testB.isEmpty() )
{
return;
}
@@ -1249,9 +1249,9 @@ public abstract class AEBaseContainer extends Container
testB.setCount( totalA - testA.getCount() );
}
if( testB != null && testB.getCount() > b.getSlotStackLimit() )
if( !testB.isEmpty() && testB.getCount() > b.getSlotStackLimit() )
{
if( testA != null )
if ( !testA.isEmpty() )
{
return;
}
@@ -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 ) ) );
@@ -167,14 +167,14 @@ public class AppEngCraftingSlot extends AppEngSlot
final ItemStack itemstack1 = this.craftMatrix.getStackInSlot( i );
final ItemStack itemstack2 = aitemstack.get( i );
if( itemstack1 != null )
if( !itemstack1.isEmpty() )
{
this.craftMatrix.decrStackSize( i, 1 );
}
if( itemstack2 != null )
if( !itemstack2.isEmpty() )
{
if( this.craftMatrix.getStackInSlot( i ) == null )
if( this.craftMatrix.getStackInSlot( i ).isEmpty() )
{
this.craftMatrix.setInventorySlotContents( i, itemstack2 );
}
@@ -67,7 +67,7 @@ public class AppEngSlot extends Slot
public void clearStack()
{
super.putStack( null );
super.putStack( ItemStack.EMPTY );
}
@Override
@@ -46,7 +46,7 @@ public class OptionalSlotFake extends SlotFake
{
if( !this.isEnabled() )
{
if( this.getDisplayStack() != null )
if( !this.getDisplayStack().isEmpty() )
{
this.clearStack();
}
@@ -34,7 +34,7 @@ public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
@Override
public void putStack( ItemStack is )
{
if( is != null )
if( !is.isEmpty() )
{
is = is.copy();
if( is.getCount() > 1 )
@@ -89,7 +89,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
public void doClick( final InventoryAction action, final EntityPlayer who )
{
if( this.getStack() == null )
if( this.getStack().isEmpty() )
{
return;
}
@@ -128,18 +128,18 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
}
final ItemStack rs = Platform.cloneItemStack( this.getStack() );
if( rs == null )
if( rs.isEmpty() )
{
return;
}
for( int x = 0; x < maxTimesToCraft; x++ )
{
if( ia.simulateAdd( rs ) == null )
if( ia.simulateAdd( rs ).isEmpty() )
{
final IItemList<IAEItemStack> all = inv.getStorageList();
final ItemStack extra = ia.addItems( this.craftItem( who, rs, inv, all ) );
if( extra != null )
if( !extra.isEmpty() )
{
final List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add( extra );
@@ -160,7 +160,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
// update crafting matrix...
ItemStack is = this.getStack();
if( is != null && Platform.itemComparisons().isEqualItem( request, is ) )
if( !is.isEmpty() && Platform.itemComparisons().isEqualItem( request, is ) )
{
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
// Safeguard for empty slots in the inventory for now
@@ -186,7 +186,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
final ItemStack pis = ic.getStackInSlot( x );
if( pis == null )
if( pis.isEmpty() )
{
continue;
}
@@ -212,7 +212,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
{
for( int x = 0; x < this.getPattern().getSizeInventory(); x++ )
{
if( this.getPattern().getStackInSlot( x ) != null )
if( !this.getPattern().getStackInSlot( x ).isEmpty() )
{
set[x] = Platform.extractItemsByRecipe( this.energySrc, this.mySrc, inv, p.world, r, is, ic, this.getPattern().getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.container.getViewCells() ) );
ic.setInventorySlotContents( x, set[x] );
@@ -257,11 +257,11 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
// set new items onto the crafting table...
for( int x = 0; x < this.craftInv.getSizeInventory(); x++ )
{
if( this.craftInv.getStackInSlot( x ) == null )
if( this.craftInv.getStackInSlot( x ).isEmpty() )
{
this.craftInv.setInventorySlotContents( x, set[x] );
}
else if( set[x] != null )
else if( !set[x].isEmpty() )
{
// eek! put it back!
final IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc );
@@ -53,7 +53,7 @@ public class SlotFake extends AppEngSlot
@Override
public void putStack( ItemStack is )
{
if( is != null )
if( !is.isEmpty() )
{
is = is.copy();
}
@@ -34,7 +34,7 @@ public class SlotFakeTypeOnly extends SlotFake
@Override
public void putStack( ItemStack is )
{
if( is != null )
if( !is.isEmpty() )
{
is = is.copy();
if( is.getCount() > 1 )
@@ -27,7 +27,7 @@ import net.minecraft.item.ItemStack;
public class SlotInaccessible extends AppEngSlot
{
private ItemStack dspStack = null;
private ItemStack dspStack = ItemStack.EMPTY;
public SlotInaccessible( final IInventory i, final int slotIdx, final int x, final int y )
{
@@ -44,7 +44,7 @@ public class SlotInaccessible extends AppEngSlot
public void onSlotChanged()
{
super.onSlotChanged();
this.dspStack = null;
this.dspStack = ItemStack.EMPTY;
}
@Override
@@ -56,10 +56,10 @@ public class SlotInaccessible extends AppEngSlot
@Override
public ItemStack getDisplayStack()
{
if( this.dspStack == null )
if( this.dspStack.isEmpty() )
{
final ItemStack dsp = super.getDisplayStack();
if( dsp != null )
if( !dsp.isEmpty() )
{
this.dspStack = dsp.copy();
}
@@ -101,7 +101,7 @@ public class SlotRestrictedInput extends AppEngSlot
return false;
}
if( i == null )
if( i.isEmpty() )
{
return false;
}
@@ -243,11 +243,11 @@ public class SlotRestrictedInput extends AppEngSlot
if( Platform.isClient() && ( this.which == PlacableItemType.ENCODED_PATTERN ) )
{
final ItemStack is = super.getStack();
if( is != null && is.getItem() instanceof ItemEncodedPattern )
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern )
{
final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
final ItemStack out = iep.getOutput( is );
if( out != null )
if( !out.isEmpty() )
{
return out;
}
@@ -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 );
}
@@ -73,7 +73,7 @@ public class CraftingTreeProcess
final IAEItemStack[] is = details.getInputs();
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, is[x] == null ? null : is[x].getItemStack() );
ic.setInventorySlotContents( x, is[x] == null ? ItemStack.EMPTY : is[x].getItemStack() );
}
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic );
@@ -81,7 +81,7 @@ public class CraftingTreeProcess
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
final ItemStack g = ic.getStackInSlot( x );
if( g != null && g.getCount() > 1 )
if( !g.isEmpty() && g.getCount() > 1 )
{
this.fullSimulation = true;
}
@@ -94,7 +94,7 @@ public class CraftingTreeProcess
boolean isAnInput = false;
for( final IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
if( !g.isEmpty() && a != null && a.equals( g ) )
{
isAnInput = true;
}
@@ -151,7 +151,7 @@ public class CraftingTreeProcess
boolean isAnInput = false;
for( final IAEItemStack a : details.getCondensedOutputs() )
{
if( g != null && a != null && a.equals( g ) )
if( !g.isEmpty() && a != null && a.equals( g ) )
{
isAnInput = true;
}
@@ -37,14 +37,14 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable
{
private int size = 3;
private ItemStack is = null;
private ItemStack is = ItemStack.EMPTY;
private int countdown = 20 * 10;
private EntityPlayer who = null;
@Override
public void update()
{
if( this.is != null && Platform.isServer() )
if( !this.is.isEmpty() && Platform.isServer() )
{
this.countdown--;
@@ -92,9 +92,9 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable
final ItemStack hand = player.inventory.getCurrentItem();
this.who = player;
if( hand == null )
if( hand.isEmpty() )
{
this.is = null;
this.is = ItemStack.EMPTY;
if( player.isSneaking() )
{
+5 -1
View File
@@ -23,6 +23,7 @@ import java.util.LinkedList;
import java.util.Queue;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -78,7 +79,10 @@ public class TileItemGen extends AEBaseTile implements IInventory
private ItemStack getRandomItem()
{
return POSSIBLE_ITEMS.peek();
// Safeguard for crash
ItemStack testStack = POSSIBLE_ITEMS.peek();
if( testStack.isEmpty() ) testStack = new ItemStack(Blocks.COBBLESTONE, 1);
return testStack;
}
@Override
@@ -64,7 +64,7 @@ public class BlockSkyStone extends AEBaseBlock
final ItemStack is = event.getEntityPlayer().getItemStackFromSlot( EntityEquipmentSlot.MAINHAND );
int level = -1;
if( is != null && is.getItem() != null )
if( !is.isEmpty() && is.getItem() != null )
{
level = is.getItem().getHarvestLevel( is, "pickaxe", event.getEntityPlayer(), event.getState() );
}
@@ -165,7 +165,7 @@ public class FacadeContainer implements IFacadeContainer
if( t != null )
{
final ItemStack is = new ItemStack( t );
if( is != null )
if( !is.isEmpty() )
{
final Item i = is.getItem();
if( i instanceof IFacadeItem )
+2 -2
View File
@@ -88,7 +88,7 @@ public class FacadePart implements IFacadePart, IBoxProvider
public Item getItem()
{
final ItemStack is = this.getTextureItem();
if( is == null )
if( is.isEmpty() )
{
return null;
}
@@ -99,7 +99,7 @@ public class FacadePart implements IFacadePart, IBoxProvider
public int getItemDamage()
{
final ItemStack is = this.getTextureItem();
if( is == null )
if( is.isEmpty() )
{
return 0;
}
@@ -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;
}
@@ -83,7 +83,7 @@ public class MultiCraftingTracker
public boolean handleCrafting( final int x, final long itemToCraft, final IAEItemStack ais, final InventoryAdaptor d, final World w, final IGrid g, final ICraftingGrid cg, final BaseActionSource mySrc )
{
if( ais != null && d.simulateAdd( ais.getItemStack() ) == null )
if( ais != null && d.simulateAdd( ais.getItemStack() ).isEmpty() )
{
final Future<ICraftingJob> craftingJob = this.getJob( x );
@@ -65,17 +65,17 @@ class FacadeRecipeWrapper extends BlankRecipeWrapper implements IShapedCraftingR
{
List<ItemStack> input = new ArrayList<>( 9 );
input.add( null );
input.add( ItemStack.EMPTY );
input.add( cableAnchor );
input.add( null );
input.add( ItemStack.EMPTY );
input.add( cableAnchor );
input.add( textureItem );
input.add( cableAnchor );
input.add( null );
input.add( ItemStack.EMPTY );
input.add( cableAnchor );
input.add( null );
input.add( ItemStack.EMPTY );
ingredients.setInputs( ItemStack.class, input );
ingredients.setOutput( ItemStack.class, facade );
@@ -45,9 +45,9 @@ class InscriberRecipeWrapper extends BlankRecipeWrapper
public void getIngredients( IIngredients ingredients )
{
List<List<ItemStack>> inputSlots = new ArrayList<>( 3 );
inputSlots.add( Collections.singletonList( recipe.getTopOptional().orElse( null ) ) );
inputSlots.add( Collections.singletonList( recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) );
inputSlots.add( recipe.getInputs() );
inputSlots.add( Collections.singletonList( recipe.getBottomOptional().orElse( null ) ) );
inputSlots.add( Collections.singletonList( recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
ingredients.setInputLists( ItemStack.class, inputSlots );
ingredients.setOutput( ItemStack.class, recipe.getOutput() );
@@ -126,7 +126,7 @@ public class JEIPlugin extends BlankModPlugin
private void registerGrinderRecipes( IDefinitions definitions, IModRegistry registry )
{
ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( null );
ItemStack grindstone = definitions.blocks().grindstone().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( grindstone == null )
{
@@ -142,19 +142,19 @@ public class JEIPlugin extends BlankModPlugin
private void registerCondenserRecipes( IDefinitions definitions, IModRegistry registry )
{
ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( null );
ItemStack condenser = definitions.blocks().condenser().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( condenser == null )
{
return;
}
ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( null );
ItemStack matterBall = definitions.materials().matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( matterBall != null )
{
registry.addRecipes( ImmutableList.of( CondenserOutput.MATTER_BALLS ) );
}
ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( null );
ItemStack singularity = definitions.materials().singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY );
if( singularity != null )
{
registry.addRecipes( ImmutableList.of( CondenserOutput.SINGULARITY ) );
@@ -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 ) );
}
@@ -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
@@ -1052,12 +1052,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
IPart p = this.getPart( side );
final ItemStack iss = new ItemStack( def );
if( iss == null )
if( iss.isEmpty() )
{
continue;
}
final ItemStack current = p == null ? null : p.getItemStack( PartItemStack.WORLD );
final ItemStack current = p == null ? ItemStack.EMPTY : p.getItemStack( PartItemStack.WORLD );
if( Platform.itemComparisons().isEqualItemType( iss, current ) )
{
@@ -88,7 +88,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
@Override
public boolean canInsert( final ItemStack stack )
{
if( stack == null || stack.getItem() == null )
if( stack.isEmpty() || stack.getItem() == null )
{
return false;
}
@@ -217,14 +217,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) );
newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) );
}
else
{
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), this.configDestination( inv ) );
newItems = myAdaptor.removeItems( toSend, whatToImport == null ? ItemStack.EMPTY : whatToImport.getItemStack(), this.configDestination( inv ) );
}
if( newItems != null )
if( !newItems.isEmpty() )
{
newItems.setCount( (int) ( Math.min( newItems.getCount(),
energy.extractAEPower( newItems.getCount(), Actionable.SIMULATE, PowerMultiplier.CONFIG ) ) + 0.01 ) );
@@ -266,7 +266,7 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
if( whatToImport == null )
{
itemStackToImport = null;
itemStackToImport = ItemStack.EMPTY;
}
else
{
@@ -141,7 +141,7 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
{
for( final ItemStack is : this.upgrades )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -66,7 +66,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
if( itemstack == null )
if( itemstack.isEmpty() )
{
return false;
}
@@ -75,7 +75,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
boolean simulate = ( type == Actionable.SIMULATE );
// This uses a brute force approach and tries to jam it in every slot the inventory exposes.
for( int i = 0; i < slotCount && remaining != null; i++ )
for( int i = 0; i < slotCount && !remaining.isEmpty(); i++ )
{
remaining = itemHandler.insertItem( i, remaining, simulate );
}
@@ -103,7 +103,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
int remainingSize = requestedItemStack.getCount();
// Use this to gather the requested items
ItemStack gathered = null;
ItemStack gathered = ItemStack.EMPTY;
final boolean simulate = ( mode == Actionable.SIMULATE );
@@ -125,7 +125,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
do
{
extracted = itemHandler.extractItem( i, remainingCurrentSlot, simulate );
if( extracted != null )
if( !extracted.isEmpty() )
{
if( extracted.getCount() > remainingCurrentSlot )
{
@@ -137,7 +137,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
// We're just gonna use the first stack we get our hands on as the template for the rest
if( gathered == null )
if( gathered.isEmpty() )
{
gathered = extracted;
}
@@ -148,7 +148,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
remainingCurrentSlot -= extracted.getCount();
}
}
while( extracted != null && remainingCurrentSlot > 0 );
while( !extracted.isEmpty() && remainingCurrentSlot > 0 );
remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot;
@@ -159,7 +159,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
}
}
if( gathered != null )
if( !gathered.isEmpty() )
{
if( mode == Actionable.MODULATE )
{
@@ -172,6 +172,17 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
return null;
}
private ItemStack getItemStackInCachedSlot ( int pos ) {
if( pos > cachedStacks.length )
return ItemStack.EMPTY;
if( cachedStacks[pos] == null )
return ItemStack.EMPTY;
return cachedStacks[pos];
}
@Override
public TickRateModulation onTick()
{
@@ -189,7 +200,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
for( int slot = 0; slot < slots; slot++ )
{
// Save the old stuff
ItemStack oldIS = cachedStacks[slot];
ItemStack oldIS = getItemStackInCachedSlot(slot);
IAEItemStack oldAeIS = cachedAeStacks[slot];
ItemStack newIS = itemHandler.getStackInSlot( slot );
@@ -198,7 +209,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
addItemChange( slot, oldAeIS, newIS, changes );
}
else if( newIS != null && oldIS != null )
else if( !newIS.isEmpty() && !oldIS.isEmpty() )
{
addPossibleStackSizeChange( slot, oldAeIS, newIS, changes );
}
@@ -275,12 +286,12 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private boolean isDifferent( final ItemStack a, final ItemStack b )
{
if( a == b && b == null )
if( a == b && b.isEmpty() )
{
return false;
}
return a == null || b == null || !Platform.itemComparisons().isSameItem( a, b );
return a.isEmpty() || b.isEmpty() || !Platform.itemComparisons().isSameItem( a, b );
}
private void postDifference( Iterable<IAEItemStack> a )
@@ -60,7 +60,7 @@ public class PartCableAnchor implements IPart
@PartModels
public static final PartModel FACADE_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor_short" ) );
private ItemStack is = null;
private ItemStack is = ItemStack.EMPTY;
private IPartHost host = null;
private AEPartLocation mySide = AEPartLocation.UP;
@@ -166,7 +166,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
// AELog.info( "ID:" + id.toString() + " : " + is.getItemDamage() );
final TunnelType tt = AEApi.instance().registries().p2pTunnel().getTunnelTypeByItem( is );
if( is != null && is.getItem() instanceof IMemoryCard )
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
{
final IMemoryCard mc = (IMemoryCard) is.getItem();
final NBTTagCompound data = mc.getData( is );
@@ -174,7 +174,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
final ItemStack newType = new ItemStack( data );
final long freq = data.getLong( "freq" );
if( newType != null )
if( !newType.isEmpty() )
{
if( newType.getItem() instanceof IPartItem )
{
@@ -219,7 +219,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
switch( tt )
{
case LIGHT:
newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( null );
newType = parts.p2PTunnelLight().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
/*
@@ -232,23 +232,23 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
*/
//case FLUID:
// newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( null );
// newType = parts.p2PTunnelLiquids().maybeStack( 1 ).orElse( ItemStack.EMPTY );
// break;
//case IC2_POWER:
// newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( null );
// newType = parts.p2PTunnelEU().maybeStack( 1 ).orElse( ItemStack.EMPTY );
// break;
case ITEM:
newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( null );
newType = parts.p2PTunnelItems().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case ME:
newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( null );
newType = parts.p2PTunnelME().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
case REDSTONE:
newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( null );
newType = parts.p2PTunnelRedstone().maybeStack( 1 ).orElse( ItemStack.EMPTY );
break;
/*
@@ -303,7 +303,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
public boolean onPartShiftActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
{
final ItemStack is = player.inventory.getCurrentItem();
if( is != null && is.getItem() instanceof IMemoryCard )
if( !is.isEmpty() && is.getItem() instanceof IMemoryCard )
{
final IMemoryCard mc = (IMemoryCard) is.getItem();
final NBTTagCompound data = new NBTTagCompound();
@@ -81,7 +81,7 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
for( final ItemStack is : this.viewCell )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -120,14 +120,14 @@ public class PartConversionMonitor extends AbstractPartMonitor
final IAEItemStack insertItem = input.copy();
insertItem.setStackSize( targetStack.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, insertItem, new PlayerSource( player, this ) );
player.inventory.setInventorySlotContents( x, failedToInsert == null ? null : failedToInsert.getItemStack() );
player.inventory.setInventorySlotContents( x, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() );
}
}
}
else
{
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? null : failedToInsert.getItemStack() );
player.inventory.setInventorySlotContents( player.inventory.currentItem, failedToInsert == null ? ItemStack.EMPTY : failedToInsert.getItemStack() );
}
}
catch( final GridAccessException e )
@@ -163,7 +163,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
ItemStack newItems = retrieved.getItemStack();
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
newItems = adaptor.addItems( newItems );
if( newItems != null )
if( !newItems.isEmpty() )
{
final TileEntity te = this.getTile();
final List<ItemStack> list = Collections.singletonList( newItems );
@@ -63,7 +63,7 @@ public class PartCraftingTerminal extends AbstractPartTerminal
for( final ItemStack is : this.craftingGrid )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -70,7 +70,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
{
for( final ItemStack is : this.pattern )
{
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -125,7 +125,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
if( inv == this.pattern && slot == 1 )
{
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem )
if( !is.isEmpty() && is.getItem() instanceof ICraftingPatternItem )
{
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() );
@@ -137,13 +137,13 @@ public class PartPatternTerminal extends AbstractPartTerminal
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
this.crafting.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
this.output.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
}
}
}
@@ -163,7 +163,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
final ItemStack is = this.crafting.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
is.setCount( 1 );
}
@@ -90,7 +90,7 @@ public final class DisassembleRecipe implements IRecipe
for( int slotIndex = 0; slotIndex < inventory.getSizeInventory(); slotIndex++ )
{
final ItemStack stackInSlot = inventory.getStackInSlot( slotIndex );
if( stackInSlot != null )
if( !stackInSlot.isEmpty() )
{
// needs a single input in the recipe
itemCount++;
@@ -57,7 +57,7 @@ public final class FacadeRecipe implements IRecipe
@Nullable
private ItemStack getOutput( final IInventory inv, final boolean createFacade )
{
if( inv.getStackInSlot( 0 ) == null && inv.getStackInSlot( 2 ) == null && inv.getStackInSlot( 6 ) == null && inv.getStackInSlot( 8 ) == null )
if( inv.getStackInSlot( 0 ).isEmpty() && inv.getStackInSlot( 2 ).isEmpty() && inv.getStackInSlot( 6 ).isEmpty() && inv.getStackInSlot( 8 ).isEmpty() )
{
if( this.anchor.isSameAs( inv.getStackInSlot( 1 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 3 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 5 ) ) && this.anchor.isSameAs( inv.getStackInSlot( 7 ) ) )
{
@@ -42,7 +42,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
private static final int MAX_CRAFT_GRID_WIDTH = 3;
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
private ItemStack output = null;
private ItemStack output = ItemStack.EMPTY;
private Object[] input = null;
private int width = 0;
private int height = 0;
@@ -256,7 +256,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
return false;
}
}
else if( target == null && slot != null )
else if( target == null && !slot.isEmpty() )
{
return false;
}
@@ -268,7 +268,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable
private boolean checkItemEquals( final ItemStack target, final ItemStack input )
{
if( input == null && target != null || input != null && target == null )
if( input.isEmpty() && !target.isEmpty() || !input.isEmpty() && target.isEmpty() )
{
return false;
}
@@ -38,7 +38,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
{
private final ArrayList<Object> input = new ArrayList<Object>();
private ItemStack output = null;
private ItemStack output = ItemStack.EMPTY;
private boolean disable = false;
public ShapelessRecipe( final ItemStack result, final Object... recipe )
@@ -83,7 +83,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
{
final ItemStack slot = var1.getStackInSlot( x );
if( slot != null )
if( !slot.isEmpty() )
{
boolean inRecipe = false;
@@ -59,8 +59,8 @@ public final class Inscribe extends InscriberProcess
final ItemStack[] realInput = this.getImprintable().getItemStackSet();
final List<ItemStack> inputs = new ArrayList<ItemStack>( realInput.length );
Collections.addAll( inputs, realInput );
final ItemStack top = ( this.getTopOptional() == null ) ? null : this.getTopOptional().getItemStack();
final ItemStack bot = ( this.getBotOptional() == null ) ? null : this.getBotOptional().getItemStack();
final ItemStack top = ( this.getTopOptional() == null ) ? ItemStack.EMPTY : this.getTopOptional().getItemStack();
final ItemStack bot = ( this.getBotOptional() == null ) ? ItemStack.EMPTY : this.getBotOptional().getItemStack();
final ItemStack output = this.getOutput().getItemStack();
final InscriberProcessType type = InscriberProcessType.INSCRIBE;
@@ -59,8 +59,8 @@ public final class Press extends InscriberProcess
final ItemStack[] realInput = this.getImprintable().getItemStackSet();
final List<ItemStack> inputs = new ArrayList<ItemStack>( realInput.length );
Collections.addAll( inputs, realInput );
final ItemStack top = ( this.getTopOptional() == null ) ? null : this.getTopOptional().getItemStack();
final ItemStack bot = ( this.getBotOptional() == null ) ? null : this.getBotOptional().getItemStack();
final ItemStack top = ( this.getTopOptional() == null ) ? ItemStack.EMPTY : this.getTopOptional().getItemStack();
final ItemStack bot = ( this.getBotOptional() == null ) ? ItemStack.EMPTY : this.getBotOptional().getItemStack();
final ItemStack output = this.getOutput().getItemStack();
final InscriberProcessType type = InscriberProcessType.PRESS;
@@ -176,7 +176,7 @@ public class ServerHelper extends CommonHelper
{
final ItemStack is = player.inventory.getStackInSlot( x );
if( is != null && is.getItem() instanceof ToolNetworkTool )
if( !is.isEmpty() && is.getItem() instanceof ToolNetworkTool )
{
final NBTTagCompound c = is.getTagCompound();
if( c != null && c.getBoolean( "hideFacades" ) )
+1 -1
View File
@@ -81,7 +81,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
{
final NBTTagCompound item = new NBTTagCompound();
final ItemStack is = this.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
is.writeToNBT( item );
}
+1 -1
View File
@@ -541,7 +541,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
for( int l = 0; l < inv.getSizeInventory(); l++ )
{
final ItemStack is = inv.getStackInSlot( l );
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -87,7 +87,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private final UpgradeInventory upgrades;
private boolean isPowered = false;
private AEPartLocation pushDirection = AEPartLocation.INTERNAL;
private ItemStack myPattern = null;
private ItemStack myPattern = ItemStack.EMPTY;
private ICraftingPatternDetails myPlan = null;
private double progress = 0;
private boolean isAwake = false;
@@ -114,12 +114,12 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
@Override
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final InventoryCrafting table, final EnumFacing where )
{
if( this.myPattern == null )
if( this.myPattern.isEmpty() )
{
boolean isEmpty = true;
for( int x = 0; x < this.inv.getSizeInventory(); x++ )
{
isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty;
isEmpty = this.inv.getStackInSlot( x ).isEmpty() && isEmpty;
}
if( isEmpty && patternDetails.isCraftable() )
@@ -167,7 +167,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private boolean canPush()
{
return this.inv.getStackInSlot( 9 ) != null;
return !this.inv.getStackInSlot( 9 ).isEmpty();
}
private boolean hasMats()
@@ -182,13 +182,13 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) );
}
return this.myPlan.getOutput( this.craftingInv, this.getWorld() ) != null;
return !this.myPlan.getOutput( this.craftingInv, this.getWorld() ).isEmpty();
}
@Override
public boolean acceptsPlans()
{
return this.inv.getStackInSlot( 10 ) == null;
return this.inv.getStackInSlot( 10 ).isEmpty();
}
@Override
@@ -217,7 +217,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
if( this.forcePlan && this.myPlan != null )
{
final ItemStack pattern = this.myPlan.getPattern();
if( pattern != null )
if( !pattern.isEmpty() )
{
final NBTTagCompound compound = new NBTTagCompound();
pattern.writeToNBT( compound );
@@ -238,7 +238,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
{
final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) );
if( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
if( !myPat.isEmpty() && myPat.getItem() instanceof ItemEncodedPattern )
{
final World w = this.getWorld();
final ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem();
@@ -269,7 +269,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
final ItemStack is = this.inv.getStackInSlot( 10 );
if( is != null && is.getItem() instanceof ItemEncodedPattern )
if( !is.isEmpty() && is.getItem() instanceof ItemEncodedPattern )
{
if( !Platform.itemComparisons().isEqualItem( is, this.myPattern ) )
{
@@ -290,7 +290,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
this.progress = 0;
this.forcePlan = false;
this.myPlan = null;
this.myPattern = null;
this.myPattern = ItemStack.EMPTY;
this.pushDirection = AEPartLocation.INTERNAL;
}
@@ -367,7 +367,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private boolean hasPattern()
{
return this.myPlan != null && this.inv.getStackInSlot( 10 ) != null;
return this.myPlan != null && !this.inv.getStackInSlot( 10 ).isEmpty();
}
@Override
@@ -404,7 +404,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
{
final ItemStack is = this.upgrades.getStackInSlot( h );
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -422,12 +422,12 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
@Override
public TickRateModulation tickingRequest( final IGridNode node, int ticksSinceLastCall )
{
if( this.inv.getStackInSlot( 9 ) != null )
if( !this.inv.getStackInSlot( 9 ).isEmpty() )
{
this.pushOut( this.inv.getStackInSlot( 9 ) );
// did it eject?
if( this.inv.getStackInSlot( 9 ) == null )
if( this.inv.getStackInSlot( 9 ).isEmpty() )
{
this.markDirty();
}
@@ -487,7 +487,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
this.progress = 0;
final ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorld() );
if( output != null )
if( !output.isEmpty() )
{
FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) this.getWorld() ), output, this.craftingInv );
@@ -498,7 +498,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) );
}
if( this.inv.getStackInSlot( 10 ) == null )
if( this.inv.getStackInSlot( 10 ).isEmpty() )
{
this.forcePlan = false;
this.myPlan = null;
@@ -529,17 +529,17 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private void ejectHeldItems()
{
if( this.inv.getStackInSlot( 9 ) == null )
if( this.inv.getStackInSlot( 9 ).isEmpty() )
{
for( int x = 0; x < 9; x++ )
{
final ItemStack is = this.inv.getStackInSlot( x );
if( is != null )
if( !is.isEmpty() )
{
if( this.myPlan == null || !this.myPlan.isValidItemForSlot( x, is, this.world ) )
{
this.inv.setInventorySlotContents( 9, is );
this.inv.setInventorySlotContents( x, null );
this.inv.setInventorySlotContents( x, ItemStack.EMPTY );
this.markDirty();
return;
}
@@ -574,7 +574,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
output = this.pushTo( output, this.pushDirection.getFacing() );
}
if( output == null && this.forcePlan )
if( output.isEmpty() && this.forcePlan )
{
this.forcePlan = false;
this.recalculatePlan();
@@ -585,7 +585,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
private ItemStack pushTo( ItemStack output, final EnumFacing d )
{
if( output == null )
if( output.isEmpty() )
{
return output;
}
@@ -606,7 +606,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
final int size = output.getCount();
output = adaptor.addItems( output );
final int newSize = output == null ? 0 : output.getCount();
final int newSize = output.isEmpty() ? 0 : output.getCount();
if( size != newSize )
{
@@ -177,7 +177,7 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
}
} );
this.setInventorySlotContents( 6, null );
this.setInventorySlotContents( 6, ItemStack.EMPTY );
}
}
@@ -189,7 +189,7 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
}
final ItemStack notAdded = sia.addItems( output );
if( notAdded != null )
if( !notAdded.isEmpty() )
{
final List<ItemStack> out = new ArrayList<ItemStack>();
out.add( notAdded );
@@ -56,7 +56,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
{
for( int x = 0; x < this.size; x++ )
{
if( this.getStackInSlot( x ) != null )
if( !this.getStackInSlot( x ).isEmpty() )
{
return false;
}
@@ -142,7 +142,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
{
if( this.inv[var1] == null )
{
return null;
return ItemStack.EMPTY;
}
return this.inv[var1].getItemStack();
@@ -154,7 +154,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
if( this.inv[slot] != null )
{
final ItemStack split = this.getStackInSlot( slot );
ItemStack ns = null;
ItemStack ns = ItemStack.EMPTY;
if( qty >= split.getCount() )
{
@@ -168,7 +168,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
if( this.te != null && Platform.isServer() )
{
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
this.te.onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, ItemStack.EMPTY );
}
return ns;
@@ -194,23 +194,23 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
if( !oldStack.isEmpty() && !newItemStack.isEmpty() && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
{
if( oldStack.getCount() > newItemStack.getCount() )
{
removed = removed.copy();
removed.grow( -newItemStack.getCount() );
added = null;
added = ItemStack.EMPTY;
}
else if( oldStack.getCount() < newItemStack.getCount() )
{
added = added.copy();
added.grow( -oldStack.getCount() );
removed = null;
removed = ItemStack.EMPTY;
}
else
{
removed = added = null;
removed = added = ItemStack.EMPTY;
}
}
@@ -241,7 +241,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
{
if( this.te != null && Platform.isServer() )
{
this.te.onChangeInventory( this, -1, InvOperation.markDirty, null, null );
this.te.onChangeInventory( this, -1, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY );
}
}
@@ -309,7 +309,7 @@ public class AppEngInternalAEInventory implements IInventory, Iterable<ItemStack
{
for( int x = 0; x < this.size; x++ )
{
this.setInventorySlotContents( x, null );
this.setInventorySlotContents( x, ItemStack.EMPTY );
}
}
}
@@ -69,7 +69,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
@Override
public ItemStack getStackInSlot( final int var1 )
{
return this.inv[var1];
return this.inv[var1] == null ? ItemStack.EMPTY : this.inv[var1];
}
@Override
@@ -78,12 +78,12 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
if( this.inv[slot] != null )
{
final ItemStack split = this.getStackInSlot( slot );
ItemStack ns = null;
ItemStack ns = ItemStack.EMPTY;
if( qty >= split.getCount() )
{
ns = this.inv[slot];
this.inv[slot] = null;
this.inv[slot] = ItemStack.EMPTY;
}
else
{
@@ -92,7 +92,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
if( this.getTileEntity() != null && this.eventsEnabled() )
{
this.getTileEntity().onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, null );
this.getTileEntity().onChangeInventory( this, slot, InvOperation.decreaseStackSize, ns, ItemStack.EMPTY );
}
this.markDirty();
@@ -124,7 +124,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if( oldStack != null && newItemStack != null && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
if( !oldStack.isEmpty() && !newItemStack.isEmpty() && Platform.itemComparisons().isEqualItem( oldStack, newItemStack ) )
{
if( oldStack.getCount() > newItemStack.getCount() )
{
@@ -136,11 +136,11 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
{
added = added.copy();
added.grow( -oldStack.getCount() );
removed = null;
removed = ItemStack.EMPTY;
}
else
{
removed = added = null;
removed = added = ItemStack.EMPTY;
}
}
@@ -173,7 +173,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
{
if( this.getTileEntity() != null && this.eventsEnabled() )
{
this.getTileEntity().onChangeInventory( this, -1, InvOperation.markDirty, null, null );
this.getTileEntity().onChangeInventory( this, -1, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY );
}
}
@@ -199,7 +199,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
{
if( this.getTileEntity() != null && this.eventsEnabled() )
{
this.getTileEntity().onChangeInventory( this, slotIndex, InvOperation.markDirty, null, null );
this.getTileEntity().onChangeInventory( this, slotIndex, InvOperation.markDirty, ItemStack.EMPTY, ItemStack.EMPTY );
}
}
@@ -306,7 +306,7 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
{
for( int x = 0; x < this.size; x++ )
{
this.setInventorySlotContents( x, null );
this.setInventorySlotContents( x, ItemStack.EMPTY );
}
}
@@ -72,7 +72,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
}
final ItemStack is = this.cell.getStackInSlot( 0 );
if( is == null )
if( is.isEmpty() )
{
return null;
}
@@ -90,7 +90,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
public ICellWorkbenchItem getCell()
{
if( this.cell.getStackInSlot( 0 ) == null )
if( this.cell.getStackInSlot( 0 ).isEmpty() )
{
return null;
}
@@ -157,7 +157,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
boolean cellHasConfig = false;
for( int x = 0; x < configInventory.getSizeInventory(); x++ )
{
if( configInventory.getStackInSlot( x ) != null )
if( !configInventory.getStackInSlot( x ).isEmpty() )
{
cellHasConfig = true;
break;
@@ -185,7 +185,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
{
for( int x = 0; x < this.config.getSizeInventory(); x++ )
{
this.config.setInventorySlotContents( x, null );
this.config.setInventorySlotContents( x, ItemStack.EMPTY );
}
this.markDirty();
@@ -219,7 +219,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
}
final ItemStack is = this.cell.getStackInSlot( 0 );
if( is == null )
if( is.isEmpty() )
{
return null;
}
@@ -93,7 +93,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
}
catch( final Throwable t )
{
this.inv.setInventorySlotContents( 0, null );
this.inv.setInventorySlotContents( 0, ItemStack.EMPTY );
}
return false; // TESR doesn't need updates!
}
@@ -217,7 +217,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
}
final ItemStack myItem = this.getStackInSlot( 0 );
if( myItem == null )
if( myItem.isEmpty() )
{
ItemStack held = player.inventory.getCurrentItem();
@@ -231,7 +231,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
{
final List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add( myItem );
this.setInventorySlotContents( 0, null );
this.setInventorySlotContents( 0, ItemStack.EMPTY );
Platform.spawnDrops( this.world, this.pos.offset( this.getForward() ), drops );
}
}
@@ -267,7 +267,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
return true;
}
if( myItem == null )
if( myItem.isEmpty() )
{
return false;
}
@@ -97,7 +97,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
public double getStorage()
{
final ItemStack is = this.inv.getStackInSlot( 2 );
if( is != null )
if( !is.isEmpty() )
{
if( is.getItem() instanceof IStorageComponent )
{
@@ -118,7 +118,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
final double requiredPower = this.getRequiredPower();
final ItemStack output = this.getOutput();
while( requiredPower <= this.getStoredPower() && output != null && requiredPower > 0 )
while( requiredPower <= this.getStoredPower() && !output.isEmpty() && requiredPower > 0 )
{
if( this.canAddOutput( output ) )
{
@@ -135,7 +135,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
private boolean canAddOutput( final ItemStack output )
{
final ItemStack outputStack = this.getStackInSlot( 1 );
return outputStack == null || ( Platform.itemComparisons().isEqualItem( outputStack,
return outputStack.isEmpty() || ( Platform.itemComparisons().isEqualItem( outputStack,
output ) && outputStack.getCount() < outputStack.getMaxStackSize() );
}
@@ -147,7 +147,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
private void addOutput( final ItemStack output )
{
final ItemStack outputStack = this.getStackInSlot( 1 );
if( outputStack == null )
if( outputStack.isEmpty() )
{
this.setInventorySlotContents( 1, output.copy() );
}
@@ -165,10 +165,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
switch( (CondenserOutput) this.cm.getSetting( Settings.CONDENSER_OUTPUT ) )
{
case MATTER_BALLS:
return materials.matterBall().maybeStack( 1 ).orElse( null );
return materials.matterBall().maybeStack( 1 ).orElse( ItemStack.EMPTY );
case SINGULARITY:
return materials.singularity().maybeStack( 1 ).orElse( null );
return materials.singularity().maybeStack( 1 ).orElse( ItemStack.EMPTY );
case TRASH:
default:
@@ -192,7 +192,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
{
if( i == 0 )
{
if( itemstack != null )
if( !itemstack.isEmpty() )
{
this.addPower( itemstack.getCount() );
}
@@ -215,10 +215,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
if( slot == 0 )
{
final ItemStack is = inv.getStackInSlot( 0 );
if( is != null )
if( !is.isEmpty() )
{
this.addPower( is.getCount() );
inv.setInventorySlotContents( 0, null );
inv.setInventorySlotContents( 0, ItemStack.EMPTY );
}
}
}
@@ -324,7 +324,7 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
{
return stack;
}
if( !simulate && stack != null )
if( !simulate && !stack.isEmpty() )
{
addPower( stack.getCount() );
}
@@ -168,7 +168,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
}
else
{
this.inv.setInventorySlotContents( num, null );
this.inv.setInventorySlotContents( num, ItemStack.EMPTY );
}
}
@@ -215,7 +215,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
for( int h = 0; h < this.upgrades.getSizeInventory(); h++ )
{
final ItemStack is = this.upgrades.getStackInSlot( h );
if( is != null )
if( !is.isEmpty() )
{
drops.add( is );
}
@@ -344,17 +344,17 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
final ItemStack plateB = this.getStackInSlot( 1 );
ItemStack renamedItem = this.getStackInSlot( 2 );
if( plateA != null && plateA.getCount() > 1 )
if( !plateA.isEmpty() && plateA.getCount() > 1 )
{
return null;
}
if( plateB != null && plateB.getCount() > 1 )
if( !plateB.isEmpty() && plateB.getCount() > 1 )
{
return null;
}
if( renamedItem != null && renamedItem.getCount() > 1 )
if( !renamedItem.isEmpty() && renamedItem.getCount() > 1 )
{
return null;
}
@@ -363,19 +363,19 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
final boolean isNameA = namePress.isSameAs( plateA );
final boolean isNameB = namePress.isSameAs( plateB );
if( ( isNameA || isNameB ) && ( isNameA || plateA == null ) && ( isNameB || plateB == null ) )
if( ( isNameA || isNameB ) && ( isNameA || plateA.isEmpty() ) && ( isNameB || plateB.isEmpty() ) )
{
if( renamedItem != null )
if( !renamedItem.isEmpty() )
{
String name = "";
if( plateA != null )
if( !plateA.isEmpty() )
{
final NBTTagCompound tag = Platform.openNbtData( plateA );
name += tag.getString( "InscribeName" );
}
if( plateB != null )
if( !plateB.isEmpty() )
{
final NBTTagCompound tag = Platform.openNbtData( plateB );
if( name.length() > 0 )
@@ -417,15 +417,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
for( final IInscriberRecipe recipe : AEApi.instance().registries().inscriber().getRecipes() )
{
final boolean matchA = ( plateA == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateB == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB,
recipe.getBottomOptional().orElse( null ) ) );
final boolean matchA = ( plateA.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateA,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( plateB.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateB,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
final boolean matchB = ( plateB == null && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
recipe.getTopOptional().orElse( null ) ) ) && // and...
( plateA == null && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA,
recipe.getBottomOptional().orElse( null ) ) );
final boolean matchB = ( plateB.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( plateB,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( plateA.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( plateA,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
if( matchA || matchB )
{
@@ -455,15 +455,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
final ItemStack outputCopy = out.getOutput().copy();
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, SLOT_OUT, 1, true ), EnumFacing.UP );
if( ad.addItems( outputCopy ) == null )
if( ad.addItems( outputCopy ).isEmpty() )
{
this.setProcessingTime( 0 );
if( out.getProcessType() == InscriberProcessType.PRESS )
{
this.setInventorySlotContents( SLOT_TOP, null );
this.setInventorySlotContents( SLOT_BOTTOM, null );
this.setInventorySlotContents( SLOT_TOP, ItemStack.EMPTY );
this.setInventorySlotContents( SLOT_BOTTOM, ItemStack.EMPTY );
}
this.setInventorySlotContents( SLOT_MIDDLE, null );
this.setInventorySlotContents( SLOT_MIDDLE, ItemStack.EMPTY );
}
}
@@ -522,7 +522,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
{
final ItemStack outputCopy = out.getOutput().copy();
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this.inv, SLOT_OUT, 1, true ), EnumFacing.UP );
if( ad.simulateAdd( outputCopy ) == null )
if( ad.simulateAdd( outputCopy ).isEmpty() )
{
this.setSmash( true );
this.finalStep = 0;
@@ -678,13 +678,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
@Override
public ItemStack insertItem( int slot, ItemStack stack, boolean simulate )
{
if( slot != 0 || stack == null )
if( slot != 0 || stack.isEmpty() )
{
return stack;
}
// If there's already an item stack in the slot, we don't allow insertion and don't do any other checks
if( inv.getStackInSlot( insertSlot ) != null )
if( !inv.getStackInSlot( insertSlot ).isEmpty() )
{
return stack;
}
@@ -715,11 +715,11 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
if( simulate )
{
return adapter.simulateRemove( amount, null, null );
return adapter.simulateRemove( amount, ItemStack.EMPTY, null );
}
else
{
return adapter.removeItems( amount, null, null );
return adapter.removeItems( amount, ItemStack.EMPTY, null );
}
}
@@ -157,7 +157,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
private boolean canEatFuel()
{
final ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX );
if( is != null )
if( !is.isEmpty() )
{
final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
if( newBurnTime > 0 && is.getCount() > 0 )
@@ -244,7 +244,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
private void eatFuel()
{
final ItemStack is = this.getStackInSlot( FUEL_SLOT_INDEX );
if( is != null )
if( !is.isEmpty() )
{
final int newBurnTime = TileEntityFurnace.getItemBurnTime( is );
if( newBurnTime > 0 && is.getCount() > 0 )
@@ -94,7 +94,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
{
int out = this.constructed;
if( this.getStackInSlot( 0 ) != null && this.constructed != -1 )
if( !this.getStackInSlot( 0 ).isEmpty() && this.constructed != -1 )
{
out |= this.hasSingularity;
}
@@ -272,7 +272,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
public long getQEFrequency()
{
final ItemStack is = this.internalInventory.getStackInSlot( 0 );
if( is != null )
if( !is.isEmpty() )
{
final NBTTagCompound c = is.getTagCompound();
if( c != null )
@@ -114,7 +114,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
private boolean isSpatialCell( final ItemStack cell )
{
if( cell != null && cell.getItem() instanceof ISpatialStorageCell )
if( !cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell )
{
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
return sc != null && sc.isSpatialStorage( cell );
@@ -126,7 +126,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
public Void call( final World world ) throws Exception
{
final ItemStack cell = this.getStackInSlot( 0 );
if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ) == null )
if( this.isSpatialCell( cell ) && this.getStackInSlot( 1 ).isEmpty() )
{
final IGrid gi = this.getProxy().getGrid();
final IEnergyGrid energy = this.getProxy().getEnergy();
@@ -147,7 +147,7 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
if( tr.success )
{
energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.setInventorySlotContents( 0, null );
this.setInventorySlotContents( 0, ItemStack.EMPTY );
this.setInventorySlotContents( 1, cell );
}
}
@@ -199,7 +199,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
this.fluidCell = null;
final ItemStack is = this.inv.getStackInSlot( 1 );
if( is != null )
if( !is.isEmpty() )
{
this.isCached = true;
this.cellHandler = AEApi.instance().registries().cell().getHandler( is );
@@ -393,7 +393,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
}
if( this.inv.getStackInSlot( 0 ) != null )
if( !this.inv.getStackInSlot( 0 ).isEmpty() )
{
this.tryToStoreContents();
}
@@ -430,7 +430,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
final ItemStack is = this.inv.getStackInSlot( 1 );
if( is == null )
if( is.isEmpty() )
{
data.writeInt( 0 );
}
@@ -454,7 +454,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
if( item == 0 )
{
this.storageType = null;
this.storageType = ItemStack.EMPTY;
}
else
{
@@ -616,7 +616,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
{
try
{
if( this.getStackInSlot( 0 ) != null )
if( !this.getStackInSlot( 0 ).isEmpty() )
{
final IMEInventory<IAEItemStack> cell = this.getHandler( StorageChannel.ITEMS );
@@ -624,7 +624,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
if( returns == null )
{
this.inv.setInventorySlotContents( 0, null );
this.inv.setInventorySlotContents( 0, ItemStack.EMPTY );
}
else
{
@@ -241,7 +241,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
@MENetworkEventSubscribe
public void channelRender( final MENetworkChannelsChanged c )
{
this.recalculateDisplay();
this.recalculateDisplay();
}
@Override
@@ -312,7 +312,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
this.invBySlot[x] = null;
this.handlersBySlot[x] = null;
if( is != null )
if( !is.isEmpty() )
{
this.handlersBySlot[x] = AEApi.instance().registries().cell().getHandler( is );

Some files were not shown because too many files have changed in this diff Show More