Search in sources :

Example 1 with RecipeOutput

use of crazypants.enderio.base.recipe.RecipeOutput in project EnderIO by SleepyTrousers.

the class RecipeWrapper method getIngredients.

@Override
public void getIngredients(@Nonnull IIngredients ingredients) {
    List<List<ItemStack>> inputStacks = recipe.getInputStackAlternatives();
    ingredients.setInputLists(ItemStack.class, inputStacks);
    List<ItemStack> outputs = new ArrayList<ItemStack>();
    for (RecipeOutput out : recipe.getOutputs()) {
        if (Prep.isValid(out.getOutput())) {
            outputs.add(out.getOutput());
        }
    }
    ingredients.setOutputs(ItemStack.class, outputs);
    List<FluidStack> inputFluidStacks = recipe.getInputFluidStacks();
    if (inputFluidStacks != null) {
        ingredients.setInputs(FluidStack.class, inputFluidStacks);
    }
    List<FluidStack> fluidOutputs = new ArrayList<FluidStack>();
    for (RecipeOutput out : recipe.getOutputs()) {
        if (out.getFluidOutput() != null) {
            fluidOutputs.add(out.getFluidOutput());
        }
    }
    ingredients.setOutputs(FluidStack.class, fluidOutputs);
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with RecipeOutput

use of crazypants.enderio.base.recipe.RecipeOutput in project EnderIO by SleepyTrousers.

the class Sagmilling method register.

@Override
public void register(@Nonnull String recipeName) {
    if (isValid() && isActive()) {
        ThingsRecipeInput recipeInput = new ThingsRecipeInput(input.getThing());
        NNList<RecipeOutput> recipeOutputs = new NNList<>();
        for (Output output : getOutputs()) {
            if (output instanceof OutputWithChance) {
                recipeOutputs.add(new RecipeOutput(output.getItemStack(), ((OutputWithChance) output).getChance()));
            } else {
                recipeOutputs.add(new RecipeOutput(output.getItemStack(), 1));
            }
        }
        Recipe recipe = new Recipe(recipeInput, energy, bonus, recipeOutputs.toArray(new RecipeOutput[0]));
        SagMillRecipeManager.getInstance().addRecipe(recipe);
    }
}
Also used : Recipe(crazypants.enderio.base.recipe.Recipe) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput) NNList(com.enderio.core.common.util.NNList) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput) ThingsRecipeInput(crazypants.enderio.base.recipe.ThingsRecipeInput)

Example 3 with RecipeOutput

use of crazypants.enderio.base.recipe.RecipeOutput in project EnderIO by SleepyTrousers.

the class VanillaSmeltingRecipe method getAllRecipes.

public List<IRecipe> getAllRecipes() {
    List<IRecipe> result = new ArrayList<IRecipe>();
    Map<ItemStack, ItemStack> metaList = FurnaceRecipes.instance().getSmeltingList();
    for (Entry<ItemStack, ItemStack> entry : metaList.entrySet()) {
        ItemStack output = entry.getValue();
        int stackSize = output.getCount();
        output.setCount(stackSize);
        final ItemStack key = NullHelper.notnullM(entry.getKey(), "null item stack in furnace recipes");
        result.add(new Recipe(new RecipeInput(key), RF_PER_ITEM, RecipeBonusType.NONE, new RecipeOutput(output)));
    }
    return result;
}
Also used : IRecipe(crazypants.enderio.base.recipe.IRecipe) IMachineRecipe(crazypants.enderio.base.recipe.IMachineRecipe) Recipe(crazypants.enderio.base.recipe.Recipe) IRecipe(crazypants.enderio.base.recipe.IRecipe) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) RecipeInput(crazypants.enderio.base.recipe.RecipeInput) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with RecipeOutput

use of crazypants.enderio.base.recipe.RecipeOutput in project EnderIO by SleepyTrousers.

the class VatRecipeManager method getMultiplierForInput.

