Search in sources :

Example 11 with FluidStackIngredient

use of mekanism.api.recipes.inputs.FluidStackIngredient in project Mekanism by mekanism.

the class PressurizedReactionRecipeSerializer method fromNetwork.

@Override
public RECIPE fromNetwork(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
    try {
        ItemStackIngredient inputSolid = ItemStackIngredient.read(buffer);
        FluidStackIngredient inputFluid = FluidStackIngredient.read(buffer);
        GasStackIngredient inputGas = GasStackIngredient.read(buffer);
        FloatingLong energyRequired = FloatingLong.readFromBuffer(buffer);
        int duration = buffer.readVarInt();
        ItemStack outputItem = buffer.readItem();
        GasStack outputGas = GasStack.readFromPacket(buffer);
        return this.factory.create(recipeId, inputSolid, inputFluid, inputGas, energyRequired, duration, outputItem, outputGas);
    } catch (Exception e) {
        Mekanism.logger.error("Error reading pressurized reaction recipe from packet.", e);
        throw e;
    }
}
Also used : ItemStackIngredient(mekanism.api.recipes.inputs.ItemStackIngredient) FloatingLong(mekanism.api.math.FloatingLong) FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack) JsonSyntaxException(com.google.gson.JsonSyntaxException) GasStackIngredient(mekanism.api.recipes.inputs.chemical.GasStackIngredient)

Example 12 with FluidStackIngredient

use of mekanism.api.recipes.inputs.FluidStackIngredient in project Mekanism by mekanism.

the class RotaryRecipeSerializer method fromNetwork.

@Override
public RECIPE fromNetwork(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
    try {
        FluidStackIngredient fluidInputIngredient = null;
        GasStackIngredient gasInputIngredient = null;
        GasStack gasOutput = null;
        FluidStack fluidOutput = null;
        boolean hasFluidToGas = buffer.readBoolean();
        if (hasFluidToGas) {
            fluidInputIngredient = FluidStackIngredient.read(buffer);
            gasOutput = GasStack.readFromPacket(buffer);
        }
        boolean hasGasToFluid = buffer.readBoolean();
        if (hasGasToFluid) {
            gasInputIngredient = GasStackIngredient.read(buffer);
            fluidOutput = FluidStack.readFromPacket(buffer);
        }
        if (hasFluidToGas && hasGasToFluid) {
            return this.factory.create(recipeId, fluidInputIngredient, gasInputIngredient, gasOutput, fluidOutput);
        } else if (hasFluidToGas) {
            return this.factory.create(recipeId, fluidInputIngredient, gasOutput);
        } else if (hasGasToFluid) {
            return this.factory.create(recipeId, gasInputIngredient, fluidOutput);
        }
        // Should never happen, but if we somehow get here log it
        Mekanism.logger.error("Error reading rotary recipe from packet. A recipe got sent with no conversion in either direction.");
        return null;
    } catch (Exception e) {
        Mekanism.logger.error("Error reading rotary recipe from packet.", e);
        throw e;
    }
}
Also used : FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) GasStack(mekanism.api.chemical.gas.GasStack) JsonSyntaxException(com.google.gson.JsonSyntaxException) GasStackIngredient(mekanism.api.recipes.inputs.chemical.GasStackIngredient)

Example 13 with FluidStackIngredient

use of mekanism.api.recipes.inputs.FluidStackIngredient in project Mekanism by mekanism.

the class FluidToFluidRecipeSerializer method fromJson.

@Nonnull
@Override
public RECIPE fromJson(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
    JsonElement input = JSONUtils.isArrayNode(json, JsonConstants.INPUT) ? JSONUtils.getAsJsonArray(json, JsonConstants.INPUT) : JSONUtils.getAsJsonObject(json, JsonConstants.INPUT);
    FluidStackIngredient inputIngredient = FluidStackIngredient.deserialize(input);
    FluidStack output = SerializerHelper.getFluidStack(json, JsonConstants.OUTPUT);
    if (output.isEmpty()) {
        throw new JsonSyntaxException("Recipe output must not be empty.");
    }
    return this.factory.create(recipeId, inputIngredient, output);
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) FluidStackIngredient(mekanism.api.recipes.inputs.FluidStackIngredient) JsonElement(com.google.gson.JsonElement) FluidStack(net.minecraftforge.fluids.FluidStack) Nonnull(javax.annotation.Nonnull)

Example 14 with FluidStackIngredient

use of mekanism.api.recipes.inputs.FluidStackIngredient 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)

Aggregations

FluidStackIngredient (mekanism.api.recipes.inputs.FluidStackIngredient)14 JsonSyntaxException (com.google.gson.JsonSyntaxException)10 GasStack (mekanism.api.chemical.gas.GasStack)8 JsonElement (com.google.gson.JsonElement)6 Nonnull (javax.annotation.Nonnull)6 FluidStack (net.minecraftforge.fluids.FluidStack)6 FloatingLong (mekanism.api.math.FloatingLong)5 GasStackIngredient (mekanism.api.recipes.inputs.chemical.GasStackIngredient)5 SlurryStack (mekanism.api.chemical.slurry.SlurryStack)3 SlurryStackIngredient (mekanism.api.recipes.inputs.chemical.SlurryStackIngredient)3 MCFluidStack (com.blamejared.crafttweaker.impl.fluid.MCFluidStack)2 JsonObject (com.google.gson.JsonObject)2 ItemStackIngredient (mekanism.api.recipes.inputs.ItemStackIngredient)2 ItemStack (net.minecraft.item.ItemStack)2 CommandStringDisplayable (com.blamejared.crafttweaker.api.brackets.CommandStringDisplayable)1 IFluidStack (com.blamejared.crafttweaker.api.fluid.IFluidStack)1 IIngredient (com.blamejared.crafttweaker.api.item.IIngredient)1 IItemStack (com.blamejared.crafttweaker.api.item.IItemStack)1 ItemStackHelper (com.blamejared.crafttweaker.impl.helper.ItemStackHelper)1 MCItemStack (com.blamejared.crafttweaker.impl.item.MCItemStack)1