From 4f740be088ea6193f232ea3002502ef52bb360cc Mon Sep 17 00:00:00 2001 From: Player Date: Wed, 19 Jun 2013 10:27:43 +0200 Subject: [PATCH] Assembly Table: prevent planning recipies multiple times --- .../buildcraft/silicon/TileAssemblyTable.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index 5091b44b..c7b4e5be 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -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 plannedOutput = new LinkedList(); + LinkedHashSet plannedOutput = new LinkedHashSet(); 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()); } }