Replaced normal for loops with foreach loops which is less error prone when just iterating over collection/array

This commit is contained in:
thatsIch
2014-09-29 09:23:02 +02:00
parent 87126e1f11
commit 3db2d4960b
15 changed files with 86 additions and 60 deletions
@@ -360,28 +360,32 @@ public abstract class AEBaseContainer extends Container
tis = shiftStoreItem( tis );
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
for (Object inventorySlot : this.inventorySlots)
{
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) inventorySlot;
if ( !(cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
{
selectedSlots.add( cs );
}
}
}
}
else
{
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
for (Object inventorySlot : this.inventorySlots)
{
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) inventorySlot;
if ( (cs.isPlayerSide()) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
{
selectedSlots.add( cs );
}
}
}
}
@@ -394,15 +398,17 @@ public abstract class AEBaseContainer extends Container
if ( tis != null )
{
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
for (Object inventorySlot : this.inventorySlots)
{
AppEngSlot cs = (AppEngSlot) this.inventorySlots.get( x );
AppEngSlot cs = (AppEngSlot) inventorySlot;
ItemStack dest = cs.getStack();
if ( !(cs.isPlayerSide()) && cs instanceof SlotFake )
{
if ( Platform.isSameItemPrecise( dest, tis ) )
{
return null;
}
else if ( dest == null )
{
cs.putStack( tis.copy() );
@@ -563,9 +569,9 @@ public abstract class AEBaseContainer extends Container
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
for (Object crafter : this.crafters)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
ICrafting icrafting = (ICrafting) crafter;
for (SyncData sd : syncData.values())
sd.tick( icrafting );
@@ -242,9 +242,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
for (Object crafter : this.crafters)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
ICrafting icrafting = (ICrafting) crafter;
if ( prevStack != is )
{
@@ -152,11 +152,11 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
if ( sideLocal != sideRemote )
{
clientCM.putSetting( set, sideLocal );
for (int j = 0; j < this.crafters.size(); ++j)
for (Object crafter : this.crafters)
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) this.crafters.get( j ) );
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter );
}
catch (IOException e)
{
@@ -262,9 +262,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
List<ItemStack> list = new ArrayList<ItemStack>( 3 );
boolean hasValue = false;
for (int x = 0; x < outputSlots.length; x++)
for (OptionalSlotFake outputSlot : outputSlots)
{
ItemStack out = outputSlots[x].getStack();
ItemStack out = outputSlot.getStack();
if ( out != null && out.stackSize > 0 )
{
list.add( out );
@@ -395,9 +395,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
if ( s == patternSlotOUT && Platform.isServer() )
{
for (int i = 0; i < this.crafters.size(); ++i)
for (Object crafter : this.crafters)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
ICrafting icrafting = (ICrafting) crafter;
for (Object g : inventorySlots)
{
@@ -134,9 +134,9 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
wirelessOut.putStack( term );
// update the two slots in question...
for (int i = 0; i < this.crafters.size(); ++i)
for (Object crafter : this.crafters)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
ICrafting icrafting = (ICrafting) crafter;
icrafting.sendSlotContents( this, wirelessIn.slotNumber, wirelessIn.getStack() );
icrafting.sendSlotContents( this, wirelessOut.slotNumber, wirelessOut.getStack() );
}