public LinkedList<AssemblyRecipe> getPotentialOutputs() {
    LinkedList<AssemblyRecipe> result = new LinkedList<AssemblyRecipe>();

    for (AssemblyRecipe recipe : AssemblyRecipe.assemblyRecipes) {
      if (recipe.canBeDone(items)) {
        result.add(recipe);
      }
    }

    return result;
  }
  public void setNextCurrentRecipe() {
    boolean takeNext = false;

    for (AssemblyRecipe recipe : plannedOutput) {
      if (recipe == currentRecipe) {
        takeNext = true;
      } else if (takeNext && recipe.canBeDone(items)) {
        setCurrentRecipe(recipe);
        return;
      }
    }

    for (AssemblyRecipe recipe : plannedOutput) {
      if (recipe.canBeDone(items)) {
        setCurrentRecipe(recipe);
        return;
      }
    }

    setCurrentRecipe(null);
  }
  @Override
  public void updateEntity() {
    tick++;
    tick = tick % recentEnergy.length;
    recentEnergy[tick] = 0.0f;

    if (currentRecipe == null) return;

    if (!currentRecipe.canBeDone(items)) {
      setNextCurrentRecipe();

      if (currentRecipe == null) return;
    }

    if (energyStored >= currentRecipe.energy) {
      energyStored = 0;

      if (currentRecipe.canBeDone(items)) {

        for (ItemStack in : currentRecipe.input) {
          if (in == null) {
            continue; // Optimisation, reduces calculation for a null ingredient
          }

          int found = 0; // Amount of ingredient found in inventory

          for (int i = 0; i < items.length; ++i) {
            if (items[i] == null) {
              continue; // Broken out of large if statement, increases clarity
            }

            if (items[i].isItemEqual(in)) {

              int supply = items[i].stackSize;
              int toBeFound = in.stackSize - found;

              if (supply >= toBeFound) {
                found +=
                    decrStackSize(i, toBeFound)
                        .stackSize; // Adds the amount of ingredient taken (in this case the total
                                    // still needed)
              } else {
                found +=
                    decrStackSize(i, supply)
                        .stackSize; // Adds the amount of ingredient taken (in this case the total
                                    // in that slot)
              }
              if (found >= in.stackSize) {
                break; // Breaks out of the for loop when the required amount of ingredient has been
                       // taken
              }
            }
          }
        }

        ItemStack remaining = currentRecipe.output.copy();
        ItemStack added =
            Utils.addToRandomInventory(
                remaining, worldObj, xCoord, yCoord, zCoord, ForgeDirection.UNKNOWN);
        remaining.stackSize -= added.stackSize;

        if (remaining.stackSize > 0) {
          Utils.addToRandomPipeEntry(this, ForgeDirection.UNKNOWN, remaining);
        }

        if (remaining.stackSize > 0) {
          EntityItem entityitem =
              new EntityItem(
                  worldObj, xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, currentRecipe.output.copy());

          worldObj.spawnEntityInWorld(entityitem);
        }

        setNextCurrentRecipe();
      }
    }
  }