Search in sources :

Example 6 with FinishedRecipe

use of net.minecraft.data.recipes.FinishedRecipe in project CodeChickenLib by TheCBProject.

the class RecipeProvider method run.

@Override
public final void run(HashCache cache) throws IOException {
    Path path = generator.getOutputFolder();
    registerRecipes();
    for (Map.Entry<ResourceLocation, RecipeBuilder> entry : recipes.entrySet()) {
        ResourceLocation id = entry.getKey();
        FinishedRecipe finishedRecipe = entry.getValue().build();
        saveRecipe(cache, finishedRecipe.serializeRecipe(), path.resolve("data/" + id.getNamespace() + "/recipes/" + id.getPath() + ".json"));
        JsonObject advancement = finishedRecipe.serializeAdvancement();
        if (advancement != null) {
            saveRecipeAdvancement(cache, advancement, path.resolve("data/" + id.getNamespace() + "/advancements/" + id.getPath() + ".json"));
        }
    }
}
Also used : Path(java.nio.file.Path) FinishedRecipe(net.minecraft.data.recipes.FinishedRecipe) ResourceLocation(net.minecraft.resources.ResourceLocation) JsonObject(com.google.gson.JsonObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with FinishedRecipe

use of net.minecraft.data.recipes.FinishedRecipe in project Mohist by MohistMC.

the class ForgeRecipeProvider method buildCraftingRecipes.

@Override
protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
    replace(Items.STICK, Tags.Items.RODS_WOODEN);
    replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD);
    replace(Items.IRON_INGOT, Tags.Items.INGOTS_IRON);
    replace(Items.NETHERITE_INGOT, Tags.Items.INGOTS_NETHERITE);
    replace(Items.COPPER_INGOT, Tags.Items.INGOTS_COPPER);
    replace(Items.AMETHYST_SHARD, Tags.Items.GEMS_AMETHYST);
    replace(Items.DIAMOND, Tags.Items.GEMS_DIAMOND);
    replace(Items.EMERALD, Tags.Items.GEMS_EMERALD);
    replace(Items.CHEST, Tags.Items.CHESTS_WOODEN);
    replace(Blocks.COBBLESTONE, Tags.Items.COBBLESTONE_NORMAL);
    replace(Blocks.COBBLED_DEEPSLATE, Tags.Items.COBBLESTONE_DEEPSLATE);
    exclude(Blocks.GOLD_BLOCK);
    exclude(Items.GOLD_NUGGET);
    exclude(Blocks.IRON_BLOCK);
    exclude(Items.IRON_NUGGET);
    exclude(Blocks.DIAMOND_BLOCK);
    exclude(Blocks.EMERALD_BLOCK);
    exclude(Blocks.NETHERITE_BLOCK);
    exclude(Blocks.COPPER_BLOCK);
    exclude(Blocks.AMETHYST_BLOCK);
    exclude(Blocks.COBBLESTONE_STAIRS);
    exclude(Blocks.COBBLESTONE_SLAB);
    exclude(Blocks.COBBLESTONE_WALL);
    exclude(Blocks.COBBLED_DEEPSLATE_STAIRS);
    exclude(Blocks.COBBLED_DEEPSLATE_SLAB);
    exclude(Blocks.COBBLED_DEEPSLATE_WALL);
    super.buildCraftingRecipes(vanilla -> {
        FinishedRecipe modified = enhance(vanilla);
        if (modified != null)
            consumer.accept(modified);
    });
}
Also used : FinishedRecipe(net.minecraft.data.recipes.FinishedRecipe)

Example 8 with FinishedRecipe

use of net.minecraft.data.recipes.FinishedRecipe in project FTB-Industrial-Contraptions by FTBTeam.

the class FTBICVanillaRecipes method add.

