Merge pull request #166 from iloveportalz0r/rv2

Deleted redundant null checks in various scenarios where it either would have crashed before by calling it already or because it was already checked before without modifying the current state of that variable.
This commit is contained in:
thatsIch 2014-09-28 20:16:21 +02:00
commit f8c7a62ce8
18 changed files with 32 additions and 46 deletions

0
gradlew vendored Normal file → Executable file
View file

View file

@ -88,7 +88,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
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 ) );

View file

@ -404,7 +404,7 @@ public abstract class AEBaseContainer extends Container
return null;
else if ( dest == null )
{
cs.putStack( tis != null ? tis.copy() : null );
cs.putStack( tis.copy() );
cs.onSlotChanged();
updateSlot( cs );
return null;
@ -422,13 +422,13 @@ public abstract class AEBaseContainer extends Container
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() )
@ -468,13 +468,13 @@ public abstract class AEBaseContainer extends Container
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 )

View file

@ -346,16 +346,13 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
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 );
}
}

View file

@ -112,7 +112,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
is = r.getCraftingResult( ic );
if ( r != null && inv != null )
if ( inv != null )
{
for (int x = 0; x < pattern.getSizeInventory(); x++)
{

View file

@ -196,7 +196,7 @@ public class SlotRestrictedInput extends AppEngSlot
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;

View file

@ -364,7 +364,7 @@ public class DualityInterface implements IGridTickable, ISegmentedInventory, ISt
return;
}
}
else if ( Stored != null ) // dispose!
else // Stored != null; dispose!
{
IAEItemStack work = AEApi.instance().storage().createItemStack( Stored );
requireWork[slot] = work.setStackSize( -work.getStackSize() );

View file

@ -74,8 +74,6 @@ public class MultiCraftingTracker
{
if ( craftingJob.isDone() )
job = craftingJob.get();
else if ( craftingJob.isCancelled() )
job = null;
if ( job != null )
{

View file

@ -86,11 +86,8 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
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
@ -118,7 +115,7 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler
{
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 ) )

View file

@ -58,11 +58,8 @@ public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
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
@ -90,7 +87,7 @@ public class NEIInscriberRecipeHandler extends TemplateRecipeHandler
{
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 ) )

View file

@ -802,7 +802,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
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 );

View file

@ -176,7 +176,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
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 ) )
@ -190,7 +190,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
changes.add( old.aeStack );
}
if ( cis != null && cis.aeStack != null )
if ( cis.aeStack != null )
{
changes.add( cis.aeStack );
list.add( cis.aeStack );
@ -198,7 +198,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
changed = true;
}
else if ( is != null )
else
{
int newSize = (newIS == null ? 0 : newIS.stackSize);
int diff = newSize - (oldIS == null ? 0 : oldIS.stackSize);

View file

@ -247,7 +247,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
if ( sbp != null )
{
IGridNode sn = sbp.getGridNode();
if ( sn != null && cn != null )
if ( sn != null )
{
try
{
@ -574,8 +574,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
data.writeShort( Item.getIdFromItem( is.getItem() ) );
data.writeShort( is.getItemDamage() );
if ( p != null )
p.writeToStream( data );
p.writeToStream( data );
}
}
@ -921,7 +920,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
}
}
if ( facades != null && !facades.isEmpty() )
if ( !facades.isEmpty() )
{
TileEntity te = tcb.getTile();
Platform.spawnDrops( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, facades );

View file

@ -162,7 +162,7 @@ public class PartPlacement
if ( host.isEmpty() )
host.cleanup();
if ( is != null && !is.isEmpty() )
if ( !is.isEmpty() )
{
Platform.spawnDrops( world, x, y, z, is );
}

View file

@ -254,7 +254,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
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 )

View file

@ -59,8 +59,6 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory
if ( inventories.isEmpty() || slotCount == 0 )
{
inventories = null;
sideData = null;
slots = null;
}
else
{

View file

@ -93,7 +93,7 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
{
if ( is.getStackSize() != dspPlay.getStackSize() )
{
dspPlay = is == null ? null : is.copy();
dspPlay = is.copy();
markForUpdate();
}
}

View file

@ -635,7 +635,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
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)
@ -645,7 +645,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
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)