use of mekanism.api.recipes.inputs.chemical.ChemicalStackIngredient in project Mekanism by mekanism.
the class ChemicalCrystallizerRecipeSerializer method fromJson.
@Nonnull
@Override
public RECIPE fromJson(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
ChemicalType chemicalType = SerializerHelper.getChemicalType(json);
JsonElement input = JSONUtils.isArrayNode(json, JsonConstants.INPUT) ? JSONUtils.getAsJsonArray(json, JsonConstants.INPUT) : JSONUtils.getAsJsonObject(json, JsonConstants.INPUT);
ChemicalStackIngredient<?, ?> inputIngredient = (ChemicalStackIngredient<?, ?>) SerializerHelper.getDeserializerForType(chemicalType).deserialize(input);
ItemStack output = SerializerHelper.getItemStack(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.chemical.ChemicalStackIngredient in project Mekanism by mekanism.
the class ChemicalCrystallizerRecipeSerializer method fromNetwork.
@Override
public RECIPE fromNetwork(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
try {
ChemicalType chemicalType = buffer.readEnum(ChemicalType.class);
ChemicalStackIngredient<?, ?> inputIngredient = (ChemicalStackIngredient<?, ?>) SerializerHelper.getDeserializerForType(chemicalType).read(buffer);
ItemStack output = buffer.readItem();
return this.factory.create(recipeId, inputIngredient, output);
} catch (Exception e) {
Mekanism.logger.error("Error reading boxed chemical to itemstack recipe from packet.", e);
throw e;
}
}
Aggregations