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;
}
}
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;
}
}
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);
}
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;
}
}
Aggregations