Search in sources :

Example 1 with IRecipe

use of crazypants.enderio.base.recipe.IRecipe 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 2 with IRecipe

use of crazypants.enderio.base.recipe.IRecipe 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 3 with IRecipe

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

the class SagMillRecipeManager method addRecipe.

public void addRecipe(@Nonnull Recipe recipe) {
    if (!recipe.isValid()) {
        Log.debug("Could not add invalid recipe: " + recipe);
        return;
    }
    IRecipe rec = getRecipeForInput(getInput(recipe));
    if (rec != null) {
        Log.warn("Not adding supplied recipe as a recipe already exists for the input: " + getInput(recipe));
        return;
    }
    recipes.add(recipe);
}
Also used : IRecipe(crazypants.enderio.base.recipe.IRecipe)

Example 4 with IRecipe

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

the class AlloyRecipeCategory method register.

public static void register(IModRegistry registry, IGuiHelper guiHelper) {
    registry.addRecipeCategories(new AlloyRecipeCategory(guiHelper));
    registry.handleRecipes(IRecipe.class, AlloyRecipe::new, AlloyRecipeCategory.UID);
    registry.addRecipeClickArea(GuiAlloySmelter.class, 155, 42, 16, 16, AlloyRecipeCategory.UID);
    registry.addRecipeCategoryCraftingItem(new ItemStack(block_alloy_smelter.getBlockNN()), AlloyRecipeCategory.UID, VanillaRecipeCategoryUid.SMELTING);
    registry.addRecipeCategoryCraftingItem(new ItemStack(block_simple_alloy_smelter.getBlockNN()), AlloyRecipeCategory.UID);
    long start = System.nanoTime();
    List<IRecipe> result = new ArrayList<IRecipe>();
    for (IManyToOneRecipe rec : AlloyRecipeManager.getInstance().getRecipes()) {
        if (!rec.isSynthetic()) {
            result.add(rec);
        }
    }
    result.addAll(AlloyRecipeManager.getInstance().getVanillaRecipe().getAllRecipes());
    long end = System.nanoTime();
    registry.addRecipes(result, UID);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerAlloySmelter.Normal.class, AlloyRecipeCategory.UID, FIRST_RECIPE_SLOT, NUM_RECIPE_SLOT, FIRST_INVENTORY_SLOT, NUM_INVENTORY_SLOT);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerAlloySmelter.Simple.class, AlloyRecipeCategory.UID, FIRST_RECIPE_SLOT, NUM_RECIPE_SLOT, FIRST_INVENTORY_SLOT - 1, NUM_INVENTORY_SLOT);
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerAlloySmelter.Normal.class, VanillaRecipeCategoryUid.SMELTING, FIRST_RECIPE_SLOT, NUM_RECIPE_SLOT, FIRST_INVENTORY_SLOT, NUM_INVENTORY_SLOT);
    Log.info(String.format("AlloyRecipeCategory: Added %d alloy smelter recipes to JEI in %.3f seconds.", result.size(), (end - start) / 1000000000d));
}
Also used : IRecipe(crazypants.enderio.base.recipe.IRecipe) IManyToOneRecipe(crazypants.enderio.base.recipe.IManyToOneRecipe) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ContainerAlloySmelter(crazypants.enderio.machines.machine.alloy.ContainerAlloySmelter)

Aggregations

IRecipe (crazypants.enderio.base.recipe.IRecipe)4 RecipeOutput (crazypants.enderio.base.recipe.RecipeOutput)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.item.ItemStack)2 IMachineRecipe (crazypants.enderio.base.recipe.IMachineRecipe)1 IManyToOneRecipe (crazypants.enderio.base.recipe.IManyToOneRecipe)1 IRecipeInput (crazypants.enderio.base.recipe.IRecipeInput)1 MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)1 Recipe (crazypants.enderio.base.recipe.Recipe)1 RecipeInput (crazypants.enderio.base.recipe.RecipeInput)1 ContainerAlloySmelter (crazypants.enderio.machines.machine.alloy.ContainerAlloySmelter)1 FluidStack (net.minecraftforge.fluids.FluidStack)1