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