public float getMultiplierForInput(Fluid inputFluid, @Nonnull ItemStack input, Fluid output) {
    if (Prep.isValid(input) || output != null) {
        for (IRecipe recipe : recipes) {
            RecipeOutput out = recipe.getOutputs()[0];
            IRecipeInput in = recipe.getInputs()[recipe.getInputs().length - 1];
            final FluidStack fluidOutput = out.getFluidOutput();
            if ((inputFluid == null || FluidUtil.areFluidsTheSame(in.getFluidInput().getFluid(), inputFluid) && (output == null || (fluidOutput != null && FluidUtil.areFluidsTheSame(fluidOutput.getFluid(), output))))) {
                for (IRecipeInput 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 (IRecipeInput ri : recipe.getInputs()) {
            if (ri.isInput(input)) {
                if (found < 0f || found > ri.getMulitplier()) {
                    found = ri.getMulitplier();
                }
            }
        }
    }
    return found > 0 ? found : 0;
}
Also used : IRecipeInput(crazypants.enderio.base.recipe.IRecipeInput) IRecipe(crazypants.enderio.base.recipe.IRecipe) FluidStack(net.minecraftforge.fluids.FluidStack) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput)

Example 5 with RecipeOutput

use of crazypants.enderio.base.recipe.RecipeOutput in project EnderIO by SleepyTrousers.

the class SagMillRecipeCategory method setRecipe.

@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull SagRecipe recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    guiItemStacks.addTooltipCallback(this);
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiItemStacks.init(0, true, 79 - xOff, 11 - yOff);
    guiItemStacks.init(1, false, 48 - xOff, 58 - yOff);
    guiItemStacks.init(2, false, 69 - xOff, 58 - yOff);
    guiItemStacks.init(3, false, 90 - xOff, 58 - yOff);
    guiItemStacks.init(4, false, 111 - xOff, 58 - yOff);
    guiItemStacks.init(5, true, 121 - xOff, 22 - yOff);
    group.init(6, true, EnergyIngredientRenderer.INSTANCE, 134 - xOff, 58 - yOff, 60, 10, 0, 0);
    guiItemStacks.addTooltipCallback(new ITooltipCallback<ItemStack>() {

        @Override
        public void onTooltip(int slotIndex, boolean input, @Nonnull ItemStack ingredient, @Nonnull List<String> tooltip) {
            switch(slotIndex) {
                case 1:
                case 2:
                case 3:
                case 4:
                    if (slotIndex <= recipeWrapper.getRecipe().getOutputs().length) {
                        RecipeOutput output = recipeWrapper.getRecipe().getOutputs()[slotIndex - 1];
                        float chance = output.getChance();
                        if (chance > 0 && chance < 1) {
                            int chanceInt = (int) (chance * 100);
                            Object[] objects = { chanceInt };
                            tooltip.add(TextFormatting.GRAY + MessageFormat.format(Lang.JEI_SAGMILL_CHANCE.get(), objects));
                        }
                    }
                    return;
                case 5:
                    if (ballsTT.shouldHandleItem(ingredient)) {
                        ballsTT.addDetailedEntries(ingredient, Minecraft.getMinecraft().player, tooltip, true);
                    }
                    return;
                default:
                    return;
            }
        }
    });
    guiItemStacks.set(ingredients);
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) RecipeOutput(crazypants.enderio.base.recipe.RecipeOutput) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ItemStack(net.minecraft.item.ItemStack)

Aggregations

RecipeOutput (crazypants.enderio.base.recipe.RecipeOutput)9 Recipe (crazypants.enderio.base.recipe.Recipe)5 NNList (com.enderio.core.common.util.NNList)4 ItemStack (net.minecraft.item.ItemStack)4 IRecipeInput (crazypants.enderio.base.recipe.IRecipeInput)3 ThingsRecipeInput (crazypants.enderio.base.recipe.ThingsRecipeInput)3 ArrayList (java.util.ArrayList)3 EnergyIngredient (crazypants.enderio.base.integration.jei.energy.EnergyIngredient)2 IRecipe (crazypants.enderio.base.recipe.IRecipe)2 RecipeInput (crazypants.enderio.base.recipe.RecipeInput)2 List (java.util.List)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 IMachineRecipe (crazypants.enderio.base.recipe.IMachineRecipe)1 MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)1 ManyToOneMachineRecipe (crazypants.enderio.base.recipe.ManyToOneMachineRecipe)1 IGuiItemStackGroup (mezz.jei.api.gui.IGuiItemStackGroup)1