Replaces while iterators with foreach call

This commit is contained in:
thatsIch 2014-09-29 09:26:35 +02:00
parent 72106c877d
commit b6ec21c70a
10 changed files with 33 additions and 36 deletions

View file

@ -394,11 +394,10 @@ public abstract class AEBaseGui extends GuiContainer
else if ( dbl_whichItem != null ) else if ( dbl_whichItem != null )
{ {
// a replica of the weird broken vanilla feature. // a replica of the weird broken vanilla feature.
Iterator iterator = this.inventorySlots.inventorySlots.iterator();
while (iterator.hasNext()) for (Object inventorySlot : this.inventorySlots.inventorySlots)
{ {
Slot targetSlot = (Slot) iterator.next(); Slot targetSlot = (Slot) inventorySlot;
if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack() if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack()
&& targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) ) && targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) )

View file

@ -251,12 +251,12 @@ public class GuiCraftConfirm extends AEBaseGui
private IAEItemStack findVisualStack(IAEItemStack l) private IAEItemStack findVisualStack(IAEItemStack l)
{ {
Iterator<IAEItemStack> i = visual.iterator(); for (IAEItemStack o : visual)
while (i.hasNext())
{ {
IAEItemStack o = i.next();
if ( o.equals( l ) ) if ( o.equals( l ) )
{
return o; return o;
}
} }
IAEItemStack stack = l.copy(); IAEItemStack stack = l.copy();

View file

@ -169,12 +169,12 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
private IAEItemStack findVisualStack(IAEItemStack l) private IAEItemStack findVisualStack(IAEItemStack l)
{ {
Iterator<IAEItemStack> i = visual.iterator(); for (IAEItemStack o : visual)
while (i.hasNext())
{ {
IAEItemStack o = i.next();
if ( o.equals( l ) ) if ( o.equals( l ) )
{
return o; return o;
}
} }
IAEItemStack stack = l.copy(); IAEItemStack stack = l.copy();

View file

@ -209,12 +209,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
if ( machine instanceof ICraftingRequester ) if ( machine instanceof ICraftingRequester )
{ {
Iterator<CraftingLinkNexus> nex = links.values().iterator(); for (CraftingLinkNexus n : links.values())
while (nex.hasNext())
{ {
CraftingLinkNexus n = nex.next();
if ( n.isMachine( machine ) ) if ( n.isMachine( machine ) )
{
n.removeNode(); n.removeNode();
}
} }
} }

View file

@ -89,15 +89,15 @@ public class CellInventory implements ICellInventory
// add new pretty stuff... // add new pretty stuff...
int x = 0; int x = 0;
Iterator<IAEItemStack> i = cellItems.iterator(); for (IAEItemStack v : cellItems)
while (i.hasNext())
{ {
IAEItemStack v = i.next();
itemCount += v.getStackSize(); itemCount += v.getStackSize();
NBTBase c = tagCompound.getTag( ITEM_SLOT_ARR[x] ); NBTBase c = tagCompound.getTag( ITEM_SLOT_ARR[x] );
if ( c instanceof NBTTagCompound ) if ( c instanceof NBTTagCompound )
{
v.writeToNBT( (NBTTagCompound) c ); v.writeToNBT( (NBTTagCompound) c );
}
else else
{ {
NBTTagCompound g = new NBTTagCompound(); NBTTagCompound g = new NBTTagCompound();

View file

@ -155,12 +155,8 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return input; return input;
} }
Iterator<List<IMEInventoryHandler<T>>> i = priorityInventory.values().iterator();// asMap().entrySet().iterator(); for (List<IMEInventoryHandler<T>> invList : priorityInventory.values())
while (i.hasNext())
{ {
List<IMEInventoryHandler<T>> invList = i.next();
Iterator<IMEInventoryHandler<T>> ii = invList.iterator(); Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
while (ii.hasNext() && input != null) while (ii.hasNext() && input != null)
{ {
@ -168,7 +164,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
if ( inv.validForPass( 1 ) && inv.canAccept( input ) if ( inv.validForPass( 1 ) && inv.canAccept( input )
&& (inv.isPrioritized( input ) || inv.extractItems( input, Actionable.SIMULATE, src ) != null) ) && (inv.isPrioritized( input ) || inv.extractItems( input, Actionable.SIMULATE, src ) != null) )
{
input = inv.injectItems( input, type, src ); input = inv.injectItems( input, type, src );
}
} }
ii = invList.iterator(); ii = invList.iterator();
@ -176,7 +174,9 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
{ {
IMEInventoryHandler<T> inv = ii.next(); IMEInventoryHandler<T> inv = ii.next();
if ( inv.validForPass( 2 ) && inv.canAccept( input ) )// ignore crafting on the second pass. if ( inv.validForPass( 2 ) && inv.canAccept( input ) )// ignore crafting on the second pass.
{
input = inv.injectItems( input, type, src ); input = inv.injectItems( input, type, src );
}
} }
} }

View file

@ -79,13 +79,12 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable
if ( slot != null ) if ( slot != null )
{ {
boolean inRecipe = false; boolean inRecipe = false;
Iterator<Object> req = required.iterator();
while (req.hasNext()) for (Object aRequired : required)
{ {
boolean match = false; boolean match = false;
Object next = req.next(); Object next = aRequired;
if ( next instanceof IIngredient ) if ( next instanceof IIngredient )
{ {

View file

@ -399,17 +399,19 @@ public class Platform
if ( cA.size() != cB.size() ) if ( cA.size() != cB.size() )
return false; return false;
Iterator<String> i = cA.iterator(); for (String name : cA)
while (i.hasNext())
{ {
String name = i.next();
NBTBase tag = ctA.getTag( name ); NBTBase tag = ctA.getTag( name );
NBTBase aTag = ctB.getTag( name ); NBTBase aTag = ctB.getTag( name );
if ( aTag == null ) if ( aTag == null )
{
return false; return false;
}
if ( !NBTEqualityTest( tag, aTag ) ) if ( !NBTEqualityTest( tag, aTag ) )
{
return false; return false;
}
} }
return true; return true;
@ -521,10 +523,8 @@ public class Platform
Set<String> cA = ctA.func_150296_c(); Set<String> cA = ctA.func_150296_c();
Iterator<String> i = cA.iterator(); for (String name : cA)
while (i.hasNext())
{ {
String name = i.next();
hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) ); hash += name.hashCode() ^ NBTOrderlessHash( ctA.getTag( name ) );
} }

View file

@ -58,11 +58,9 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
AESharedNBT x = new AESharedNBT( itemID, damageValue ); AESharedNBT x = new AESharedNBT( itemID, damageValue );
// c.getTags() // c.getTags()
Iterator var2 = c.func_150296_c().iterator(); for (Object o : c.func_150296_c())
while (var2.hasNext())
{ {
String name = (String) var2.next(); String name = (String) o;
x.setTag( name, c.getTag( name ).copy() ); x.setTag( name, c.getTag( name ).copy() );
} }

View file

@ -135,9 +135,10 @@ public final class ItemList<StackType extends IAEStack> implements IItemList<Sta
@Override @Override
synchronized public StackType getFirstItem() synchronized public StackType getFirstItem()
{ {
Iterator<StackType> i = this.iterator(); for (StackType stackType : this)
while (i.hasNext()) {
return i.next(); return stackType;
}
return null; return null;
} }