Assembly Table: prevent planning recipies multiple times

This commit is contained in:
Player 2013-06-19 10:27:43 +02:00
parent acae574f26
commit 4f740be088

View file

@ -1,6 +1,8 @@
package buildcraft.silicon;
import buildcraft.api.gates.IAction;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import cpw.mods.fml.common.FMLCommonHandler;
@ -28,7 +30,7 @@ import buildcraft.core.utils.Utils;
public class TileAssemblyTable extends TileEntity implements IMachine, IInventory, IPipeConnection, ILaserTarget {
ItemStack[] items = new ItemStack[12];
LinkedList<AssemblyRecipe> plannedOutput = new LinkedList<AssemblyRecipe>();
LinkedHashSet<AssemblyRecipe> plannedOutput = new LinkedHashSet<AssemblyRecipe>();
public AssemblyRecipe currentRecipe;
private float currentRequiredEnergy = 0;
private float energyStored = 0;
@ -237,6 +239,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
plannedOutput.add(r);
break;
}
}
}
@ -278,20 +281,11 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
}
}
public void cleanPlannedOutput() {
plannedOutput.clear();
}
public boolean isPlanned(AssemblyRecipe recipe) {
if (recipe == null)
return false;
for (AssemblyRecipe r : plannedOutput) {
if (r == recipe)
return true;
}
return false;
return plannedOutput.contains(recipe);
}
public boolean isAssembling(AssemblyRecipe recipe) {
@ -324,8 +318,8 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
plannedOutput.remove(recipe);
if (plannedOutput.size() != 0) {
setCurrentRecipe(plannedOutput.getFirst());
if (!plannedOutput.isEmpty()) {
setCurrentRecipe(plannedOutput.iterator().next());
}
}