Search in sources :

Example 1 with ProcessingRecipeSerializer

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer in project Create by Creators-of-Create.

the class ProcessingRecipeGen method create.

/**
 * Create a processing recipe with a single itemstack ingredient, using its id
 * as the name of the recipe
 */
protected <T extends ProcessingRecipe<?>> GeneratedRecipe create(String namespace, Supplier<ItemLike> singleIngredient, UnaryOperator<ProcessingRecipeBuilder<T>> transform) {
    ProcessingRecipeSerializer<T> serializer = getSerializer();
    GeneratedRecipe generatedRecipe = c -> {
        ItemLike iItemProvider = singleIngredient.get();
        transform.apply(new ProcessingRecipeBuilder<>(serializer.getFactory(), new ResourceLocation(namespace, iItemProvider.asItem().getRegistryName().getPath())).withItemIngredients(Ingredient.of(iItemProvider))).build(c);
    };
    all.add(generatedRecipe);
    return generatedRecipe;
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) HashCache(net.minecraft.data.HashCache) IOException(java.io.IOException) UnaryOperator(java.util.function.UnaryOperator) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) Ingredient(net.minecraft.world.item.crafting.Ingredient) FluidAttributes(net.minecraftforge.fluids.FluidAttributes) List(java.util.List) Create(com.simibubi.create.Create) ItemLike(net.minecraft.world.level.ItemLike) IRecipeTypeInfo(com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo) ProcessingRecipeSerializer(com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer) ProcessingRecipeBuilder(com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder) DataGenerator(net.minecraft.data.DataGenerator) DataProvider(net.minecraft.data.DataProvider) ProcessingRecipeBuilder(com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder) ResourceLocation(net.minecraft.resources.ResourceLocation) ItemLike(net.minecraft.world.level.ItemLike)

Example 2 with ProcessingRecipeSerializer

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer in project KubeJS-Create by KubeJS-Mods.

the class KubeJSCreatePlugin method addRecipes.

@Override
public void addRecipes(RegisterRecipeHandlersEvent event) {
    event.register(new ResourceLocation("create:sequenced_assembly"), SequencedAssemblyRecipeJS::new);
    event.registerShaped(new ResourceLocation("create:mechanical_crafting"));
    for (var createRecipeType : AllRecipeTypes.values()) {
        if (createRecipeType.getSerializer() instanceof ProcessingRecipeSerializer) {
            event.register(createRecipeType.getId(), ProcessingRecipeJS::new);
        }
    }
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) ProcessingRecipeSerializer(com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer)

Example 3 with ProcessingRecipeSerializer

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer in project Create by Creators-of-Create.

the class SequencedRecipe method readFromBuffer.

public static SequencedRecipe<?> readFromBuffer(FriendlyByteBuf buffer) {
    ResourceLocation resourcelocation = buffer.readResourceLocation();
    ResourceLocation resourcelocation1 = buffer.readResourceLocation();
    RecipeSerializer<?> serializer = ForgeRegistries.RECIPE_SERIALIZERS.getValue(resourcelocation);
    if (!(serializer instanceof ProcessingRecipeSerializer))
        throw new JsonParseException("Not a supported recipe type");
    @SuppressWarnings("rawtypes") ProcessingRecipe recipe = (ProcessingRecipe) serializer.fromNetwork(resourcelocation1, buffer);
    return new SequencedRecipe<>(recipe);
}
Also used : ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) ResourceLocation(net.minecraft.resources.ResourceLocation) ProcessingRecipeSerializer(com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer) JsonParseException(com.google.gson.JsonParseException)

Example 4 with ProcessingRecipeSerializer

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer in project Create by Creators-of-Create.

the class SequencedRecipe method toJson.

public JsonObject toJson() {
    @SuppressWarnings("unchecked") ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) wrapped.getSerializer();
    JsonObject json = new JsonObject();
    json.addProperty("type", ForgeRegistries.RECIPE_SERIALIZERS.getKey(serializer).toString());
    serializer.write(json, wrapped);
    return json;
}
Also used : ProcessingRecipeSerializer(com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer) JsonObject(com.google.gson.JsonObject)

Aggregations

ProcessingRecipeSerializer (com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer)4 ResourceLocation (net.minecraft.resources.ResourceLocation)3 ProcessingRecipe (com.simibubi.create.content.contraptions.processing.ProcessingRecipe)2 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 Create (com.simibubi.create.Create)1 ProcessingRecipeBuilder (com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder)1 IRecipeTypeInfo (com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1 UnaryOperator (java.util.function.UnaryOperator)1 DataGenerator (net.minecraft.data.DataGenerator)1 DataProvider (net.minecraft.data.DataProvider)1 HashCache (net.minecraft.data.HashCache)1 Ingredient (net.minecraft.world.item.crafting.Ingredient)1 ItemLike (net.minecraft.world.level.ItemLike)1 FluidAttributes (net.minecraftforge.fluids.FluidAttributes)1