Skip to content

Commit

Permalink
Merge pull request #12 from Gu-ZT/recipe
Browse files Browse the repository at this point in the history
统一铁砧处理配方
  • Loading branch information
Gu-ZT authored Mar 26, 2024
2 parents 551588b + 0dba11d commit 72bcb33
Show file tree
Hide file tree
Showing 39 changed files with 1,947 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@

import dev.dubhe.anvilcraft.AnvilCraft;
import dev.dubhe.anvilcraft.data.generator.recipe.*;
import dev.dubhe.anvilcraft.data.recipe.TagIngredient;
import dev.dubhe.anvilcraft.data.recipe.anvil.item.ItemAnvilRecipe;
import dev.dubhe.anvilcraft.data.recipe.anvil.item.ItemAnvilRecipeBuilder;
import dev.dubhe.anvilcraft.data.recipe.anvil.AnvilRecipe;
import dev.dubhe.anvilcraft.data.recipe.anvil.RecipePredicate;
import dev.dubhe.anvilcraft.data.recipe.anvil.predicate.HasItemIngredient;
import dev.dubhe.anvilcraft.init.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeCategory;
import net.minecraft.nbt.IntTag;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.function.Consumer;

public class MyRecipesGenerator extends FabricRecipeProvider {
Expand All @@ -31,109 +32,57 @@ public MyRecipesGenerator(FabricDataOutput output) {
public void buildRecipes(Consumer<FinishedRecipe> exporter) {
VanillaRecipesGenerator.buildRecipes(exporter);
// 铁砧物品处理
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.CAULDRON)
.component(BlockTags.CAMPFIRES)
.result(ModItems.ROYAL_STEEL_INGOT)
.requires(Items.IRON_INGOT)
.requires(Items.EMERALD)
.requires(Items.DIAMOND)
.requires(Items.AMETHYST_SHARD)
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.hasBlock(Blocks.CAULDRON)
.hasBlock(new Vec3(0.0, -2.0, 0.0), BlockTags.CAMPFIRES)
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), Items.IRON_INGOT)
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), Items.EMERALD)
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), Items.DIAMOND)
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), Items.AMETHYST_SHARD)
.spawnItem(new Vec3(0.0, -1.0, 0.0), ModItems.ROYAL_STEEL_INGOT)
.unlockedBy(MyRecipesGenerator.hasItem(Items.IRON_INGOT), FabricRecipeProvider.has(Items.IRON_INGOT))
.unlockedBy(MyRecipesGenerator.hasItem(Items.EMERALD), FabricRecipeProvider.has(Items.EMERALD))
.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.SMITHING_TABLE)
.requires(Items.ANCIENT_DEBRIS)
.result(ModItems.DEBRIS_SCRAP, 1)
.result(Items.ANCIENT_DEBRIS, 1)
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.hasBlock(Blocks.SMITHING_TABLE)
.hasItem(Items.ANCIENT_DEBRIS)
.spawnItem(ModItems.DEBRIS_SCRAP)
.unlockedBy(MyRecipesGenerator.hasItem(Items.ANCIENT_DEBRIS), FabricRecipeProvider.has(Items.ANCIENT_DEBRIS))
.location(ItemAnvilRecipe.Location.UP)
.resultLocation(ItemAnvilRecipe.Location.UP)
.save(exporter);
TagIngredient ingredient = TagIngredient.of(TagIngredient.Value.of(Items.ELYTRA).with("Damage", IntTag.valueOf(0)));
ItemPredicate.Builder predicate = ItemPredicate.Builder.item().of(Items.ELYTRA)
.hasDurability(MinMaxBounds.Ints.atLeast(Items.ELYTRA.getMaxDamage()));
RecipePredicate hasItemIngredient = new HasItemIngredient(Vec3.ZERO, predicate.build());
ItemStack result = Items.ELYTRA.getDefaultInstance();
result.setDamageValue(432);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.SMITHING_TABLE)
.requires(ingredient)
.result(ModItems.ELYTRA_FRAME, 1)
.result(Items.PHANTOM_MEMBRANE, 1)
.result(result)
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.hasBlock(Blocks.SMITHING_TABLE)
.addPredicates(hasItemIngredient)
.spawnItem(ModItems.ELYTRA_FRAME)
.spawnItem(Items.PHANTOM_MEMBRANE)
.spawnItem(result)
.unlockedBy(MyRecipesGenerator.hasItem(Items.ELYTRA), FabricRecipeProvider.has(Items.ELYTRA))
.location(ItemAnvilRecipe.Location.UP)
.resultLocation(ItemAnvilRecipe.Location.UP)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.WATER_CAULDRON)
.requires(ModItems.SEED_OF_THE_SEA)
.result(ModItems.FRUIT_OF_THE_SEA)
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.SEED_OF_THE_SEA), FabricRecipeProvider.has(ModItems.SEED_OF_THE_SEA))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.WATER_CAULDRON)
.requires(ModItems.SPONGE_GEMMULE)
.result(Items.WET_SPONGE)
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.SPONGE_GEMMULE), FabricRecipeProvider.has(ModItems.SPONGE_GEMMULE))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.POWDER_SNOW_CAULDRON)
.requires(ModItems.SEED_OF_THE_SEA)
.result(ModItems.TEAR_OF_THE_SEA)
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.SEED_OF_THE_SEA), FabricRecipeProvider.has(ModItems.SEED_OF_THE_SEA))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.CAULDRON)
.requires(ModItems.FRUIT_OF_THE_SEA)
.result(ModItems.KERNEL_OF_THE_SEA)
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.FRUIT_OF_THE_SEA), FabricRecipeProvider.has(ModItems.FRUIT_OF_THE_SEA))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.CAULDRON)
.requires(Items.PRISMARINE_SHARD)
.requires(ModItems.TEAR_OF_THE_SEA)
.result(ModItems.BLADE_OF_THE_SEA)
.unlockedBy(MyRecipesGenerator.hasItem(Items.PRISMARINE_SHARD), FabricRecipeProvider.has(Items.PRISMARINE_SHARD))
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.TEAR_OF_THE_SEA), FabricRecipeProvider.has(ModItems.TEAR_OF_THE_SEA))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.SMITHING_TABLE)
.requires(ModItems.KERNEL_OF_THE_SEA)
.result(Items.PRISMARINE_SHARD)
.result(Items.HEART_OF_THE_SEA)
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.hasBlock(Blocks.SMITHING_TABLE)
.hasItemIngredient(ModItems.KERNEL_OF_THE_SEA)
.spawnItem(Items.HEART_OF_THE_SEA)
.spawnItem(Items.PRISMARINE_SHARD)
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.KERNEL_OF_THE_SEA), FabricRecipeProvider.has(ModItems.KERNEL_OF_THE_SEA))
.location(ItemAnvilRecipe.Location.UP)
.resultLocation(ItemAnvilRecipe.Location.UP)
.save(exporter);
ItemAnvilRecipeBuilder.item(RecipeCategory.MISC)
.component(Blocks.CAULDRON)
.requires(Items.SOUL_SOIL)
.requires(ModItems.NETHERITE_COIL)
.result(Items.ANCIENT_DEBRIS)
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.hasBlock(Blocks.SOUL_SOIL)
.hasItemIngredient(ModItems.NETHERITE_COIL)
.setBlock(Blocks.ANCIENT_DEBRIS)
.unlockedBy(MyRecipesGenerator.hasItem(Items.SOUL_SOIL), FabricRecipeProvider.has(Items.SOUL_SOIL))
.unlockedBy(MyRecipesGenerator.hasItem(ModItems.NETHERITE_COIL), FabricRecipeProvider.has(ModItems.NETHERITE_COIL))
.location(ItemAnvilRecipe.Location.IN)
.resultLocation(ItemAnvilRecipe.Location.IN)
.save(exporter);
SmashRecipesGenerator.buildRecipes(exporter);
CookingRecipesGenerator.buildRecipes(exporter);
CompressRecipesGenerator.buildRecipes(exporter);
StampingRecipesGenerator.buildRecipes(exporter);
BulgingRecipesGenerator.buildRecipes(exporter);
BulgingAndCrystallizeRecipesGenerator.buildRecipes(exporter);
// 铁砧方块处理
SqueezeRecipesGenerator.buildRecipes(exporter);
SmashBlockRecipesGenerator.buildRecipes(exporter);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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.AnvilRecipe;
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 net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.phys.Vec3;

