Use Collections.addAll

This commit is contained in:
mezz committed 2016-10-20 23:18:49 -07:00
1 parent 57930991ec
commit c6783e573c
12 files changed
+30 -57

No files matched your search

+4 -9
View File
@@ -15,6 +15,7 @@ import net.minecraftforge.fml.relauncher.Side;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
@@ -72,18 +73,12 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
for (final IInitializable module : this.modules) {
module.preInit();
}
for (final Field field : this.getClass().getFields()) {
this.fields.add(field);
}
Collections.addAll(this.fields, this.getClass().getFields());
for (final Class cls : this.getClass().getClasses()) {
for (final Field field2 : this.getClass().getFields()) {
this.fields.add(field2);
}
Collections.addAll(this.fields, this.getClass().getFields());
}
for (final IInitializable module : this.modules) {
for (final Field field3 : module.getClass().getFields()) {
this.fields.add(field3);
}
Collections.addAll(this.fields, module.getClass().getFields());
}
for (final Field field4 : this.fields) {
try {
@@ -13,6 +13,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
@@ -123,13 +124,9 @@ public class MachineUtil {
public boolean hasIngredients(final int[] recipe, final int[] inventory) {
final ItemStackSet requiredStacks = new ItemStackSet();
for (final ItemStack stack : this.getStacks(recipe)) {
requiredStacks.add(stack);
}
Collections.addAll(requiredStacks, this.getStacks(recipe));
final ItemStackSet inventoryStacks = new ItemStackSet();
for (final ItemStack stack2 : this.getStacks(inventory)) {
inventoryStacks.add(stack2);
}
Collections.addAll(inventoryStacks, this.getStacks(inventory));
requiredStacks.removeAll(inventoryStacks);
return requiredStacks.isEmpty();
}
@@ -47,9 +47,7 @@ public class ManagerMachine extends ManagerBase {
}
final Set<Class<?>> interfaces = new HashSet<>();
for (Class<?> currentClass = component; currentClass != null; currentClass = null) {
for (final Class<?> clss : currentClass.getInterfaces()) {
interfaces.add(clss);
}
Collections.addAll(interfaces, currentClass.getInterfaces());
currentClass = currentClass.getSuperclass();
if (currentClass == Object.class) {
}
@@ -16,6 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WindowBotanistDatabase extends WindowAbstractDatabase {
@@ -48,9 +49,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
}
};
final List<IFlowerColour> colors = new ArrayList<>();
for (final IFlowerColour c : EnumFlowerColor.values()) {
colors.add(c);
}
Collections.addAll(colors, EnumFlowerColor.values());
this.listBox.setOptions(colors);
}
});
@@ -6,6 +6,7 @@ import binnie.craftgui.events.EventMouse;
import binnie.craftgui.events.EventValueChanged;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ControlEnumButton<T> extends ControlButton implements IControlValue<T> {
@@ -41,9 +42,7 @@ public class ControlEnumButton<T> extends ControlButton implements IControlValue
public ControlEnumButton(final IWidget parent, final float x, final float y, final float width, final float height, final T[] values) {
super(parent, x, y, width, height, "");
this.enumConstants = new ArrayList<>();
for (final T value : values) {
this.enumConstants.add(value);
}
Collections.addAll(this.enumConstants, values);
if (values.length > 0) {
this.currentSelection = values[0];
}
@@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import java.util.Collections;
public class ControlBreweryProgress extends ControlProgressBase {
static Texture Brewery;
static Texture BreweryOverlay;
@@ -47,9 +49,7 @@ public class ControlBreweryProgress extends ControlProgressBase {
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(17.0f, 22.0f));
GL11.glDisable(3089);
final ItemStackSet stacks = new ItemStackSet();
for (final ItemStack stack : logic.currentCrafting.inputs) {
stacks.add(stack);
}
Collections.addAll(stacks, logic.currentCrafting.inputs);
stacks.add(logic.currentCrafting.ingr);
int x = 1;
int y = 6;
@@ -12,6 +12,7 @@ import net.minecraftforge.common.BiomeDictionary;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class ExtraBeeMutation implements IBeeMutation {
@@ -270,9 +271,7 @@ public class ExtraBeeMutation implements IBeeMutation {
public Collection<String> getSpecialConditions() {
final List<String> conditions = new ArrayList<>();
if (this.req != null) {
for (final String s : this.req.tooltip()) {
conditions.add(s);
}
Collections.addAll(conditions, this.req.tooltip());
}
return conditions;
}
@@ -210,9 +210,7 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromo
public ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products) {
if (this == ExtraBeesFlowers.Mystical) {
final List<ItemStack> prods = new ArrayList<>();
for (final ItemStack stack : products) {
prods.add(stack);
}
Collections.addAll(prods, products);
for (int k = 0; k < 50; ++k) {
final int tX = 7;
final int tY = 7;
@@ -11,6 +11,7 @@ import net.minecraft.world.IBlockAccess;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
public class HiveDrop implements IHiveDrop {
private IAllele[] template;
@@ -28,9 +29,7 @@ public class HiveDrop implements IHiveDrop {
}
this.template = template;
this.chance = chance;
for (final ItemStack stack : bonus) {
this.additional.add(stack);
}
Collections.addAll(this.additional, bonus);
}
@Override
@@ -11,6 +11,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WoodManager {
@@ -92,20 +93,14 @@ public class WoodManager {
public static List<IPlankType> getAllPlankTypes() {
final List<IPlankType> list = new ArrayList<>();
for (final IPlankType type : PlankType.ExtraTreePlanks.values()) {
list.add(type);
}
for (final IPlankType type : PlankType.ForestryPlanks.values()) {
list.add(type);
}
Collections.addAll(list, PlankType.ExtraTreePlanks.values());
Collections.addAll(list, PlankType.ForestryPlanks.values());
for (final IPlankType type : PlankType.ExtraBiomesPlank.values()) {
if (type.getStack() != null) {
list.add(type);
}
}
for (final IPlankType type : PlankType.VanillaPlanks.values()) {
list.add(type);
}
Collections.addAll(list, PlankType.VanillaPlanks.values());
return list;
}
@@ -16,6 +16,7 @@ import forestry.api.arboriculture.IWoodType;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Queue;
@@ -42,13 +43,9 @@ public class ModuleCore implements IInitializable {
speciesQueue.add(s);
}
final Queue<IWoodType> logQueue = new LinkedList<>();
for (final IWoodType wood : EnumExtraTreeLog.values()) {
logQueue.add(wood);
}
Collections.addAll(logQueue, EnumExtraTreeLog.values());
final Queue<IDesignMaterial> plankQueue = new LinkedList<>();
for (final IDesignMaterial wood2 : PlankType.ExtraTreePlanks.values()) {
plankQueue.add(wood2);
}
Collections.addAll(plankQueue, PlankType.ExtraTreePlanks.values());
final Queue<ExtraTreeFruitGene> fruitQueue = new LinkedList<>();
for (final ExtraTreeFruitGene wood3 : ExtraTreeFruitGene.values()) {
fruitQueue.add(wood3);
@@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
public class AnalystPageFruit extends AnalystPageProduce {
public AnalystPageFruit(final IWidget parent, final IArea area, final ITree ind) {
@@ -44,9 +45,7 @@ public class AnalystPageFruit extends AnalystPageProduce {
final FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider();
final Field f = FruitProviderPod.class.getDeclaredField("drop");
f.setAccessible(true);
for (final ItemStack stack2 : (ItemStack[]) f.get(pod)) {
products.add(stack2);
}
Collections.addAll(products, (ItemStack[]) f.get(pod));
}
} catch (Exception e) {
e.printStackTrace();
@@ -115,9 +114,7 @@ public class AnalystPageFruit extends AnalystPageProduce {
final FruitProviderPod pod2 = (FruitProviderPod) ((IAlleleFruit) a).getProvider();
final Field field = FruitProviderPod.class.getDeclaredField("drop");
field.setAccessible(true);
for (final ItemStack stack4 : (ItemStack[]) field.get(pod2)) {
stacks.add(stack4);
}
Collections.addAll(stacks, (ItemStack[]) field.get(pod2));
}
} catch (Exception ex) {
}