use of com.blamejared.crafttweaker.impl.fluid.MCFluidStack in project Mekanism by mekanism.
the class MekanismRecipeHandler method convertIngredient.
private String convertIngredient(FluidStackIngredient ingredient) {
if (ingredient instanceof FluidStackIngredient.Single) {
JsonObject serialized = ingredient.serialize().getAsJsonObject();
// Note: Handled via implicit casts
return new MCFluidStack(SerializerHelper.deserializeFluid(serialized)).getCommandString();
} else if (ingredient instanceof FluidStackIngredient.Tagged) {
JsonObject serialized = ingredient.serialize().getAsJsonObject();
// Note: Handled via implicit casts
return getTagWithExplicitAmount(TagManagerFluid.INSTANCE.getTag(serialized.get(JsonConstants.TAG).getAsString()), serialized.getAsJsonPrimitive(JsonConstants.AMOUNT).getAsInt());
} else if (ingredient instanceof FluidStackIngredient.Multi) {
FluidStackIngredient.Multi multiIngredient = (FluidStackIngredient.Multi) ingredient;
StringBuilder builder = new StringBuilder(CrTConstants.CLASS_FLUID_STACK_INGREDIENT + ".createMulti(");
multiIngredient.forEachIngredient(i -> {
builder.append(convertIngredient(i)).append(", ");
return false;
});
// Remove trailing comma and space
builder.setLength(builder.length() - 2);
builder.append(")");
return builder.toString();
}
return "Unimplemented fluidstack ingredient: " + ingredient;
}
use of com.blamejared.crafttweaker.impl.fluid.MCFluidStack in project Mekanism by mekanism.
the class BaseCrTExampleProvider method getIngredientRepresentation.
private String getIngredientRepresentation(CrTImportsComponent imports, FluidStackIngredient ingredient) {
if (ingredient instanceof FluidStackIngredient.Single) {
JsonObject serialized = ingredient.serialize().getAsJsonObject();
String stackRepresentation = new MCFluidStack(SerializerHelper.deserializeFluid(serialized)).getCommandString();
return imports.addImport(CrTConstants.CLASS_FLUID_STACK_INGREDIENT) + ".from(" + stackRepresentation + ")";
} else if (ingredient instanceof FluidStackIngredient.Tagged) {
JsonObject serialized = ingredient.serialize().getAsJsonObject();
String tagRepresentation = TagManagerFluid.INSTANCE.getTag(serialized.get(JsonConstants.TAG).getAsString()).getCommandString();
return imports.addImport(CrTConstants.CLASS_FLUID_STACK_INGREDIENT) + ".from(" + tagRepresentation + ", " + serialized.getAsJsonPrimitive(JsonConstants.AMOUNT) + ")";
} else if (ingredient instanceof FluidStackIngredient.Multi) {
FluidStackIngredient.Multi multiIngredient = (FluidStackIngredient.Multi) ingredient;
StringBuilder builder = new StringBuilder(imports.addImport(CrTConstants.CLASS_FLUID_STACK_INGREDIENT) + ".createMulti(");
if (!multiIngredient.forEachIngredient(i -> {
String rep = getIngredientRepresentation(imports, i);
if (rep == null) {
return true;
}
builder.append(rep).append(", ");
return false;
})) {
// Remove trailing comma and space
builder.setLength(builder.length() - 2);
builder.append(")");
return builder.toString();
}
}
return null;
}
use of com.blamejared.crafttweaker.impl.fluid.MCFluidStack in project Mekanism by mekanism.
the class RotaryRecipeManager method getAction.
@Override
protected ActionAddMekanismRecipe getAction(RotaryRecipe recipe) {
return new ActionAddMekanismRecipe(recipe) {
@Override
protected String describeOutputs() {
RotaryRecipe recipe = getRecipe();
StringBuilder builder = new StringBuilder();
if (recipe.hasFluidToGas()) {
builder.append(CrTUtils.describeOutputs(recipe.getGasOutputDefinition(), CrTGasStack::new)).append(" for fluid to gas");
}
if (recipe.hasGasToFluid()) {
if (recipe.hasFluidToGas()) {
builder.append(" and ");
}
builder.append(CrTUtils.describeOutputs(recipe.getFluidOutputDefinition(), MCFluidStack::new)).append(" for gas to fluid");
}
return builder.toString();
}
};
}
Aggregations