Search in sources :

Example 1 with ChemicalDissolutionRecipe

use of mekanism.api.recipes.ChemicalDissolutionRecipe in project Mekanism by mekanism.

the class ChemicalDissolutionRecipeMapper method handleRecipe.

@Override
public boolean handleRecipe(IMappingCollector<NormalizedSimpleStack, Long> mapper, IRecipe<?> iRecipe, INSSFakeGroupManager groupManager) {
    if (!(iRecipe instanceof ChemicalDissolutionRecipe)) {
        // Double check that we have a type of recipe we know how to handle
        return false;
    }
    boolean handled = false;
    ChemicalDissolutionRecipe recipe = (ChemicalDissolutionRecipe) iRecipe;
    List<@NonNull ItemStack> itemRepresentations = recipe.getItemInput().getRepresentations();
    List<@NonNull GasStack> gasRepresentations = recipe.getGasInput().getRepresentations();
    for (GasStack gasRepresentation : gasRepresentations) {
        NSSGas nssGas = NSSGas.createGas(gasRepresentation);
        long gasAmount = gasRepresentation.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED;
        for (ItemStack itemRepresentation : itemRepresentations) {
            BoxedChemicalStack output = recipe.getOutput(itemRepresentation, gasRepresentation);
            if (!output.isEmpty()) {
                IngredientHelper ingredientHelper = new IngredientHelper(mapper);
                ingredientHelper.put(itemRepresentation);
                ingredientHelper.put(nssGas, gasAmount);
                if (ingredientHelper.addAsConversion(output.getChemicalStack())) {
                    handled = true;
                }
            }
        }
    }
    return handled;
}
Also used : ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) NSSGas(mekanism.common.integration.projecte.NSSGas) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack) IngredientHelper(mekanism.common.integration.projecte.IngredientHelper) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 2 with ChemicalDissolutionRecipe

use of mekanism.api.recipes.ChemicalDissolutionRecipe in project Mekanism by mekanism.

the class ChemicalDissolutionRecipeCategory method setIngredients.

@Override
public void setIngredients(ChemicalDissolutionRecipe recipe, IIngredients ingredients) {
    ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(recipe.getItemInput().getRepresentations()));
    List<@NonNull GasStack> gasInputs = recipe.getGasInput().getRepresentations();
    List<GasStack> scaledGases = gasInputs.stream().map(gas -> new GasStack(gas, gas.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)).collect(Collectors.toList());
    ingredients.setInputLists(MekanismJEI.TYPE_GAS, Collections.singletonList(scaledGases));
    BoxedChemicalStack outputDefinition = recipe.getOutputDefinition();
    ChemicalType chemicalType = outputDefinition.getChemicalType();
    if (chemicalType == ChemicalType.GAS) {
        ingredients.setOutput(MekanismJEI.TYPE_GAS, (GasStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.INFUSION) {
        ingredients.setOutput(MekanismJEI.TYPE_INFUSION, (InfusionStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.PIGMENT) {
        ingredients.setOutput(MekanismJEI.TYPE_PIGMENT, (PigmentStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.SLURRY) {
        ingredients.setOutput(MekanismJEI.TYPE_SLURRY, (SlurryStack) outputDefinition.getChemicalStack());
    } else {
        throw new IllegalStateException("Unknown chemical type");
    }
}
Also used : ChemicalStack(mekanism.api.chemical.ChemicalStack) IIngredients(mezz.jei.api.ingredients.IIngredients) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ChemicalType(mekanism.api.chemical.ChemicalType) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) GuiGauge(mekanism.client.gui.element.gauge.GuiGauge) TileEntityChemicalDissolutionChamber(mekanism.common.tile.machine.TileEntityChemicalDissolutionChamber) GasStack(mekanism.api.chemical.gas.GasStack) NonNull(mekanism.api.annotations.NonNull) MekanismBlocks(mekanism.common.registries.MekanismBlocks) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) BaseRecipeCategory(mekanism.client.jei.BaseRecipeCategory) SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) SlotType(mekanism.client.gui.element.slot.SlotType) DataType(mekanism.common.tile.component.config.DataType) Collectors(java.util.stream.Collectors) MekanismJEI(mekanism.client.jei.MekanismJEI) ProgressType(mekanism.client.gui.element.progress.ProgressType) List(java.util.List) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) IIngredientType(mezz.jei.api.ingredients.IIngredientType) GaugeType(mekanism.client.gui.element.gauge.GaugeType) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) IGuiIngredientGroup(mezz.jei.api.gui.ingredient.IGuiIngredientGroup) VanillaTypes(mezz.jei.api.constants.VanillaTypes) Collections(java.util.Collections) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ChemicalType(mekanism.api.chemical.ChemicalType) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 3 with ChemicalDissolutionRecipe

