Search in sources :

Example 1 with IFabricatorSmeltingRecipe

use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.

the class FabricatorRecipeCategory method getSmeltingInputs.

private static Map<Fluid, List<IFabricatorSmeltingRecipe>> getSmeltingInputs() {
    Map<Fluid, List<IFabricatorSmeltingRecipe>> smeltingInputs = new HashMap<>();
    for (IFabricatorSmeltingRecipe smelting : FabricatorSmeltingRecipeManager.recipes) {
        Fluid fluid = smelting.getProduct().getFluid();
        if (!smeltingInputs.containsKey(fluid)) {
            smeltingInputs.put(fluid, new ArrayList<>());
        }
        smeltingInputs.get(fluid).add(smelting);
    }
    return smeltingInputs;
}
Also used : IFabricatorSmeltingRecipe(forestry.api.recipes.IFabricatorSmeltingRecipe) HashMap(java.util.HashMap) Fluid(net.minecraftforge.fluids.Fluid) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with IFabricatorSmeltingRecipe

use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.

the class FabricatorRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, FabricatorRecipeWrapper recipeWrapper, IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
    guiItemStacks.init(planSlot, true, 118, 0);
    guiItemStacks.init(smeltingInputSlot, true, 5, 4);
    guiItemStacks.init(craftOutputSlot, false, 118, 36);
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 3; ++x) {
            int index = craftInputSlot + x + y * 3;
            guiItemStacks.init(index, true, 46 + x * 18, y * 18);
        }
    }
    guiFluidStacks.init(inputTank, true, 6, 32, 16, 16, 2000, false, null);
    IFabricatorRecipe recipe = recipeWrapper.getRecipe();
    ItemStack plan = recipe.getPlan();
    if (!plan.isEmpty()) {
        guiItemStacks.set(planSlot, plan);
    }
    List<ItemStack> smeltingInput = new ArrayList<>();
    Fluid recipeFluid = recipe.getLiquid().getFluid();
    for (IFabricatorSmeltingRecipe s : getSmeltingInputs().get(recipeFluid)) {
        smeltingInput.add(s.getResource());
    }
    if (!smeltingInput.isEmpty()) {
        guiItemStacks.set(smeltingInputSlot, smeltingInput);
    }
    List<List<ItemStack>> itemOutputs = ingredients.getOutputs(ItemStack.class);
    guiItemStacks.set(craftOutputSlot, itemOutputs.get(0));
    List<List<ItemStack>> itemStackInputs = ingredients.getInputs(ItemStack.class);
    craftingGridHelper.setInputs(guiItemStacks, itemStackInputs, recipe.getWidth(), recipe.getHeight());
    List<List<FluidStack>> fluidInputs = ingredients.getInputs(FluidStack.class);
    if (!fluidInputs.isEmpty()) {
        guiFluidStacks.set(inputTank, fluidInputs.get(0));
    }
}
Also used : IFabricatorSmeltingRecipe(forestry.api.recipes.IFabricatorSmeltingRecipe) IGuiFluidStackGroup(mezz.jei.api.gui.IGuiFluidStackGroup) Fluid(net.minecraftforge.fluids.Fluid) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IFabricatorRecipe(forestry.api.recipes.IFabricatorRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IFabricatorSmeltingRecipe

use of forestry.api.recipes.IFabricatorSmeltingRecipe in project ForestryMC by ForestryMC.

the class TileFabricator method trySmelting.

private void trySmelting() {
    IInventoryAdapter inventory = getInternalInventory();
    ItemStack smeltResource = inventory.getStackInSlot(InventoryFabricator.SLOT_METAL);
    if (smeltResource.isEmpty()) {
        return;
    }
    IFabricatorSmeltingRecipe smelt = FabricatorSmeltingRecipeManager.findMatchingSmelting(smeltResource);
    if (smelt == null || smelt.getMeltingPoint() > heat) {
        return;
    }
    FluidStack smeltFluid = smelt.getProduct();
    if (moltenTank.fillInternal(smeltFluid, false) == smeltFluid.amount) {
        this.decrStackSize(InventoryFabricator.SLOT_METAL, 1);
        moltenTank.fillInternal(smeltFluid, true);
        meltingPoint = smelt.getMeltingPoint();
    }
}
Also used : IFabricatorSmeltingRecipe(forestry.api.recipes.IFabricatorSmeltingRecipe) FluidStack(net.minecraftforge.fluids.FluidStack) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IFabricatorSmeltingRecipe (forestry.api.recipes.IFabricatorSmeltingRecipe)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ItemStack (net.minecraft.item.ItemStack)2 Fluid (net.minecraftforge.fluids.Fluid)2 IFabricatorRecipe (forestry.api.recipes.IFabricatorRecipe)1 IInventoryAdapter (forestry.core.inventory.IInventoryAdapter)1 HashMap (java.util.HashMap)1 IGuiFluidStackGroup (mezz.jei.api.gui.IGuiFluidStackGroup)1 IGuiItemStackGroup (mezz.jei.api.gui.IGuiItemStackGroup)1 FluidStack (net.minecraftforge.fluids.FluidStack)1