Example #1
0
 public float getMultiplierForInput(ItemStack input, Fluid output) {
   if (output != null) {
     for (IRecipe recipe : recipes) {
       RecipeOutput out = recipe.getOutputs()[0];
       if (out.getFluidOutput().getFluid().getID() == output.getID()) {
         for (RecipeInput ri : recipe.getInputs()) {
           if (ri.isInput(input)) {
             return ri.getMulitplier();
           }
         }
       }
     }
   }
   // no fluid or not an input for this fluid: best guess
   // (after all, the item IS in the input slot)
   float found = -1f;
   for (IRecipe recipe : recipes) {
     for (RecipeInput ri : recipe.getInputs()) {
       if (ri.isInput(input)) {
         if (found < 0f || found > ri.getMulitplier()) {
           found = ri.getMulitplier();
         }
       }
     }
   }
   return found > 0 ? found : 0;
 }
Example #2
0
 public boolean isValidInput(MachineRecipeInput input) {
   for (IRecipe recipe : recipes) {
     if (input.item != null && recipe.isValidInput(input.slotNumber, input.item)) {
       return true;
     } else if (input.fluid != null && recipe.isValidInput(input.fluid)) {
       return true;
     }
   }
   return false;
 }
Example #3
0
 public IRecipe getRecipeForInput(MachineRecipeInput[] inputs) {
   if (inputs == null || inputs.length == 0) {
     return null;
   }
   for (IRecipe recipe : recipes) {
     if (recipe.isInputForRecipe(inputs)) {
       return recipe;
     }
   }
   return null;
 }
Example #4
0
 public void addRecipe(IRecipe recipe) {
   if (recipe == null || !recipe.isValid()) {
     Log.debug("Could not add invalid Vat recipe: " + recipe);
     return;
   }
   recipes.add(new VatRecipe(recipe));
 }
Example #5
0
 public boolean isValidInput(MachineRecipeInput[] inputs) {
   for (IRecipe recipe : recipes) {
     boolean allValid = true;
     for (MachineRecipeInput input : inputs) {
       if (input.item != null) {
         allValid = recipe.isValidInput(input.slotNumber, input.item);
       } else if (input.fluid != null) {
         allValid = recipe.isValidInput(input.fluid);
       }
       if (!allValid) {
         break;
       }
     }
     if (allValid) {
       return true;
     }
   }
   return false;
 }
  @Override
  public List<IEnderIoRecipe> getAllRecipes() {
    List<IEnderIoRecipe> result = new ArrayList<IEnderIoRecipe>();
    List<IAlloyRecipe> recipes = AlloyRecipeManager.getInstance().getRecipes();
    for (IRecipe cr : recipes) {
      List<IRecipeComponent> components = new ArrayList<IRecipeComponent>();
      for (crazypants.enderio.machine.recipe.RecipeInput ri : cr.getInputs()) {
        if (ri.getInput() != null) {
          IRecipeInput input = new RecipeInput(ri.getInput(), -1, ri.getEquivelentInputs());
          components.add(input);
        }
      }

      for (RecipeOutput co : cr.getOutputs()) {
        IRecipeOutput output =
            new crazypants.enderio.crafting.impl.RecipeOutput(co.getOutput(), co.getChance());
        components.add(output);
      }
      result.add(
          new EnderIoRecipe(IEnderIoRecipe.ALLOY_SMELTER_ID, cr.getEnergyRequired(), components));
    }
    return result;
  }