use of mekanism.api.recipes.ChemicalDissolutionRecipe in project Mekanism by mekanism.

the class ChemicalDissolutionRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, ChemicalDissolutionRecipe recipe, IIngredients ingredients) {
    initItem(recipeLayout.getItemStacks(), 0, true, inputSlot, recipe.getItemInput().getRepresentations());
    List<@NonNull GasStack> gasInputs = recipe.getGasInput().getRepresentations();
    List<GasStack> scaledGases = gasInputs.stream().map(gas -> new GasStack(gas, gas.getAmount() * TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED)).collect(Collectors.toList());
    IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.TYPE_GAS);
    initChemical(gasStacks, 0, true, inputGauge, scaledGases);
    BoxedChemicalStack outputDefinition = recipe.getOutputDefinition();
    ChemicalType chemicalType = outputDefinition.getChemicalType();
    if (chemicalType == ChemicalType.GAS) {
        initChemicalOutput(recipeLayout, MekanismJEI.TYPE_GAS, (GasStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.INFUSION) {
        initChemicalOutput(recipeLayout, MekanismJEI.TYPE_INFUSION, (InfusionStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.PIGMENT) {
        initChemicalOutput(recipeLayout, MekanismJEI.TYPE_PIGMENT, (PigmentStack) outputDefinition.getChemicalStack());
    } else if (chemicalType == ChemicalType.SLURRY) {
        initChemicalOutput(recipeLayout, MekanismJEI.TYPE_SLURRY, (SlurryStack) outputDefinition.getChemicalStack());
    } else {
        throw new IllegalStateException("Unknown chemical type");
    }
}
Also used : ChemicalStack(mekanism.api.chemical.ChemicalStack) IIngredients(mezz.jei.api.ingredients.IIngredients) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) ChemicalType(mekanism.api.chemical.ChemicalType) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) GuiGauge(mekanism.client.gui.element.gauge.GuiGauge) TileEntityChemicalDissolutionChamber(mekanism.common.tile.machine.TileEntityChemicalDissolutionChamber) GasStack(mekanism.api.chemical.gas.GasStack) NonNull(mekanism.api.annotations.NonNull) MekanismBlocks(mekanism.common.registries.MekanismBlocks) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) GuiHorizontalPowerBar(mekanism.client.gui.element.bar.GuiHorizontalPowerBar) ChemicalDissolutionRecipe(mekanism.api.recipes.ChemicalDissolutionRecipe) BaseRecipeCategory(mekanism.client.jei.BaseRecipeCategory) SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) SlotType(mekanism.client.gui.element.slot.SlotType) DataType(mekanism.common.tile.component.config.DataType) Collectors(java.util.stream.Collectors) MekanismJEI(mekanism.client.jei.MekanismJEI) ProgressType(mekanism.client.gui.element.progress.ProgressType) List(java.util.List) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) IIngredientType(mezz.jei.api.ingredients.IIngredientType) GaugeType(mekanism.client.gui.element.gauge.GaugeType) PigmentStack(mekanism.api.chemical.pigment.PigmentStack) IGuiIngredientGroup(mezz.jei.api.gui.ingredient.IGuiIngredientGroup) VanillaTypes(mezz.jei.api.constants.VanillaTypes) Collections(java.util.Collections) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) ChemicalType(mekanism.api.chemical.ChemicalType) InfusionStack(mekanism.api.chemical.infuse.InfusionStack) GasStack(mekanism.api.chemical.gas.GasStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Aggregations

GasStack (mekanism.api.chemical.gas.GasStack)3 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)3 ChemicalDissolutionRecipe (mekanism.api.recipes.ChemicalDissolutionRecipe)3 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 NonNull (mekanism.api.annotations.NonNull)2 ChemicalStack (mekanism.api.chemical.ChemicalStack)2 ChemicalType (mekanism.api.chemical.ChemicalType)2 InfusionStack (mekanism.api.chemical.infuse.InfusionStack)2 PigmentStack (mekanism.api.chemical.pigment.PigmentStack)2 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)2 GuiHorizontalPowerBar (mekanism.client.gui.element.bar.GuiHorizontalPowerBar)2 GaugeType (mekanism.client.gui.element.gauge.GaugeType)2 GuiGasGauge (mekanism.client.gui.element.gauge.GuiGasGauge)2 GuiGauge (mekanism.client.gui.element.gauge.GuiGauge)2 ProgressType (mekanism.client.gui.element.progress.ProgressType)2 GuiSlot (mekanism.client.gui.element.slot.GuiSlot)2 SlotType (mekanism.client.gui.element.slot.SlotType)2 BaseRecipeCategory (mekanism.client.jei.BaseRecipeCategory)2