Search in sources :

Example 11 with GasStackIngredient

use of mekanism.api.recipes.inputs.chemical.GasStackIngredient in project Mekanism by mekanism.

the class ChemicalCrystallizerRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, ChemicalCrystallizerRecipe recipe, IIngredients ingredients) {
    IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
    initItem(itemStacks, 0, false, output, recipe.getOutputDefinition());
    IChemicalStackIngredient<?, ?> input = recipe.getInput();
    if (input instanceof GasStackIngredient) {
        initChemical(recipeLayout, recipe, MekanismJEI.TYPE_GAS, (GasStackIngredient) input, null);
    } else if (input instanceof InfusionStackIngredient) {
        initChemical(recipeLayout, recipe, MekanismJEI.TYPE_INFUSION, (InfusionStackIngredient) input, null);
    } else if (input instanceof PigmentStackIngredient) {
        initChemical(recipeLayout, recipe, MekanismJEI.TYPE_PIGMENT, (PigmentStackIngredient) input, null);
    } else if (input instanceof SlurryStackIngredient) {
        SlurryStackIngredient slurryInput = (SlurryStackIngredient) input;
        Set<ITag<Item>> tags = new HashSet<>();
        for (SlurryStack slurryStack : slurryInput.getRepresentations()) {
            Slurry slurry = slurryStack.getType();
            if (!slurry.isIn(MekanismTags.Slurries.DIRTY)) {
                ITag<Item> oreTag = slurry.getOreTag();
                if (oreTag != null) {
                    tags.add(oreTag);
                }
            }
        }
        if (tags.size() == 1) {
            initChemical(recipeLayout, recipe, MekanismJEI.TYPE_SLURRY, slurryInput, itemStacks);
            // TODO: Eventually come up with a better way to do this to allow for if there outputs based on the input and multiple input types
            tags.stream().findFirst().ifPresent(tag -> initItem(itemStacks, 1, false, slurryOreSlot, tag.getValues().stream().map(ItemStack::new).collect(Collectors.toList())));
        } else {
            initChemical(recipeLayout, recipe, MekanismJEI.TYPE_SLURRY, slurryInput, null);
        }
    }
}
Also used : IOreInfo(mekanism.client.gui.machine.GuiChemicalCrystallizer.IOreInfo) ChemicalStack(mekanism.api.chemical.ChemicalStack) Item(net.minecraft.item.Item) IIngredients(mezz.jei.api.ingredients.IIngredients) ChemicalCrystallizerRecipe(mekanism.api.recipes.ChemicalCrystallizerRecipe) GuiGasGauge(mekanism.client.gui.element.gauge.GuiGasGauge) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) HashSet(java.util.HashSet) GuiGauge(mekanism.client.gui.element.gauge.GuiGauge) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) Slurry(mekanism.api.chemical.slurry.Slurry) Nonnull(javax.annotation.Nonnull) MekanismBlocks(mekanism.common.registries.MekanismBlocks) IRecipeLayout(mezz.jei.api.gui.IRecipeLayout) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) WeakHashMap(java.util.WeakHashMap) Nullable(javax.annotation.Nullable) 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) Set(java.util.Set) ITag(net.minecraft.tags.ITag) PigmentStackIngredient(mekanism.api.recipes.inputs.chemical.PigmentStackIngredient) GuiChemicalCrystallizer(mekanism.client.gui.machine.GuiChemicalCrystallizer) Collectors(java.util.stream.Collectors) MekanismJEI(mekanism.client.jei.MekanismJEI) IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup) GuiInnerScreen(mekanism.client.gui.element.GuiInnerScreen) IGuiIngredient(mezz.jei.api.gui.ingredient.IGuiIngredient) ProgressType(mekanism.client.gui.element.progress.ProgressType) SlurryStackIngredient(mekanism.api.recipes.inputs.chemical.SlurryStackIngredient) GasStackIngredient(mekanism.api.recipes.inputs.chemical.GasStackIngredient) IIngredientType(mezz.jei.api.ingredients.IIngredientType) GaugeType(mekanism.client.gui.element.gauge.GaugeType) IGuiIngredientGroup(mezz.jei.api.gui.ingredient.IGuiIngredientGroup) MekanismTags(mekanism.common.tags.MekanismTags) VanillaTypes(mezz.jei.api.constants.VanillaTypes) Collections(java.util.Collections) IChemicalStackIngredient(mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient) BoxedChemicalStack(mekanism.api.chemical.merged.BoxedChemicalStack) InfusionStackIngredient(mekanism.api.recipes.inputs.chemical.InfusionStackIngredient) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) HashSet(java.util.HashSet) Set(java.util.Set) PigmentStackIngredient(mekanism.api.recipes.inputs.chemical.PigmentStackIngredient) IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup) GasStackIngredient(mekanism.api.recipes.inputs.chemical.GasStackIngredient) Item(net.minecraft.item.Item) ITag(net.minecraft.tags.ITag) Slurry(mekanism.api.chemical.slurry.Slurry) SlurryStackIngredient(mekanism.api.recipes.inputs.chemical.SlurryStackIngredient) ItemStack(net.minecraft.item.ItemStack) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) InfusionStackIngredient(mekanism.api.recipes.inputs.chemical.InfusionStackIngredient)

Aggregations

GasStackIngredient (mekanism.api.recipes.inputs.chemical.GasStackIngredient)11 JsonSyntaxException (com.google.gson.JsonSyntaxException)10 Nonnull (javax.annotation.Nonnull)6 GasStack (mekanism.api.chemical.gas.GasStack)6 ItemStackIngredient (mekanism.api.recipes.inputs.ItemStackIngredient)6 JsonElement (com.google.gson.JsonElement)5 ItemStack (net.minecraft.item.ItemStack)5 FluidStackIngredient (mekanism.api.recipes.inputs.FluidStackIngredient)4 FloatingLong (mekanism.api.math.FloatingLong)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 WeakHashMap (java.util.WeakHashMap)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 ChemicalStack (mekanism.api.chemical.ChemicalStack)1 ChemicalType (mekanism.api.chemical.ChemicalType)1 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)1