mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Java5 cleanup
- Replace for loops with foreach - Remove unnecessary boxing
This commit is contained in:
1 parent
6721909e84
commit
3db03edbc9
6 files changed
+50
-41
No files matched your search
@@ -929,22 +929,20 @@ public class Mekanism
|
||||
if(event.getChunk() != null && !event.getWorld().isRemote)
|
||||
{
|
||||
Map copy = (Map)((HashMap)event.getChunk().getTileEntityMap()).clone();
|
||||
|
||||
for(Iterator iter = copy.values().iterator(); iter.hasNext();)
|
||||
|
||||
for (Object obj : copy.values())
|
||||
{
|
||||
Object obj = iter.next();
|
||||
|
||||
if(obj instanceof TileEntity)
|
||||
if (obj instanceof TileEntity)
|
||||
{
|
||||
TileEntity tileEntity = (TileEntity)obj;
|
||||
|
||||
if(tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2())
|
||||
TileEntity tileEntity = (TileEntity) obj;
|
||||
|
||||
if (tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2())
|
||||
{
|
||||
((TileEntityElectricBlock)tileEntity).register();
|
||||
((TileEntityElectricBlock) tileEntity).register();
|
||||
}
|
||||
else if(tileEntity instanceof IChunkLoadHandler)
|
||||
else if (tileEntity instanceof IChunkLoadHandler)
|
||||
{
|
||||
((IChunkLoadHandler)tileEntity).onChunkLoad();
|
||||
((IChunkLoadHandler) tileEntity).onChunkLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,11 +151,25 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
|
||||
|
||||
if(ticksExisted == 1)
|
||||
{
|
||||
dataManager.set(IS_LATCHED, new Byte(latched != null ? (byte)1 : (latchedEntity != null ? (byte)2 : (byte)0)));
|
||||
dataManager.set(LATCHED_X, new Integer(latched != null ? latched.x : 0));
|
||||
dataManager.set(LATCHED_Y, new Integer(latched != null ? latched.y : 0));
|
||||
dataManager.set(LATCHED_Z, new Integer(latched != null ? latched.z : 0));
|
||||
dataManager.set(LATCHED_ID, new Integer(latchedEntity != null ? latchedEntity.getEntityId() : -1));
|
||||
byte isLatched;
|
||||
if (latched != null)
|
||||
{
|
||||
isLatched = (byte) 1;
|
||||
}
|
||||
else if (latchedEntity != null)
|
||||
{
|
||||
isLatched = (byte) 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
isLatched = (byte) 0;
|
||||
}
|
||||
|
||||
dataManager.set(IS_LATCHED, isLatched);
|
||||
dataManager.set(LATCHED_X, latched != null ? latched.x : 0);
|
||||
dataManager.set(LATCHED_Y, latched != null ? latched.y : 0);
|
||||
dataManager.set(LATCHED_Z, latched != null ? latched.z : 0);
|
||||
dataManager.set(LATCHED_ID, latchedEntity != null ? latchedEntity.getEntityId() : -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -317,31 +317,30 @@ public final class OreDictManager
|
||||
}
|
||||
|
||||
List<ItemStack> registeredOres = OreDictionary.getOres("logWood");
|
||||
|
||||
for(int i = 0; i < registeredOres.size(); i++)
|
||||
{
|
||||
ItemStack logEntry = registeredOres.get(i);
|
||||
|
||||
if(logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
for (ItemStack logEntry : registeredOres)
|
||||
{
|
||||
if (logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
ItemStack log = new ItemStack(logEntry.getItem(), 1, j);
|
||||
tempCrafting.setInventorySlotContents(0, log);
|
||||
ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);
|
||||
|
||||
if(!resultEntry.isEmpty())
|
||||
if (!resultEntry.isEmpty())
|
||||
{
|
||||
RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ItemStack log = StackUtils.size(logEntry, 1);
|
||||
tempCrafting.setInventorySlotContents(0, log);
|
||||
ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);
|
||||
|
||||
if(!resultEntry.isEmpty())
|
||||
if (!resultEntry.isEmpty())
|
||||
{
|
||||
RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1);
|
||||
}
|
||||
|
||||
@@ -64,21 +64,21 @@ public class ContainerRobitSmelting extends Container
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for(int i = 0; i < listeners.size(); ++i)
|
||||
for (IContainerListener listener : listeners)
|
||||
{
|
||||
IContainerListener icrafting = (IContainerListener)listeners.get(i);
|
||||
IContainerListener icrafting = listener;
|
||||
|
||||
if(lastCookTime != robit.furnaceCookTime)
|
||||
if (lastCookTime != robit.furnaceCookTime)
|
||||
{
|
||||
icrafting.sendWindowProperty(this, 0, robit.furnaceCookTime);
|
||||
}
|
||||
|
||||
if(lastBurnTime != robit.furnaceBurnTime)
|
||||
if (lastBurnTime != robit.furnaceBurnTime)
|
||||
{
|
||||
icrafting.sendWindowProperty(this, 1, robit.furnaceBurnTime);
|
||||
}
|
||||
|
||||
if(lastItemBurnTime != robit.currentItemBurnTime)
|
||||
if (lastItemBurnTime != robit.currentItemBurnTime)
|
||||
{
|
||||
icrafting.sendWindowProperty(this, 2, robit.currentItemBurnTime);
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ public final class RecipeHandler
|
||||
public static void removeRecipe(Recipe recipeMap, MachineRecipe recipe)
|
||||
{
|
||||
List<MachineInput> toRemove = new ArrayList<>();
|
||||
|
||||
for(Iterator iter = recipeMap.get().keySet().iterator(); iter.hasNext();)
|
||||
|
||||
for (Object o : recipeMap.get().keySet())
|
||||
{
|
||||
MachineInput iterInput = (MachineInput)iter.next();
|
||||
|
||||
if(iterInput.testEquality(recipe.getInput()))
|
||||
MachineInput iterInput = (MachineInput) o;
|
||||
|
||||
if (iterInput.testEquality(recipe.getInput()))
|
||||
{
|
||||
toRemove.add(iterInput);
|
||||
}
|
||||
|
||||
@@ -95,12 +95,10 @@ public final class PipeUtils
|
||||
|
||||
List<IFluidHandler> availableAcceptors = new ArrayList<IFluidHandler>();
|
||||
IFluidHandler[] possibleAcceptors = getConnectedAcceptors(from);
|
||||
|
||||
for(int i = 0; i < possibleAcceptors.length; i++)
|
||||
|
||||
for (IFluidHandler handler : possibleAcceptors)
|
||||
{
|
||||
IFluidHandler handler = possibleAcceptors[i];
|
||||
|
||||
if(handler != null && canFill(handler, stack))
|
||||
if (handler != null && canFill(handler, stack))
|
||||
{
|
||||
availableAcceptors.add(handler);
|
||||
}
|
||||
@@ -168,4 +166,4 @@ public final class PipeUtils
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user