diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/MyRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/MyRecipesGenerator.java index ee084626b..dfd094f6a 100644 --- a/src/main/java/dev/dubhe/anvilcraft/data/generator/MyRecipesGenerator.java +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/MyRecipesGenerator.java @@ -46,30 +46,6 @@ public void buildRecipes(Consumer exporter) { .unlockedBy(MyRecipesGenerator.hasItem(Items.DIAMOND), FabricRecipeProvider.has(Items.DIAMOND)) .unlockedBy(MyRecipesGenerator.hasItem(Items.AMETHYST_SHARD), FabricRecipeProvider.has(Items.AMETHYST_SHARD)) .save(exporter, AnvilCraft.of("craft_a_royal_steel_ingot")); - ItemAnvilRecipeBuilder.item(RecipeCategory.MISC) - .component(Blocks.IRON_TRAPDOOR) - .requires(Items.HEART_OF_THE_SEA) - .result(ModItems.SEED_OF_THE_SEA, 4) - .unlockedBy(MyRecipesGenerator.hasItem(Items.HEART_OF_THE_SEA), FabricRecipeProvider.has(Items.HEART_OF_THE_SEA)) - .location(ItemAnvilRecipe.Location.UP) - .resultLocation(ItemAnvilRecipe.Location.IN) - .save(exporter); - ItemAnvilRecipeBuilder.item(RecipeCategory.MISC) - .component(Blocks.IRON_TRAPDOOR) - .requires(Items.WET_SPONGE) - .result(ModItems.SPONGE_GEMMULE, 2) - .unlockedBy(MyRecipesGenerator.hasItem(Items.WET_SPONGE), FabricRecipeProvider.has(Items.WET_SPONGE)) - .location(ItemAnvilRecipe.Location.UP) - .resultLocation(ItemAnvilRecipe.Location.IN) - .save(exporter); - ItemAnvilRecipeBuilder.item(RecipeCategory.MISC) - .component(Blocks.IRON_TRAPDOOR) - .requires(Items.NETHER_STAR) - .result(ModItems.NETHER_STAR_SHARD, 4) - .unlockedBy(MyRecipesGenerator.hasItem(Items.NETHER_STAR), FabricRecipeProvider.has(Items.NETHER_STAR)) - .location(ItemAnvilRecipe.Location.UP) - .resultLocation(ItemAnvilRecipe.Location.IN) - .save(exporter); ItemAnvilRecipeBuilder.item(RecipeCategory.MISC) .component(Blocks.SMITHING_TABLE) .requires(Items.ANCIENT_DEBRIS) @@ -153,6 +129,7 @@ public void buildRecipes(Consumer exporter) { .location(ItemAnvilRecipe.Location.IN) .resultLocation(ItemAnvilRecipe.Location.IN) .save(exporter); + SmashRecipesGenerator.buildRecipes(exporter); CookingRecipesGenerator.buildRecipes(exporter); CompressRecipesGenerator.buildRecipes(exporter); StampingRecipesGenerator.buildRecipes(exporter); diff --git a/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java new file mode 100644 index 000000000..5f5976474 --- /dev/null +++ b/src/main/java/dev/dubhe/anvilcraft/data/generator/recipe/SmashRecipesGenerator.java @@ -0,0 +1,41 @@ +package dev.dubhe.anvilcraft.data.generator.recipe; + +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.data.generator.MyRecipesGenerator; +import dev.dubhe.anvilcraft.data.recipe.anvil.item.ItemAnvilRecipe; +import dev.dubhe.anvilcraft.data.recipe.anvil.item.ItemAnvilRecipeBuilder; +import dev.dubhe.anvilcraft.init.ModItems; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.block.Blocks; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +public abstract class SmashRecipesGenerator { + private SmashRecipesGenerator() { + } + + public static void buildRecipes(Consumer exporter) { + smash(Items.HEART_OF_THE_SEA, ModItems.SEED_OF_THE_SEA, 4, exporter); + smash(Items.WET_SPONGE, ModItems.SPONGE_GEMMULE, 2, exporter); + smash(Items.NETHER_STAR, ModItems.NETHER_STAR_SHARD, 4, exporter); + smash(ModItems.HOLLOW_MAGNET_BLOCK, ModItems.MAGNET_INGOT, 8, exporter); + smash(ModItems.MAGNET_BLOCK, ModItems.MAGNET_INGOT, 9, exporter); + } + + public static void smash(Item item, @NotNull Item item1, int count, Consumer exporter) { + ItemAnvilRecipeBuilder.item(RecipeCategory.MISC) + .requires(item) + .result(item1, count) + .component(Blocks.IRON_TRAPDOOR) + .location(ItemAnvilRecipe.Location.UP) + .resultLocation(ItemAnvilRecipe.Location.IN) + .unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item)) + .save(exporter, AnvilCraft.of("smash/" + BuiltInRegistries.ITEM.getKey(item).getPath() + "_2_" + BuiltInRegistries.ITEM.getKey(item1).getPath())); + } +}