import java.util.function.Consumer;

public abstract class BulgingAndCrystallizeRecipesGenerator {
private BulgingAndCrystallizeRecipesGenerator() {
}

public static void buildRecipes(Consumer<FinishedRecipe> exporter) {
bulging(Items.DIRT, Items.CLAY, exporter);
bulging(Items.CRIMSON_FUNGUS, Items.NETHER_WART_BLOCK, exporter);
bulging(Items.WARPED_FUNGUS, Items.WARPED_WART_BLOCK, exporter);
bulging(Items.SPIDER_EYE, Items.FERMENTED_SPIDER_EYE, exporter);
bulging(Items.BRAIN_CORAL, Items.BRAIN_CORAL_BLOCK, exporter);
bulging(Items.BUBBLE_CORAL, Items.BUBBLE_CORAL_BLOCK, exporter);
bulging(Items.FIRE_CORAL, Items.FIRE_CORAL_BLOCK, exporter);
bulging(Items.HORN_CORAL, Items.HORN_CORAL_BLOCK, exporter);
bulging(Items.TUBE_CORAL, Items.TUBE_CORAL_BLOCK, exporter);
bulging(ModItems.FLOUR, ModItems.DOUGH, exporter);
bulging(ModItems.SEED_OF_THE_SEA, ModItems.FRUIT_OF_THE_SEA, exporter);
crystallize(ModItems.SEED_OF_THE_SEA, ModItems.TEAR_OF_THE_SEA, exporter);
bulging(ModItems.SPONGE_GEMMULE, Items.WET_SPONGE, exporter);
}

public static void bulging(Item item, Item item1, Consumer<FinishedRecipe> exporter) {
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2))
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("bulging/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_3"));
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 1))
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("bulging/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_2"));
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 1))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.CAULDRON)
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("bulging/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_1"));
}

public static void crystallize(Item item, Item item1, Consumer<FinishedRecipe> exporter) {
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2))
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("crystallize/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_3"));
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 1))
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("crystallize/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_2"));
AnvilRecipe.Builder.create(RecipeCategory.MISC)
.icon(item1)
.hasBlock(Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 1))
.hasItemIngredient(new Vec3(0.0, -1.0, 0.0), item)
.spawnItem(new Vec3(0.0, -1.0, 0.0), item1)
.setBlock(Blocks.CAULDRON)
.unlockedBy(MyRecipesGenerator.hasItem(item), FabricRecipeProvider.has(item))
.save(exporter, AnvilCraft.of("crystallize/" + BuiltInRegistries.ITEM.getKey(item1).getPath() + "_1"));
}
}

This file was deleted.

Loading

0 comments on commit 72bcb33

Please sign in to comment.