Search in sources :

Example 6 with BoxedChemicalStack

use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.

the class BoxedChemicalInputHandler method use.

/**
 * Adds {@code operations} operations worth of {@code recipeInput} from the input.
 *
 * @param recipeInput Recipe input result.
 * @param operations  Operations to perform.
 */
public void use(BoxedChemicalStack recipeInput, long operations) {
    if (operations == 0 || recipeInput.isEmpty()) {
        // or if something went wrong, this if should never really be true if we got to finishProcessing
        return;
    }
    BoxedChemicalStack inputGas = getInput();
    if (!inputGas.isEmpty()) {
        long amount = recipeInput.getChemicalStack().getAmount() * operations;
        logMismatchedStackSize(chemicalTank.getTankForType(inputGas.getChemicalType()).shrinkStack(amount, Action.EXECUTE), amount);
    }
}
Also used : BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack)

Example 7 with BoxedChemicalStack

use of mekanism.api.chemical.merged.BoxedChemicalStack 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 8 with BoxedChemicalStack

use of mekanism.api.chemical.merged.BoxedChemicalStack 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)

Example 9 with BoxedChemicalStack

use of mekanism.api.chemical.merged.BoxedChemicalStack in project Mekanism by mekanism.

the class GuiChemicalCrystallizer method getScreenRenderStrings.

public static List<ITextComponent> getScreenRenderStrings(IOreInfo oreInfo) {
    BoxedChemicalStack boxedChemical = oreInfo.getInputChemical();
    if (!boxedChemical.isEmpty()) {
        List<ITextComponent> ret = new ArrayList<>();
        ret.add(boxedChemical.getTextComponent());
        if (boxedChemical.getChemicalType() == ChemicalType.SLURRY && !oreInfo.getRenderStack().isEmpty()) {
            ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(oreInfo.getRenderStack()));
        } else {
            ChemicalCrystallizerRecipe recipe = oreInfo.getRecipe();
            if (recipe == null) {
                ret.add(MekanismLang.NO_RECIPE.translate());
            } else {
                ret.add(MekanismLang.GENERIC_PARENTHESIS.translate(recipe.getOutput(boxedChemical)));
            }
        }
        return ret;
    }
    return Collections.emptyList();
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) ChemicalCrystallizerRecipe(mekanism.api.recipes.ChemicalCrystallizerRecipe)

Aggregations

BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)9 List (java.util.List)3 ChemicalStack (mekanism.api.chemical.ChemicalStack)3 ChemicalType (mekanism.api.chemical.ChemicalType)3 GasStack (mekanism.api.chemical.gas.GasStack)3 ChemicalDissolutionRecipe (mekanism.api.recipes.ChemicalDissolutionRecipe)3 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 NonNull (mekanism.api.annotations.NonNull)2 InfusionStack (mekanism.api.chemical.infuse.InfusionStack)2 Current (mekanism.api.chemical.merged.MergedChemicalTank.Current)2 PigmentStack (mekanism.api.chemical.pigment.PigmentStack)2 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)2 ChemicalCrystallizerRecipe (mekanism.api.recipes.ChemicalCrystallizerRecipe)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