@Override
public void add(Consumer<FinishedRecipe> consumer) {
    Function<TagKey<Item>, InventoryChangeTrigger.TriggerInstance> tagKeyHas = (e) -> RecipeProvider.inventoryTrigger(ItemPredicate.Builder.item().of(e).build());
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(BLAZE_ROD)).inputItem(Ingredient.of(BLAZE_ROD)).outputItem(new ItemStack(Items.BLAZE_POWDER, 5)).save(consumer, maceratingLoc("blaze_powder"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", has(Items.BONE)).inputItem(Ingredient.of(Items.BONE)).outputItem(new ItemStack(Items.BONE_MEAL, 5)).save(consumer, maceratingLoc("bone_meal"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(COBBLESTONE)).inputItem(Ingredient.of(COBBLESTONE)).outputItem(new ItemStack(Items.GRAVEL)).save(consumer, maceratingLoc("gravel"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(STONE)).inputItem(Ingredient.of(STONE)).outputItem(new ItemStack(Items.COBBLESTONE)).save(consumer, maceratingLoc("cobblestone"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(GRAVEL)).inputItem(Ingredient.of(GRAVEL)).outputItem(new ItemStack(Items.SAND)).save(consumer, maceratingLoc("sand"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", has(Items.SNOW_BLOCK)).inputItem(Ingredient.of(Items.SNOW_BLOCK)).outputItem(new ItemStack(Items.SNOWBALL)).save(consumer, maceratingLoc("snowball"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(WOOL)).inputItem(Ingredient.of(WOOL)).outputItem(new ItemStack(Items.STRING, 4)).save(consumer, maceratingLoc("string"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(OBSIDIAN)).inputItem(Ingredient.of(OBSIDIAN)).outputItem(new ItemStack(OBSIDIAN_DUST_ITEM)).save(consumer, maceratingLoc("obsidian_dust"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", tagKeyHas.apply(ENDER_PEARL)).inputItem(Ingredient.of(ENDER_PEARL)).outputItem(new ItemStack(ENDER_DUST_ITEM)).save(consumer, maceratingLoc("ender_dust"));
    // MachineRecipeBuilder.macerating()
    // .unlockedBy("has_item", tagKeyHas.apply(PLANKS))
    // .inputItem(Ingredient.of(PLANKS))
    // .outputItem(new ItemStack(SAWDUST_ITEM))
    // .save(consumer, maceratingLoc("sawdust"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", has(Items.COAL)).inputItem(Ingredient.of(Items.COAL)).outputItem(new ItemStack(COAL_DUST_ITEM)).save(consumer, maceratingLoc("coal_dust"));
    MachineRecipeBuilder.macerating().unlockedBy("has_item", has(Items.CHARCOAL)).inputItem(Ingredient.of(Items.CHARCOAL)).outputItem(new ItemStack(CHARCOAL_DUST_ITEM)).save(consumer, maceratingLoc("charcoal_dust"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", tagKeyHas.apply(GRAVEL)).inputItem(Ingredient.of(GRAVEL)).outputItem(new ItemStack(Items.FLINT)).save(consumer, separatingLoc("flint"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", tagKeyHas.apply(QUARTZ)).inputItem(Ingredient.of(QUARTZ)).outputItem(new ItemStack(SILICON_ITEM, 3)).save(consumer, separatingLoc("silicon_from_quartz"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", tagKeyHas.apply(SAND)).inputItem(Ingredient.of(SAND)).outputItem(new ItemStack(SILICON_ITEM), 0.20).outputItem(new ItemStack(SILICON_ITEM), 0.05).save(consumer, separatingLoc("silicon_from_sand"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(Items.SEA_PICKLE)).inputItem(Ingredient.of(Items.SEA_PICKLE)).outputItem(new ItemStack(Items.SEAGRASS), 0.50).outputItem(new ItemStack(Items.GLOWSTONE_DUST), 0.03).save(consumer, separatingLoc("glowstone_dust"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(Items.MAGMA_CREAM)).inputItem(Ingredient.of(Items.MAGMA_CREAM)).outputItem(new ItemStack(Items.SLIME_BALL)).outputItem(new ItemStack(Items.BLAZE_POWDER), 0.25).save(consumer, separatingLoc("slime_ball"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(Items.SUGAR_CANE)).inputItem(Ingredient.of(Items.SUGAR_CANE)).outputItem(new ItemStack(Items.SUGAR, 2)).outputItem(new ItemStack(Items.PAPER), 0.50).save(consumer, separatingLoc("sugar"));
    MachineRecipeBuilder.compressing().unlockedBy("has_item", has(FLUID_CELL)).inputItem(waterCell()).outputItem(new ItemStack(Items.SNOWBALL)).save(consumer, compressingLoc("snowball"));
    MachineRecipeBuilder.compressing().unlockedBy("has_item", has(Items.SNOWBALL)).inputItem(Ingredient.of(Items.SNOWBALL)).outputItem(new ItemStack(Items.ICE)).save(consumer, compressingLoc("ice"));
    MachineRecipeBuilder.compressing().unlockedBy("has_item", has(GRAPHENE)).inputItem(Ingredient.of(GRAPHENE)).outputItem(new ItemStack(Items.DIAMOND)).save(consumer, compressingLoc("diamond"));
    MachineRecipeBuilder.compressing().unlockedBy("has_item", has(Items.SUGAR_CANE)).inputItem(Ingredient.of(Items.SUGAR_CANE), 3).outputItem(new ItemStack(Items.PAPER, 5)).save(consumer, compressingLoc("paper"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(RUBBERWOOD_LOG)).inputItem(Ingredient.of(RUBBERWOOD_LOG)).outputItem(new ItemStack(LATEX), 0.80).save(consumer, separatingLoc("latex_from_log"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(RUBBERWOOD_SAPLING)).inputItem(Ingredient.of(RUBBERWOOD_SAPLING)).outputItem(new ItemStack(LATEX)).save(consumer, separatingLoc("latex_from_sapling"));
    MachineRecipeBuilder.separating().unlockedBy("has_item", has(RUBBERWOOD_LEAVES)).inputItem(Ingredient.of(RUBBERWOOD_LEAVES)).outputItem(new ItemStack(LATEX), 0.35).outputItem(new ItemStack(RUBBERWOOD_SAPLING), 0.05).save(consumer, separatingLoc("latex_from_leaves"));
// MachineRecipeBuilder.separating()
// .unlockedBy("has_item", has(Items.GUNPOWDER))
// .inputItem(Ingredient.of(Items.GUNPOWDER))
// .outputItem(new ItemStack(COAL_DUST_ITEM))
// .outputItem(new ItemStack(SULFUR_ITEM), 0.50)
// .save(consumer, separatingLoc("sulfur_from_gunpowder"));
}
Also used : TagKey(net.minecraft.tags.TagKey) Consumer(java.util.function.Consumer) InventoryChangeTrigger(net.minecraft.advancements.critereon.InventoryChangeTrigger) Items(net.minecraft.world.item.Items) Item(net.minecraft.world.item.Item) RecipeProvider(net.minecraft.data.recipes.RecipeProvider) ItemStack(net.minecraft.world.item.ItemStack) ItemPredicate(net.minecraft.advancements.critereon.ItemPredicate) DataGenerator(net.minecraft.data.DataGenerator) FinishedRecipe(net.minecraft.data.recipes.FinishedRecipe) Function(java.util.function.Function) Ingredient(net.minecraft.world.item.crafting.Ingredient) TagKey(net.minecraft.tags.TagKey) ItemStack(net.minecraft.world.item.ItemStack)

Example 9 with FinishedRecipe

use of net.minecraft.data.recipes.FinishedRecipe in project refinedstorage by refinedmods.

the class RecipeGenerator method buildCraftingRecipes.

@Override
protected void buildCraftingRecipes(Consumer<FinishedRecipe> recipeAcceptor) {
    // Tag + Color -> Colored Block
    RSItems.COLORED_ITEM_TAGS.forEach((tag, map) -> map.forEach((color, item) -> ShapelessRecipeBuilder.shapeless(item.get()).requires(tag).requires(color.getTag()).group(RS.ID).unlockedBy("refinedstorage:controller", InventoryChangeTrigger.TriggerInstance.hasItems(RSItems.CONTROLLER.get(ColorMap.DEFAULT_COLOR).get())).save(recipeAcceptor, new ResourceLocation(RS.ID, "coloring_recipes/" + item.getId().getPath()))));
    // Crafting Grid
    RSItems.CRAFTING_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapeless(item.get()).requires(RSItems.GRID.get(color).get()).requires(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get()).requires(ItemTags.create(new ResourceLocation(RS.ID, "crafting_tables"))).unlockedBy(GRID_ID, InventoryChangeTrigger.TriggerInstance.hasItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get())).save(recipeAcceptor, new ResourceLocation(RS.ID, "crafting_grid/" + item.getId().getPath())));
    // Fluid Grid
    RSItems.FLUID_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapeless(item.get()).requires(RSItems.GRID.get(color).get()).requires(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get()).requires(Items.BUCKET).unlockedBy(GRID_ID, InventoryChangeTrigger.TriggerInstance.hasItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get())).save(recipeAcceptor, new ResourceLocation(RS.ID, "fluid_grid/" + item.getId().getPath())));
    // Pattern Grid
    RSItems.PATTERN_GRID.forEach((color, item) -> ShapelessRecipeBuilder.shapeless(item.get()).requires(RSItems.GRID.get(color).get()).requires(RSItems.PROCESSORS.get(ProcessorItem.Type.ADVANCED).get()).requires(RSItems.PATTERN.get()).unlockedBy(GRID_ID, InventoryChangeTrigger.TriggerInstance.hasItems(RSItems.GRID.get(ColorMap.DEFAULT_COLOR).get())).save(recipeAcceptor, new ResourceLocation(RS.ID, "pattern_grid/" + item.getId().getPath())));
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) InventoryChangeTrigger(net.minecraft.advancements.critereon.InventoryChangeTrigger) Items(net.minecraft.world.item.Items) ItemTags(net.minecraft.tags.ItemTags) RecipeProvider(net.minecraft.data.recipes.RecipeProvider) FinishedRecipe(net.minecraft.data.recipes.FinishedRecipe) Consumer(java.util.function.Consumer) RS(com.refinedmods.refinedstorage.RS) ColorMap(com.refinedmods.refinedstorage.util.ColorMap) ShapelessRecipeBuilder(net.minecraft.data.recipes.ShapelessRecipeBuilder) ProcessorItem(com.refinedmods.refinedstorage.item.ProcessorItem) DataGenerator(net.minecraft.data.DataGenerator) RSItems(com.refinedmods.refinedstorage.RSItems) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 10 with FinishedRecipe

use of net.minecraft.data.recipes.FinishedRecipe in project MinecraftForge by MinecraftForge.

the class ForgeRecipeProvider method buildCraftingRecipes.

@Override
protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) {
    replace(Items.STICK, Tags.Items.RODS_WOODEN);
    replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD);
    replace(Items.IRON_INGOT, Tags.Items.INGOTS_IRON);
    replace(Items.NETHERITE_INGOT, Tags.Items.INGOTS_NETHERITE);
    replace(Items.COPPER_INGOT, Tags.Items.INGOTS_COPPER);
    replace(Items.AMETHYST_SHARD, Tags.Items.GEMS_AMETHYST);
    replace(Items.DIAMOND, Tags.Items.GEMS_DIAMOND);
    replace(Items.EMERALD, Tags.Items.GEMS_EMERALD);
    replace(Items.CHEST, Tags.Items.CHESTS_WOODEN);
    replace(Blocks.COBBLESTONE, Tags.Items.COBBLESTONE_NORMAL);
    replace(Blocks.COBBLED_DEEPSLATE, Tags.Items.COBBLESTONE_DEEPSLATE);
    exclude(Blocks.GOLD_BLOCK);
    exclude(Items.GOLD_NUGGET);
    exclude(Blocks.IRON_BLOCK);
    exclude(Items.IRON_NUGGET);
    exclude(Blocks.DIAMOND_BLOCK);
    exclude(Blocks.EMERALD_BLOCK);
    exclude(Blocks.NETHERITE_BLOCK);
    exclude(Blocks.COPPER_BLOCK);
    exclude(Blocks.AMETHYST_BLOCK);
    exclude(Blocks.COBBLESTONE_STAIRS);
    exclude(Blocks.COBBLESTONE_SLAB);
    exclude(Blocks.COBBLESTONE_WALL);
    exclude(Blocks.COBBLED_DEEPSLATE_STAIRS);
    exclude(Blocks.COBBLED_DEEPSLATE_SLAB);
    exclude(Blocks.COBBLED_DEEPSLATE_WALL);
    super.buildCraftingRecipes(vanilla -> {
        FinishedRecipe modified = enhance(vanilla);
        if (modified != null)
            consumer.accept(modified);
    });
}
Also used : FinishedRecipe(net.minecraft.data.recipes.FinishedRecipe)

Aggregations

FinishedRecipe (net.minecraft.data.recipes.FinishedRecipe)18 ResourceLocation (net.minecraft.resources.ResourceLocation)13 Consumer (java.util.function.Consumer)11 Ingredient (net.minecraft.world.item.crafting.Ingredient)11 DataGenerator (net.minecraft.data.DataGenerator)10 ItemStack (net.minecraft.world.item.ItemStack)10 Items (net.minecraft.world.item.Items)10 ShapelessRecipeBuilder (net.minecraft.data.recipes.ShapelessRecipeBuilder)9 ItemTags (net.minecraft.tags.ItemTags)9 ItemLike (net.minecraft.world.level.ItemLike)9 Function (java.util.function.Function)8 ShapedRecipeBuilder (net.minecraft.data.recipes.ShapedRecipeBuilder)8 Blocks (net.minecraft.world.level.block.Blocks)8 CompoundIngredient (slimeknights.mantle.recipe.data.CompoundIngredient)8 ItemCastingRecipeBuilder (slimeknights.tconstruct.library.recipe.casting.ItemCastingRecipeBuilder)8 FluidTags (net.minecraft.tags.FluidTags)7 EntityType (net.minecraft.world.entity.EntityType)7 Fluids (net.minecraft.world.level.material.Fluids)7 Tags (net.minecraftforge.common.Tags)7 ConditionalRecipe (net.minecraftforge.common.crafting.ConditionalRecipe)7