Search in sources :

Example 1 with SlurryStackIngredient

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

the class FluidSlurryToSlurryRecipeSerializer method fromJson.

@Nonnull
@Override
public RECIPE fromJson(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
    JsonElement fluidInput = JSONUtils.isArrayNode(json, JsonConstants.FLUID_INPUT) ? JSONUtils.getAsJsonArray(json, JsonConstants.FLUID_INPUT) : JSONUtils.getAsJsonObject(json, JsonConstants.FLUID_INPUT);
    FluidStackIngredient fluidIngredient = FluidStackIngredient.deserialize(fluidInput);
    JsonElement slurryInput = JSONUtils.isArrayNode(json, JsonConstants.SLURRY_INPUT) ? JSONUtils.getAsJsonArray(json, JsonConstants.SLURRY_INPUT) : JSONUtils.getAsJsonObject(json, JsonConstants.SLURRY_INPUT);
    SlurryStackIngredient slurryIngredient = SlurryStackIngredient.deserialize(slurryInput);
    SlurryStack output = SerializerHelper.getSlurryStack(json, JsonConstants.OUTPUT);
    if (output.isEmpty()) {
        throw new JsonSyntaxException("Recipe output must not be empty.");
    }
    return this.factory.create(recipeId, fluidIngredient, slurryIngredient, output);
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) JsonElement(com.google.gson.JsonElement) SlurryStackIngredient(mekanism.api.recipes.inputs.chemical.SlurryStackIngredient) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) Nonnull(javax.annotation.Nonnull)

Example 2 with SlurryStackIngredient

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

the class FluidSlurryToSlurryRecipeSerializer method fromNetwork.

@Override
public RECIPE fromNetwork(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
    try {
        FluidStackIngredient fluidInput = FluidStackIngredient.read(buffer);
        SlurryStackIngredient slurryInput = SlurryStackIngredient.read(buffer);
        SlurryStack output = SlurryStack.readFromPacket(buffer);
        return this.factory.create(recipeId, fluidInput, slurryInput, output);
    } catch (Exception e) {
        Mekanism.logger.error("Error reading fluid slurry to slurry recipe from packet.", e);
        throw e;
    }
}
Also used : FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) SlurryStackIngredient(mekanism.api.recipes.inputs.chemical.SlurryStackIngredient) SlurryStack(mekanism.api.chemical.slurry.SlurryStack) JsonSyntaxException(com.google.gson.JsonSyntaxException)

Example 3 with SlurryStackIngredient

use of mekanism.api.recipes.inputs.chemical.SlurryStackIngredient 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

SlurryStack (mekanism.api.chemical.slurry.SlurryStack)3 SlurryStackIngredient (mekanism.api.recipes.inputs.chemical.SlurryStackIngredient)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 Nonnull (javax.annotation.Nonnull)2 FluidStackIngredient (mekanism.api.recipes.inputs.FluidStackIngredient)2 JsonElement (com.google.gson.JsonElement)1 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 BoxedChemicalStack (mekanism.api.chemical.merged.BoxedChemicalStack)1 Slurry (mekanism.api.chemical.slurry.Slurry)1 ChemicalCrystallizerRecipe (mekanism.api.recipes.ChemicalCrystallizerRecipe)1 GasStackIngredient (mekanism.api.recipes.inputs.chemical.GasStackIngredient)1 IChemicalStackIngredient (mekanism.api.recipes.inputs.chemical.IChemicalStackIngredient)1