quick fixes : enhanced for loop

This commit is contained in:
Alexdoru authored and Jason Mitchell committed 2023-01-28 18:02:41 -08:00
1 parent 59f3b5b72a
commit 83f54f1e97
33 files changed
+74 -96

No files matched your search

@@ -248,7 +248,7 @@ public class ArmorExtended implements IInventory {
public void closeInventory() {}
public void writeInventoryToStream(ByteBuf os) {
for (int i = 0; i < inventory.length; i++) ByteBufUtils.writeItemStack(os, inventory[i]);
for (ItemStack itemStack : inventory) ByteBufUtils.writeItemStack(os, itemStack);
}
public void readInventoryFromStream(ByteBuf is) {
@@ -47,9 +47,7 @@ public class TabRegistry {
public static void updateTabValues(int cornerX, int cornerY, Class<?> selectedButton) {
int count = 2;
for (int i = 0; i < tabList.size(); i++) {
AbstractTab t = tabList.get(i);
for (AbstractTab t : tabList) {
if (t.shouldAddToList()) {
t.id = count;
t.xPosition = cornerX + (count - 2) * 28;
@@ -109,8 +109,8 @@ public class Mattock extends DualHarvestTool {
private boolean allowCrafting(int head) {
int[] nonMetals = {0, 1, 3, 4, 5, 6, 7, 8, 9, 17};
for (int i = 0; i < nonMetals.length; i++) {
if (head == nonMetals[i]) return false;
for (int nonMetal : nonMetals) {
if (head == nonMetal) return false;
}
return true;
}
@@ -156,13 +156,13 @@ public class Scythe extends Weapon {
!= null) // && (block.blockMaterial == Material.leaves || block.isLeaves(world,
// xPos, yPos, zPos)))
{
for (int iter = 0; iter < materials.length; iter++) {
if (materials[iter] == localBlock.getMaterial()) {
for (Material material : materials) {
if (material == localBlock.getMaterial()) {
if (!player.capabilities.isCreativeMode) {
if (butter
&& localBlock instanceof IShearable
&& ((IShearable) localBlock)
.isShearable(stack, player.worldObj, xPos, yPos, zPos)) {
.isShearable(stack, player.worldObj, xPos, yPos, zPos)) {
ArrayList<ItemStack> drops = ((IShearable) localBlock)
.onSheared(
stack,
@@ -12,8 +12,8 @@ public abstract class ArmorModTypeFilter extends ArmorMod {
assert items.length == values.length
: "Itemstacks and their values for armor modifiers must be the same length";
this.increase = new ArrayList<>();
for (int i = 0; i < values.length; i++) {
increase.add(values[i]);
for (int value : values) {
increase.add(value);
}
}
@@ -63,9 +63,8 @@ public class MultiFluidTank extends LogicComponent implements IFluidTank {
if (doFill) {
if (addFluidToTank(resource, false)) {
ArrayList alloys = Smeltery.mixMetals(fluidlist);
for (int al = 0; al < alloys.size(); al++) {
FluidStack liquid = (FluidStack) alloys.get(al);
ArrayList<FluidStack> alloys = Smeltery.mixMetals(fluidlist);
for (FluidStack liquid : alloys) {
addFluidToTank(liquid, true);
}
}
@@ -208,8 +208,8 @@ public class TankLayerScan extends LogicComponent {
protected boolean isValidBlock(int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if (block != null) {
for (int i = 0; i < scanBlocks.length; i++) {
if (block == scanBlocks[i]) return true;
for (Block scanBlock : scanBlocks) {
if (block == scanBlock) return true;
}
}
return false;
@@ -46,12 +46,8 @@ public class Detailing {
}
public void addShapelessToolRecipe(ItemStack par1ItemStack, Object... par2ArrayOfObj) {
ArrayList arraylist = new ArrayList();
int i = par2ArrayOfObj.length;
for (int j = 0; j < i; ++j) {
Object object1 = par2ArrayOfObj[j];
ArrayList<ItemStack> arraylist = new ArrayList<>();
for (Object object1 : par2ArrayOfObj) {
if (object1 instanceof ItemStack) {
arraylist.add(((ItemStack) object1).copy());
} else if (object1 instanceof Item) {
@@ -64,13 +60,11 @@ public class Detailing {
arraylist.add(new ItemStack((Block) object1));
}
}
GameRegistry.addRecipe(new ShapelessToolRecipe(par1ItemStack, arraylist));
}
public DetailInput getDetailing(Block block, int inputMeta) {
for (int i = 0; i < detailing.size(); i++) {
DetailInput detail = detailing.get(i);
for (DetailInput detail : detailing) {
if (Item.getItemFromBlock(block) == detail.input.getItem() && inputMeta == detail.inputMeta) {
return detail;
}
@@ -34,16 +34,14 @@ public abstract class ItemModifier {
ArrayList<ItemStack> list = new ArrayList<>(this.stacks);
for (int iter = 0; iter < recipe.length; ++iter) {
ItemStack craftingStack = recipe[iter];
for (ItemStack craftingStack : recipe) {
if (craftingStack != null) {
boolean canCraft = false;
for (ItemStack removeStack : list) {
if (craftingStack.getItem() == removeStack.getItem()
&& (removeStack.getItemDamage() == Short.MAX_VALUE
|| craftingStack.getItemDamage() == removeStack.getItemDamage())) {
|| craftingStack.getItemDamage() == removeStack.getItemDamage())) {
canCraft = true;
list.remove(removeStack);
break;
@@ -37,16 +37,16 @@ public abstract class DualHarvestTool extends HarvestTool {
if (tags.getBoolean("Broken")) return 0.1f;
Material[] materials = getEffectiveMaterials();
for (int i = 0; i < materials.length; i++) {
if (materials[i] == block.getMaterial()) {
for (Material value : materials) {
if (value == block.getMaterial()) {
if (block.getHarvestLevel(meta) <= tags.getInteger("HarvestLevel"))
return AbilityHelper.calcDualToolSpeed(this, tags, false);
return 0.1f;
}
}
materials = getEffectiveSecondaryMaterials();
for (int i = 0; i < materials.length; i++) {
if (materials[i] == block.getMaterial()) {
for (Material material : materials) {
if (material == block.getMaterial()) {
if (block.getHarvestLevel(meta) <= tags.getInteger("HarvestLevel2"))
return AbilityHelper.calcDualToolSpeed(this, tags, true);
return 0.1f;
@@ -40,8 +40,8 @@ public abstract class Weapon extends ToolCore
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) return 0.1f;
for (int i = 0; i < web.length; i++) {
if (web[i] == block.getMaterial()) {
for (Material material : web) {
if (material == block.getMaterial()) {
return effectiveSpeed();
}
}
@@ -95,8 +95,8 @@ public abstract class Weapon extends ToolCore
*/
@Override
public boolean canHarvestBlock(Block block, ItemStack is) {
for (int i = 0; i < web.length; i++) {
if (block.getMaterial() == web[i]) return true;
for (Material material : web) {
if (block.getMaterial() == material) return true;
}
return super.canHarvestBlock(block, is);
}
@@ -11,8 +11,8 @@ public abstract class ItemModTypeFilter extends ItemModifier {
super(items, effect, dataKey);
assert items.length == values.length : "Itemstacks and their values for tool modifiers must be the same length";
this.increase = new ArrayList<>();
for (int i = 0; i < values.length; i++) {
increase.add(values[i]);
for (int value : values) {
increase.add(value);
}
}
@@ -121,8 +121,7 @@ public class RecipeHandlerAlloying extends RecipeHandlerBase {
@Override
public void loadUsageRecipes(FluidStack ingredient) {
for (Iterator<AlloyMix> i = Smeltery.getAlloyList().iterator(); i.hasNext(); ) {
AlloyMix recipe = i.next();
for (AlloyMix recipe : Smeltery.getAlloyList()) {
for (FluidStack liquid : recipe.mixers) {
if (areFluidsEqual(liquid, ingredient) && !recipe.mixers.isEmpty()) {
this.arecipes.add(new CachedAlloyingRecipe(recipe));
@@ -34,8 +34,7 @@ public class SmelteryDataProvider implements IWailaDataProvider {
if (fls.size() <= 0) {
currenttip.add(SpecialChars.ITALIC + StatCollector.translateToLocal("tconstruct.waila.empty"));
} else {
for (int i = 0; i < fls.size(); i++) {
FluidStack st = fls.get(i);
for (FluidStack st : fls) {
currenttip.add(WailaRegistrar.fluidNameHelper(st) + " (" + st.amount + "mB)");
}
}
@@ -1138,18 +1138,18 @@ public class TinkerSmeltery {
new ItemStack(TinkerTools.materials, 1, 2),
new ItemStack(TinkerTools.materials, 1, 37)
};
for (int i = 0; i < ingotShapes.length; i++) {
for (ItemStack ingotShape : ingotShapes) {
tableCasting.addCastingRecipe(
ingotcast,
new FluidStack(TinkerSmeltery.moltenAlubrassFluid, TConstruct.ingotLiquidValue),
ingotShapes[i],
ingotShape,
false,
50);
if (!PHConstruct.removeGoldCastRecipes)
tableCasting.addCastingRecipe(
ingotcast,
new FluidStack(TinkerSmeltery.moltenGoldFluid, TConstruct.ingotLiquidValue * 2),
ingotShapes[i],
ingotShape,
false,
50);
}
@@ -385,16 +385,13 @@ public class SmelteryGui extends ActiveContainerGui {
private boolean isMolten(String fluidName) {
boolean molten = false;
String[] moltenNames =
StatCollector.translateToLocal("gui.smeltery.molten.check").split(",");
for (int i = 0; i < moltenNames.length; i++) {
if (fluidName.contains(moltenNames[i].trim())) {
String[] moltenNames = StatCollector.translateToLocal("gui.smeltery.molten.check").split(",");
for (String moltenName : moltenNames) {
if (fluidName.contains(moltenName.trim())) {
molten = true;
break;
}
}
return molten;
}
@@ -423,9 +423,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
if (addMoltenMetal(result, false)) {
inventory[i] = null;
activeTemps[i] = 200;
ArrayList alloys = Smeltery.mixMetals(moltenMetal);
for (int al = 0; al < alloys.size(); al++) {
FluidStack liquid = (FluidStack) alloys.get(al);
ArrayList<FluidStack> alloys = Smeltery.mixMetals(moltenMetal);
for (FluidStack liquid : alloys) {
addMoltenMetal(liquid, true);
}
markDirty();
@@ -962,9 +961,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
if (amount > 0 && doFill) {
if (addMoltenMetal(resource, false)) {
ArrayList alloys = Smeltery.mixMetals(moltenMetal);
for (int al = 0; al < alloys.size(); al++) {
FluidStack liquid = (FluidStack) alloys.get(al);
ArrayList<FluidStack> alloys = Smeltery.mixMetals(moltenMetal);
for (FluidStack liquid : alloys) {
addMoltenMetal(liquid, true);
}
}
@@ -150,8 +150,8 @@ public class TinkerToolEvents {
private boolean allowCrafting(int head, int handle, int accessory) {
int[] nonMetals = {0, 1, 3, 4, 5, 6, 7, 8, 9, 17};
for (int i = 0; i < nonMetals.length; i++) {
if (head == nonMetals[i] || handle == nonMetals[i] || accessory == nonMetals[i]) return false;
for (int nonMetal : nonMetals) {
if (head == nonMetal || handle == nonMetal || accessory == nonMetal) return false;
}
return true;
}
@@ -635,14 +635,14 @@ public class TinkerTools {
}
}
} else {
for (int mat = 0; mat < nonMetals.length; mat++) {
for (int nonMetal : nonMetals) {
for (int meta = 0; meta < TinkerTools.patternOutputs.length; meta++) {
if (TinkerTools.patternOutputs[meta] != null)
TConstructRegistry.addPartMapping(
TinkerTools.woodPattern,
meta + 1,
nonMetals[mat],
new ItemStack(TinkerTools.patternOutputs[meta], 1, nonMetals[mat]));
nonMetal,
new ItemStack(TinkerTools.patternOutputs[meta], 1, nonMetal));
}
}
}
@@ -186,11 +186,10 @@ public class RotatingBase extends Entity implements IEntityAdditionalSpawnData {
movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(
this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int j = 0; j < list.size(); j++) {
Entity entity1 = (Entity) list.get(j);
for (Entity entity1 : list) {
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) {
continue;
}
@@ -37,8 +37,8 @@ public class FrypanContainer extends Container {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < crafters.size(); i++) {
ICrafting icrafting = (ICrafting) crafters.get(i);
for (Object crafter : crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (progress != logic.progress) {
icrafting.sendProgressBarUpdate(this, 0, logic.progress);
}
@@ -47,8 +47,8 @@ public class FurnaceContainer extends Container {
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); ++i) {
ICrafting icrafting = (ICrafting) this.crafters.get(i);
for (Object crafter : this.crafters) {
ICrafting icrafting = (ICrafting) crafter;
if (this.lastCookTime != this.furnace.progress) {
icrafting.sendProgressBarUpdate(this, 0, this.furnace.progress);
@@ -36,7 +36,9 @@ public class PartCrafterChestContainer extends ActiveContainer {
new SlotOnlyTake(partLogic, 6, 218, 45),
new SlotOnlyTake(partLogic, 7, 236, 45)
};
for (int iter = 0; iter < inventory.length; iter++) this.addSlotToContainer(inventory[iter]);
for (Slot slot : inventory) {
this.addSlotToContainer(slot);
}
/* Holder inventory */
for (int column = 0; column < 5; column++) {
@@ -32,7 +32,9 @@ public class PartCrafterContainer extends ActiveContainer {
new SlotOnlyTake(partLogic, 6, 102, 45),
new SlotOnlyTake(partLogic, 7, 120, 45)
};
for (int iter = 0; iter < inventory.length; iter++) this.addSlotToContainer(inventory[iter]);
for (Slot slot : inventory) {
this.addSlotToContainer(slot);
}
/* Player inventory */
for (int column = 0; column < 3; column++) {
@@ -122,8 +122,8 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
// we only allow renaming with a nametag otherwise
else if (!("\u00A7f" + name).equals(display.getString("Name")) && !name.equals(display.getString("Name"))) {
int nametagCount = 0;
for (int i = 0; i < inventory.length; i++)
if (inventory[i] != null && inventory[i].getItem() == Items.name_tag) nametagCount++;
for (ItemStack itemStack : inventory)
if (itemStack != null && itemStack.getItem() == Items.name_tag) nametagCount++;
doRename = nametagCount == 1;
}
@@ -59,9 +59,7 @@ public class CraftingRecipeHelper {
if (objArray[var4] instanceof String[]) {
String[] var7 = ((String[]) objArray[var4++]);
for (int var8 = 0; var8 < var7.length; ++var8) {
String var9 = var7[var8];
for (String var9 : var7) {
++var6;
var5 = var9.length();
var3.append(var9);
@@ -36,8 +36,8 @@ public class DimensionBlacklist {
if (PHConstruct.slimeIslGenDim0Only) {
return false;
}
for (int len = 0; len < blacklistedDims.size(); len++) {
if (blacklistedDims.get(len) == dim) return false;
for (Integer blacklistedDim : blacklistedDims) {
if (blacklistedDim == dim) return false;
}
return true;
}
@@ -233,12 +233,10 @@ public class Crossbow extends ProjectileWeapon {
ItemStack[] inventory = player.inventory.mainInventory;
// check hotbar for tinker arrows
for (int i = 0; i < inventory.length; i++) {
ItemStack stack = inventory[i];
for (ItemStack stack : inventory) {
if (stack == null) continue;
if (!(stack.getItem() instanceof BoltAmmo)) continue;
if (((IAmmo) stack.getItem()).getAmmoCount(stack) <= 0) continue;
return stack;
}
@@ -90,12 +90,11 @@ public class MiningExplosion extends Explosion {
int l1 = MathHelper.floor_double(this.explosionY + (double) this.explosionSize + 1.0D);
int i2 = MathHelper.floor_double(this.explosionZ - (double) this.explosionSize - 1.0D);
int j2 = MathHelper.floor_double(this.explosionZ + (double) this.explosionSize + 1.0D);
List list = this.world.getEntitiesWithinAABBExcludingEntity(
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(
this.exploder, AxisAlignedBB.getBoundingBox(i, k, i2, j, l1, j2));
Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ);
for (int k2 = 0; k2 < list.size(); ++k2) {
Entity entity = (Entity) list.get(k2);
for (Entity entity : list) {
double d7 =
entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double) this.explosionSize;
@@ -965,10 +965,10 @@ public class TinkerWorld {
TinkerTools.chiselHead
};
for (int partIter = 0; partIter < partTypes.length; partIter++) {
for (int typeIter = 0; typeIter < validTypes.length; typeIter++) {
for (Item partType : partTypes) {
for (int validType : validTypes) {
TinkerWorld.tinkerHouseChest.addItem(new WeightedRandomChestContent(
new ItemStack(partTypes[partIter], 1, validTypes[typeIter]), 1, 1, 15));
new ItemStack(partType, 1, validType), 1, 1, 15));
}
}
@@ -403,12 +403,10 @@ public class CartEntity extends Entity implements IInventory, IEntityAdditionalS
AxisAlignedBB box = boundingBox.expand(0.2D, 0.0D, 0.2D);
List var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box);
List<Entity> var15 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box);
if (var15 != null && !var15.isEmpty()) {
for (int var52 = 0; var52 < var15.size(); ++var52) {
Entity var17 = (Entity) var15.get(var52);
for (Entity var17 : var15) {
if (var17 != this.riddenByEntity && var17.canBePushed() && var17 instanceof CartEntity) {
var17.applyEntityCollision(this);
}
@@ -84,8 +84,8 @@ public class OreberryBushGen extends WorldGenerator {
|| (block != Blocks.end_portal_frame && !world.getBlock(x, y, z).func_149730_j()))
world.setBlock(x, y, z, this.blockB, metadata, 2);
else {
for (int iter = 0; iter < replaceBlocks.length; iter++) {
if (world.getBlock(x, y, z).isReplaceableOreGen(world, x, y, z, replaceBlocks[iter])) {
for (Block replaceBlock : replaceBlocks) {
if (world.getBlock(x, y, z).isReplaceableOreGen(world, x, y, z, replaceBlock)) {
world.setBlock(x, y, z, this.blockB, metadata, 2);
break;
}
@@ -116,9 +116,9 @@ public class SurfaceOreGen extends WorldGenerator {
|| !world.getBlock(k2, l2, i3).isOpaqueCube())
world.setBlock(k2, l2, i3, this.minableBlock, minableBlockMeta, 2);
else {
for (int iter = 0; iter < replaceBlocks.length; iter++) {
for (Block replaceBlock : replaceBlocks) {
if (world.getBlock(k2, l2, i3)
.isReplaceableOreGen(world, k2, l2, i3, replaceBlocks[iter])) {
.isReplaceableOreGen(world, k2, l2, i3, replaceBlock)) {
world.setBlock(k2, l2, i3, this.minableBlock, minableBlockMeta, 2);
break;
}