Search in sources :

Example 1 with ProcessingRecipe

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

the class SequencedRecipe method fromJson.

public static SequencedRecipe<?> fromJson(JsonObject json, SequencedAssemblyRecipe parent, int index) {
    ResourceLocation parentId = parent.getId();
    Recipe<?> recipe = RecipeManager.fromJson(new ResourceLocation(parentId.getNamespace(), parentId.getPath() + "_step_" + index), json);
    if (recipe instanceof ProcessingRecipe<?> && recipe instanceof IAssemblyRecipe) {
        ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
        IAssemblyRecipe assemblyRecipe = (IAssemblyRecipe) recipe;
        if (assemblyRecipe.supportsAssembly()) {
            Ingredient transit = Ingredient.of(parent.getTransitionalItem());
            processingRecipe.getIngredients().set(0, index == 0 ? Ingredient.merge(ImmutableList.of(transit, parent.getIngredient())) : transit);
            SequencedRecipe<?> sequencedRecipe = new SequencedRecipe<>(processingRecipe);
            return sequencedRecipe;
        }
    }
    throw new JsonParseException("Not a supported recipe type");
}
Also used : ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) Ingredient(net.minecraft.world.item.crafting.Ingredient) ResourceLocation(net.minecraft.resources.ResourceLocation) JsonParseException(com.google.gson.JsonParseException)

Example 2 with ProcessingRecipe

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

the class CrushingWheelControllerTileEntity method applyRecipe.

private void applyRecipe() {
    Optional<ProcessingRecipe<RecipeWrapper>> recipe = findRecipe();
    List<ItemStack> list = new ArrayList<>();
    if (recipe.isPresent()) {
        int rolls = inventory.getStackInSlot(0).getCount();
        inventory.clear();
        for (int roll = 0; roll < rolls; roll++) {
            List<ItemStack> rolledResults = recipe.get().rollResults();
            for (int i = 0; i < rolledResults.size(); i++) {
                ItemStack stack = rolledResults.get(i);
                ItemHelper.addToList(stack, list);
            }
        }
        for (int slot = 0; slot < list.size() && slot + 1 < inventory.getSlots(); slot++) inventory.setStackInSlot(slot + 1, list.get(slot));
    } else {
        inventory.clear();
    }
}
Also used : ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with ProcessingRecipe

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

the class CreateRecipeCategory method getRenderedSlot.

public static AllGuiTextures getRenderedSlot(Recipe<?> recipe, int index) {
    AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT;
    if (!(recipe instanceof ProcessingRecipe))
        return jeiSlot;
    ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
    List<ProcessingOutput> rollableResults = processingRecipe.getRollableResults();
    if (rollableResults.size() <= index)
        return jeiSlot;
    if (processingRecipe.getRollableResults().get(index).getChance() == 1)
        return jeiSlot;
    return AllGuiTextures.JEI_CHANCE_SLOT;
}
Also used : ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) AllGuiTextures(com.simibubi.create.foundation.gui.AllGuiTextures) ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Example 4 with ProcessingRecipe

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe 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 5 with ProcessingRecipe

use of com.simibubi.create.content.contraptions.processing.ProcessingRecipe 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)

Aggregations

ProcessingRecipe (com.simibubi.create.content.contraptions.processing.ProcessingRecipe)5 ResourceLocation (net.minecraft.resources.ResourceLocation)3 JsonParseException (com.google.gson.JsonParseException)2 ProcessingRecipeSerializer (com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer)2 ArrayList (java.util.ArrayList)2 Ingredient (net.minecraft.world.item.crafting.Ingredient)2 Create (com.simibubi.create.Create)1 ProcessingOutput (com.simibubi.create.content.contraptions.processing.ProcessingOutput)1 ProcessingRecipeBuilder (com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder)1 AllGuiTextures (com.simibubi.create.foundation.gui.AllGuiTextures)1 IRecipeTypeInfo (com.simibubi.create.foundation.utility.recipe.IRecipeTypeInfo)1 IOException (java.io.IOException)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 ItemStack (net.minecraft.world.item.ItemStack)1 ItemLike (net.minecraft.world.level.ItemLike)1