Skip to content

Commit

Permalink
Deleted redundant null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMetric committed Sep 28, 2014
1 parent f9b9729 commit 0042176
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 46 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion src/main/java/appeng/client/gui/AEBaseMEGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected void renderToolTip(ItemStack stack, int x, int y)

drawTooltip( x, y, 0, join( currentToolTip, "\n" ) );
}
else if ( stack != null && stack.stackSize > BigNumber )
else if ( stack.stackSize > BigNumber )
{
List var4 = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/appeng/container/AEBaseContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public ItemStack transferStackInSlot(EntityPlayer p, int idx)
return null;
else if ( dest == null )
{
cs.putStack( tis != null ? tis.copy() : null );
cs.putStack( tis.copy() );
cs.onSlotChanged();
updateSlot( cs );
return null;
Expand All @@ -422,13 +422,13 @@ else if ( dest == null )
if ( d instanceof SlotDisabled || d instanceof SlotME )
continue;

if ( d.isItemValid( tis ) && tis != null )
if ( d.isItemValid( tis ) )
{
if ( d.getHasStack() )
{
ItemStack t = d.getStack();

if ( tis != null && Platform.isSameItemPrecise( tis, t ) ) // t.isItemEqual(tis))
if ( Platform.isSameItemPrecise( tis, t ) ) // t.isItemEqual(tis))
{
int maxSize = t.getMaxStackSize();
if ( maxSize > d.getSlotStackLimit() )
Expand Down Expand Up @@ -468,13 +468,13 @@ else if ( dest == null )
if ( d instanceof SlotDisabled || d instanceof SlotME )
continue;

if ( d.isItemValid( tis ) && tis != null )
if ( d.isItemValid( tis ) )
{
if ( d.getHasStack() )
{
ItemStack t = d.getStack();

if ( tis != null && Platform.isSameItemPrecise( t, tis ) )
if ( Platform.isSameItemPrecise( t, tis ) )
{
int maxSize = t.getMaxStackSize();
if ( d.getSlotStackLimit() < maxSize )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,13 @@ public void craftOrGetItem(PacketPatternSlot packetPatternSlot)

ItemStack is = r.getCraftingResult( ic );

if ( r != null && inv != null )
for (int x = 0; x < ic.getSizeInventory(); x++)
{
for (int x = 0; x < ic.getSizeInventory(); x++)
if ( ic.getStackInSlot( x ) != null )
{
if ( ic.getStackInSlot( x ) != null )
{
ItemStack pulled = Platform.extractItemsByRecipe( powerSrc, mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all,
Actionable.MODULATE, ItemViewCell.createFilter( getViewCells() ) );
real.setInventorySlotContents( x, pulled );
}
ItemStack pulled = Platform.extractItemsByRecipe( powerSrc, mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all,
Actionable.MODULATE, ItemViewCell.createFilter( getViewCells() ) );
real.setInventorySlotContents( x, pulled );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/container/slot/SlotCraftingTerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ItemStack craftItem(EntityPlayer p, ItemStack request, IMEMonitor<IAEItem

is = r.getCraftingResult( ic );

if ( r != null && inv != null )
if ( inv != null )
{
for (int x = 0; x < pattern.getSizeInventory(); x++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public boolean isItemValid(ItemStack i)
case STORAGE_CELLS:
return AEApi.instance().registries().cell().isCellHandled( i );
case WORKBENCH_CELL:
return i != null && i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable( i );
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable( i );
case STORAGE_COMPONENT:
boolean isComp = i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i );
return isComp;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ else if ( req.isSameType( Stored ) ) // same type ( qty different? )!
return;
}
}
else if ( Stored != null ) // dispose!
else // Stored != null; dispose!
{
IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
requireWork[slot] = work.setStackSize( -work.getStackSize() );
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/appeng/helpers/MultiCraftingTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ else if ( craftingJob != null )
{
if ( craftingJob.isDone() )
job = craftingJob.get();
else if ( craftingJob.isCancelled() )
job = null;

if ( job != null )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ public void loadCraftingRecipes(String outputId, Object... results)
for (IGrinderEntry recipe : AEApi.instance().registries().grinder().getRecipes())
{
CachedGrindStoneRecipe cachedRecipe = new CachedGrindStoneRecipe( recipe );
if ( cachedRecipe != null )
{
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
else
Expand Down Expand Up @@ -118,7 +115,7 @@ public void loadUsageRecipes(ItemStack ingredient)
{
CachedGrindStoneRecipe cachedRecipe = new CachedGrindStoneRecipe( recipe );

if ( (cachedRecipe != null) && (cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() )) )
if ( (cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() )) )
{
cachedRecipe.computeVisuals();
if ( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ public void loadCraftingRecipes(String outputId, Object... results)
for (InscriberRecipe recipe : Inscribe.recipes)
{
CachedInscriberRecipe cachedRecipe = new CachedInscriberRecipe( recipe );
if ( cachedRecipe != null )
{
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
cachedRecipe.computeVisuals();
this.arecipes.add( cachedRecipe );
}
}
else
Expand Down Expand Up @@ -90,7 +87,7 @@ public void loadUsageRecipes(ItemStack ingredient)
{
CachedInscriberRecipe cachedRecipe = new CachedInscriberRecipe( recipe );

if ( (cachedRecipe != null) && (cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() )) )
if ( (cachedRecipe.contains( cachedRecipe.ingredients, ingredient.getItem() )) )
{
cachedRecipe.computeVisuals();
if ( cachedRecipe.contains( cachedRecipe.ingredients, ingredient ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ public ICraftingLink submitJob(IGrid g, ICraftingJob job, BaseActionSource src,
if ( requestingMachine == null )
return myLastLink;

ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, requestingMachine == null, true ), requestingMachine );
ICraftingLink whatLink = new CraftingLink( generateLinkData( craftID, false, true ), requestingMachine );

submitLink( myLastLink );
submitLink( whatLink );
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/appeng/me/storage/MEMonitorIInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public TickRateModulation onTick()
CachedItemStack old = memory.get( is.slot );
high = Math.max( high, is.slot );

ItemStack newIS = is == null || is.isExtractable == false && mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
ItemStack newIS = is.isExtractable == false && mode == StorageFilter.EXTRACTABLE_ONLY ? null : is.getItemStack();
ItemStack oldIS = old == null ? null : old.itemStack;

if ( isDifferent( newIS, oldIS ) )
Expand All @@ -190,15 +190,15 @@ public TickRateModulation onTick()
changes.add( old.aeStack );
}

if ( cis != null && cis.aeStack != null )
if ( cis.aeStack != null )
{
changes.add( cis.aeStack );
list.add( cis.aeStack );
}

changed = true;
}
else if ( is != null )
else
{
int newSize = (newIS == null ? 0 : newIS.stackSize);
int diff = newSize - (oldIS == null ? 0 : oldIS.stackSize);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/appeng/parts/CableBusContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public ForgeDirection addPart(ItemStack is, ForgeDirection side, EntityPlayer pl
if ( sbp != null )
{
IGridNode sn = sbp.getGridNode();
if ( sn != null && cn != null )
if ( sn != null )
{
try
{
Expand Down Expand Up @@ -574,8 +574,7 @@ public void writeToStream(ByteBuf data) throws IOException
data.writeShort( Item.getIdFromItem( is.getItem() ) );
data.writeShort( is.getItemDamage() );

if ( p != null )
p.writeToStream( data );
p.writeToStream( data );
}
}

Expand Down Expand Up @@ -921,7 +920,7 @@ public void partChanged()
}
}

if ( facades != null && !facades.isEmpty() )
if ( !facades.isEmpty() )
{
TileEntity te = tcb.getTile();
Platform.spawnDrops( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, facades );
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/parts/PartPlacement.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static boolean place(ItemStack held, int x, int y, int z, int face, Entit
if ( host.isEmpty() )
host.cleanup();

if ( is != null && !is.isEmpty() )
if ( !is.isEmpty() )
{
Platform.spawnDrops( world, x, y, z, is );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public TickRateModulation EatBlock(boolean eatForReal)

if ( !ignore )
{
if ( !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && blk != null && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
if ( !w.isAirBlock( x, y, z ) && w.blockExists( x, y, z ) && w.canMineBlock( Platform.getPlayer( w ), x, y, z ) )
{
float hardness = blk.getBlockHardness( w, x, y, z );
if ( hardness >= 0.0 )
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/appeng/parts/layers/LayerISidedInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public void notifyNeighbors()
if ( inventories.isEmpty() || slotCount == 0 )
{
inventories = null;
sideData = null;
slots = null;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ else if ( is != null && dspPlay != null )
{
if ( is.getStackSize() != dspPlay.getStackSize() )
{
dspPlay = is == null ? null : is.copy();
dspPlay = is.copy();
markForUpdate();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/appeng/tile/storage/TileChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public int getCellStatus(int slot)
try
{
IMEInventoryHandler handler = getHandler( StorageChannel.ITEMS );
if ( ch != null && handler instanceof ChestMonitorHandler )
if ( handler instanceof ChestMonitorHandler )
return ch.getStatusForCell( cell, ((ChestMonitorHandler) handler).getInternalHandler() );
}
catch (ChestNoHandler e)
Expand All @@ -645,7 +645,7 @@ public int getCellStatus(int slot)
try
{
IMEInventoryHandler handler = getHandler( StorageChannel.FLUIDS );
if ( ch != null && handler instanceof ChestMonitorHandler )
if ( handler instanceof ChestMonitorHandler )
return ch.getStatusForCell( cell, ((ChestMonitorHandler) handler).getInternalHandler() );
}
catch (ChestNoHandler e)
Expand Down

0 comments on commit 0042176

Please sign in to comment.