diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidIgnemRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidIgnemRecipe.java index bee99f1166..5c06e1395d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidIgnemRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidIgnemRecipe.java @@ -18,6 +18,7 @@ import net.minecraft.world.level.biome.Biome; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import vazkii.botania.api.recipe.StateIngredient; @@ -25,10 +26,15 @@ public class OrechidIgnemRecipe extends OrechidRecipe { public OrechidIgnemRecipe(StateIngredient input, StateIngredient output, int weight, - CacheableFunction successFunction, int weightBonus, TagKey biomes) { + @Nullable CacheableFunction successFunction, int weightBonus, TagKey biomes) { super(input, output, weight, successFunction, weightBonus, biomes); } + public OrechidIgnemRecipe(StateIngredient input, StateIngredient output, int weight, + @Nullable CacheableFunction successFunction) { + this(input, output, weight, successFunction, 0, null); + } + private OrechidIgnemRecipe(OrechidRecipe orechidRecipe) { this(orechidRecipe.getInput(), orechidRecipe.getOutput(), orechidRecipe.getWeight(), orechidRecipe.getSuccessFunction().orElse(null), orechidRecipe.getWeightBonus(), diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/BrewProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/BrewProvider.java index 49a78c8a72..5e25f5cc8e 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/BrewProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/BrewProvider.java @@ -8,24 +8,16 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.Nullable; - -import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.brew.Brew; import vazkii.botania.common.brew.BotaniaBrews; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; +import vazkii.botania.common.crafting.BotanicalBreweryRecipe; import vazkii.botania.common.item.BotaniaItems; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @@ -42,74 +34,30 @@ public String getName() { @Override public void buildRecipes(RecipeOutput consumer) { - consumer.accept(new FinishedRecipe(idFor("speed"), BotaniaBrews.speed, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SUGAR), Ingredient.of(Items.REDSTONE))); - consumer.accept(new FinishedRecipe(idFor("strength"), BotaniaBrews.strength, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.BLAZE_POWDER), Ingredient.of(Items.GLOWSTONE_DUST))); - consumer.accept(new FinishedRecipe(idFor("haste"), BotaniaBrews.haste, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SUGAR), Ingredient.of(Items.GOLD_NUGGET))); - consumer.accept(new FinishedRecipe(idFor("healing"), BotaniaBrews.healing, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GLISTERING_MELON_SLICE), Ingredient.of(Items.POTATO))); - consumer.accept(new FinishedRecipe(idFor("jump_boost"), BotaniaBrews.jumpBoost, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FEATHER), Ingredient.of(Items.CARROT))); - consumer.accept(new FinishedRecipe(idFor("regeneration"), BotaniaBrews.regen, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GHAST_TEAR), Ingredient.of(Items.GLOWSTONE_DUST))); - consumer.accept(new FinishedRecipe(idFor("weak_regeneration"), BotaniaBrews.regenWeak, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GHAST_TEAR), Ingredient.of(Items.REDSTONE))); - consumer.accept(new FinishedRecipe(idFor("resistance"), BotaniaBrews.resistance, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.IRON_INGOT), Ingredient.of(Items.LEATHER))); - consumer.accept(new FinishedRecipe(idFor("fire_resistance"), BotaniaBrews.fireResistance, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.MAGMA_CREAM), Ingredient.of(Blocks.NETHERRACK))); - consumer.accept(new FinishedRecipe(idFor("water_breathing"), BotaniaBrews.waterBreathing, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.PRISMARINE_CRYSTALS), Ingredient.of(Items.GLOWSTONE_DUST))); - consumer.accept(new FinishedRecipe(idFor("invisibility"), BotaniaBrews.invisibility, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SNOWBALL), Ingredient.of(Items.GLOWSTONE_DUST))); - consumer.accept(new FinishedRecipe(idFor("night_vision"), BotaniaBrews.nightVision, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SPIDER_EYE), Ingredient.of(Items.GOLDEN_CARROT))); - consumer.accept(new FinishedRecipe(idFor("absorption"), BotaniaBrews.absorption, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GOLDEN_APPLE), Ingredient.of(Items.POTATO))); - - consumer.accept(new FinishedRecipe(idFor("overload"), BotaniaBrews.overload, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.BLAZE_POWDER), Ingredient.of(Items.SUGAR), Ingredient.of(Items.GLOWSTONE_DUST), Ingredient.of(BotaniaItems.manaSteel), Ingredient.of(Items.SPIDER_EYE))); - consumer.accept(new FinishedRecipe(idFor("soul_cross"), BotaniaBrews.soulCross, Ingredient.of(Items.NETHER_WART), Ingredient.of(Blocks.SOUL_SAND), Ingredient.of(Items.PAPER), Ingredient.of(Items.APPLE), Ingredient.of(Items.BONE))); - consumer.accept(new FinishedRecipe(idFor("feather_feet"), BotaniaBrews.featherfeet, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FEATHER), Ingredient.of(Items.LEATHER), Ingredient.of(ItemTags.WOOL))); - consumer.accept(new FinishedRecipe(idFor("emptiness"), BotaniaBrews.emptiness, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GUNPOWDER), Ingredient.of(Items.ROTTEN_FLESH), Ingredient.of(Items.BONE), Ingredient.of(Items.STRING), Ingredient.of(Items.ENDER_PEARL))); - consumer.accept(new FinishedRecipe(idFor("bloodthirst"), BotaniaBrews.bloodthirst, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FERMENTED_SPIDER_EYE), Ingredient.of(Items.LAPIS_LAZULI), Ingredient.of(Items.FIRE_CHARGE), Ingredient.of(Items.IRON_INGOT))); - consumer.accept(new FinishedRecipe(idFor("allure"), BotaniaBrews.allure, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.COD), Ingredient.of(Items.QUARTZ), Ingredient.of(Items.GOLDEN_CARROT))); - consumer.accept(new FinishedRecipe(idFor("clear"), BotaniaBrews.clear, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.QUARTZ), Ingredient.of(Items.EMERALD), Ingredient.of(Items.MELON_SLICE))); + consumer.accept(idFor("speed"), new BotanicalBreweryRecipe(BotaniaBrews.speed, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SUGAR), Ingredient.of(Items.REDSTONE)), null); + consumer.accept(idFor("strength"), new BotanicalBreweryRecipe(BotaniaBrews.strength, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.BLAZE_POWDER), Ingredient.of(Items.GLOWSTONE_DUST)), null); + consumer.accept(idFor("haste"), new BotanicalBreweryRecipe(BotaniaBrews.haste, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SUGAR), Ingredient.of(Items.GOLD_NUGGET)), null); + consumer.accept(idFor("healing"), new BotanicalBreweryRecipe(BotaniaBrews.healing, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GLISTERING_MELON_SLICE), Ingredient.of(Items.POTATO)), null); + consumer.accept(idFor("jump_boost"), new BotanicalBreweryRecipe(BotaniaBrews.jumpBoost, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FEATHER), Ingredient.of(Items.CARROT)), null); + consumer.accept(idFor("regeneration"), new BotanicalBreweryRecipe(BotaniaBrews.regen, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GHAST_TEAR), Ingredient.of(Items.GLOWSTONE_DUST)), null); + consumer.accept(idFor("weak_regeneration"), new BotanicalBreweryRecipe(BotaniaBrews.regenWeak, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GHAST_TEAR), Ingredient.of(Items.REDSTONE)), null); + consumer.accept(idFor("resistance"), new BotanicalBreweryRecipe(BotaniaBrews.resistance, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.IRON_INGOT), Ingredient.of(Items.LEATHER)), null); + consumer.accept(idFor("fire_resistance"), new BotanicalBreweryRecipe(BotaniaBrews.fireResistance, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.MAGMA_CREAM), Ingredient.of(Blocks.NETHERRACK)), null); + consumer.accept(idFor("water_breathing"), new BotanicalBreweryRecipe(BotaniaBrews.waterBreathing, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.PRISMARINE_CRYSTALS), Ingredient.of(Items.GLOWSTONE_DUST)), null); + consumer.accept(idFor("invisibility"), new BotanicalBreweryRecipe(BotaniaBrews.invisibility, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SNOWBALL), Ingredient.of(Items.GLOWSTONE_DUST)), null); + consumer.accept(idFor("night_vision"), new BotanicalBreweryRecipe(BotaniaBrews.nightVision, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.SPIDER_EYE), Ingredient.of(Items.GOLDEN_CARROT)), null); + consumer.accept(idFor("absorption"), new BotanicalBreweryRecipe(BotaniaBrews.absorption, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GOLDEN_APPLE), Ingredient.of(Items.POTATO)), null); + + consumer.accept(idFor("overload"), new BotanicalBreweryRecipe(BotaniaBrews.overload, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.BLAZE_POWDER), Ingredient.of(Items.SUGAR), Ingredient.of(Items.GLOWSTONE_DUST), Ingredient.of(BotaniaItems.manaSteel), Ingredient.of(Items.SPIDER_EYE)), null); + consumer.accept(idFor("soul_cross"), new BotanicalBreweryRecipe(BotaniaBrews.soulCross, Ingredient.of(Items.NETHER_WART), Ingredient.of(Blocks.SOUL_SAND), Ingredient.of(Items.PAPER), Ingredient.of(Items.APPLE), Ingredient.of(Items.BONE)), null); + consumer.accept(idFor("feather_feet"), new BotanicalBreweryRecipe(BotaniaBrews.featherfeet, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FEATHER), Ingredient.of(Items.LEATHER), Ingredient.of(ItemTags.WOOL)), null); + consumer.accept(idFor("emptiness"), new BotanicalBreweryRecipe(BotaniaBrews.emptiness, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.GUNPOWDER), Ingredient.of(Items.ROTTEN_FLESH), Ingredient.of(Items.BONE), Ingredient.of(Items.STRING), Ingredient.of(Items.ENDER_PEARL)), null); + consumer.accept(idFor("bloodthirst"), new BotanicalBreweryRecipe(BotaniaBrews.bloodthirst, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.FERMENTED_SPIDER_EYE), Ingredient.of(Items.LAPIS_LAZULI), Ingredient.of(Items.FIRE_CHARGE), Ingredient.of(Items.IRON_INGOT)), null); + consumer.accept(idFor("allure"), new BotanicalBreweryRecipe(BotaniaBrews.allure, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.COD), Ingredient.of(Items.QUARTZ), Ingredient.of(Items.GOLDEN_CARROT)), null); + consumer.accept(idFor("clear"), new BotanicalBreweryRecipe(BotaniaBrews.clear, Ingredient.of(Items.NETHER_WART), Ingredient.of(Items.QUARTZ), Ingredient.of(Items.EMERALD), Ingredient.of(Items.MELON_SLICE)), null); } private static ResourceLocation idFor(String s) { return prefix("brew/" + s); } - - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - private final ResourceLocation id; - private final Brew brew; - private final Ingredient[] inputs; - - private FinishedRecipe(ResourceLocation id, Brew brew, Ingredient... inputs) { - this.id = id; - this.brew = brew; - this.inputs = inputs; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.addProperty("brew", BotaniaAPI.instance().getBrewRegistry().getKey(brew).toString()); - JsonArray ingredients = new JsonArray(); - for (Ingredient ingr : inputs) { - ingredients.add(ingr.toJson()); - } - json.add("ingredients", ingredients); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.BREW_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/ElvenTradeProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/ElvenTradeProvider.java index a3d15a6136..eb8c258785 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/ElvenTradeProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/ElvenTradeProvider.java @@ -8,31 +8,21 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import net.minecraft.data.PackOutput; -import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.Nullable; - import vazkii.botania.common.block.BotaniaBlocks; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; -import vazkii.botania.common.helper.ItemNBTHelper; +import vazkii.botania.common.crafting.ElvenTradeRecipe; +import vazkii.botania.common.crafting.LexiconElvenTradeRecipe; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.lib.BotaniaTags; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; - import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class ElvenTradeProvider extends BotaniaRecipeProvider { @@ -41,54 +31,33 @@ public ElvenTradeProvider(PackOutput packOutput) { } @Override - public void buildRecipes(Consumer consumer) { - consumer.accept(new FinishedElvenRecipe(id("dreamwood_log"), new ItemStack(BotaniaBlocks.dreamwoodLog), Ingredient.of(BotaniaBlocks.livingwoodLog))); - consumer.accept(new FinishedElvenRecipe(id("dreamwood"), new ItemStack(BotaniaBlocks.dreamwood), Ingredient.of(BotaniaBlocks.livingwood))); + public void buildRecipes(RecipeOutput consumer) { + consumer.accept(id("dreamwood_log"), new ElvenTradeRecipe(singleOutput(BotaniaBlocks.dreamwoodLog), Ingredient.of(BotaniaBlocks.livingwoodLog)), null); + consumer.accept(id("dreamwood"), new ElvenTradeRecipe(singleOutput(BotaniaBlocks.dreamwood), Ingredient.of(BotaniaBlocks.livingwood)), null); - Ingredient manaDiamond = Ingredient.of(BotaniaTags.Items.GEMS_MANA_DIAMOND); Ingredient manaSteel = Ingredient.of(BotaniaTags.Items.INGOTS_MANASTEEL); - consumer.accept(new FinishedElvenRecipe(id("elementium"), new ItemStack(BotaniaItems.elementium), manaSteel, manaSteel)); - consumer.accept(new FinishedElvenRecipe(id("elementium_block"), new ItemStack(BotaniaBlocks.elementiumBlock), Ingredient.of(BotaniaBlocks.manasteelBlock), Ingredient.of(BotaniaBlocks.manasteelBlock))); - - consumer.accept(new FinishedElvenRecipe(id("pixie_dust"), new ItemStack(BotaniaItems.pixieDust), Ingredient.of(BotaniaItems.manaPearl))); - consumer.accept(new FinishedElvenRecipe(id("dragonstone"), new ItemStack(BotaniaItems.dragonstone), manaDiamond)); - consumer.accept(new FinishedElvenRecipe(id("dragonstone_block"), new ItemStack(BotaniaBlocks.dragonstoneBlock), Ingredient.of(BotaniaBlocks.manaDiamondBlock))); - - consumer.accept(new FinishedElvenRecipe(id("elf_quartz"), new ItemStack(BotaniaItems.elfQuartz), Ingredient.of(Items.QUARTZ))); - consumer.accept(new FinishedElvenRecipe(id("elf_glass"), new ItemStack(BotaniaBlocks.elfGlass), Ingredient.of(BotaniaBlocks.manaGlass))); + Ingredient manaSteelBlock = Ingredient.of(BotaniaBlocks.manasteelBlock); + consumer.accept(id("elementium"), new ElvenTradeRecipe(singleOutput(BotaniaItems.elementium), manaSteel, manaSteel), null); + consumer.accept(id("elementium_block"), new ElvenTradeRecipe(singleOutput(BotaniaBlocks.elementiumBlock), manaSteelBlock, manaSteelBlock), null); - consumer.accept(new FinishedElvenRecipe(id("iron_return"), new ItemStack(Items.IRON_INGOT), Ingredient.of(Items.IRON_INGOT))); - consumer.accept(new FinishedElvenRecipe(id("iron_block_return"), new ItemStack(Blocks.IRON_BLOCK), Ingredient.of(Blocks.IRON_BLOCK))); - consumer.accept(new FinishedElvenRecipe(id("ender_pearl_return"), new ItemStack(Items.ENDER_PEARL), Ingredient.of(Items.ENDER_PEARL))); - consumer.accept(new FinishedElvenRecipe(id("diamond_return"), new ItemStack(Items.DIAMOND), Ingredient.of(Items.DIAMOND))); - consumer.accept(new FinishedElvenRecipe(id("diamond_block_return"), new ItemStack(Blocks.DIAMOND_BLOCK), Ingredient.of(Blocks.DIAMOND_BLOCK))); + consumer.accept(id("pixie_dust"), new ElvenTradeRecipe(singleOutput(BotaniaItems.pixieDust), Ingredient.of(BotaniaItems.manaPearl)), null); + consumer.accept(id("dragonstone"), new ElvenTradeRecipe(singleOutput(BotaniaItems.dragonstone), Ingredient.of(BotaniaItems.manaDiamond)), null); + consumer.accept(id("dragonstone_block"), new ElvenTradeRecipe(singleOutput(BotaniaBlocks.dragonstoneBlock), Ingredient.of(BotaniaBlocks.manaDiamondBlock)), null); - consumer.accept(new FinishedRecipe() { - @Override - public void serializeRecipeData(JsonObject obj) {} + consumer.accept(id("elf_quartz"), new ElvenTradeRecipe(singleOutput(BotaniaItems.elfQuartz), Ingredient.of(Items.QUARTZ)), null); + consumer.accept(id("elf_glass"), new ElvenTradeRecipe(singleOutput(BotaniaBlocks.elfGlass), Ingredient.of(BotaniaBlocks.manaGlass)), null); - @Override - public ResourceLocation getId() { - return id("lexicon_elven"); - } + consumer.accept(id("iron_return"), new ElvenTradeRecipe(singleOutput(Items.IRON_INGOT), Ingredient.of(Items.IRON_INGOT)), null); + consumer.accept(id("iron_block_return"), new ElvenTradeRecipe(singleOutput(Blocks.IRON_BLOCK), Ingredient.of(Blocks.IRON_BLOCK)), null); + consumer.accept(id("ender_pearl_return"), new ElvenTradeRecipe(singleOutput(Items.ENDER_PEARL), Ingredient.of(Items.ENDER_PEARL)), null); + consumer.accept(id("diamond_return"), new ElvenTradeRecipe(singleOutput(Items.DIAMOND), Ingredient.of(Items.DIAMOND)), null); + consumer.accept(id("diamond_block_return"), new ElvenTradeRecipe(singleOutput(Blocks.DIAMOND_BLOCK), Ingredient.of(Blocks.DIAMOND_BLOCK)), null); - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.LEXICON_ELVEN_TRADE_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } + consumer.accept(id("lexicon_elven"), new LexiconElvenTradeRecipe(), null); + } - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - }); + private static ItemStack[] singleOutput(ItemLike output) { + return new ItemStack[] { new ItemStack(output) }; } private static ResourceLocation id(String path) { @@ -99,58 +68,4 @@ private static ResourceLocation id(String path) { public String getName() { return "Botania elven trade recipes"; } - - protected static class FinishedElvenRecipe implements FinishedRecipe { - private final ResourceLocation id; - private final List inputs; - private final List outputs; - - public FinishedElvenRecipe(ResourceLocation id, ItemStack output, Ingredient... inputs) { - this(id, Arrays.asList(inputs), Collections.singletonList(output)); - } - - protected FinishedElvenRecipe(ResourceLocation id, List inputs, List outputs) { - this.id = id; - this.inputs = inputs; - this.outputs = outputs; - } - - @Override - public void serializeRecipeData(JsonObject json) { - JsonArray in = new JsonArray(); - for (Ingredient ingr : inputs) { - in.add(ingr.toJson()); - } - - JsonArray out = new JsonArray(); - for (ItemStack s : outputs) { - out.add(ItemNBTHelper.serializeStack(s)); - } - - json.add("ingredients", in); - json.add("output", out); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.ELVEN_TRADE_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java index 6995db18fb..b7f15cd029 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java @@ -8,10 +8,9 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonObject; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.DyeColor; @@ -20,22 +19,17 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.Nullable; - import vazkii.botania.api.recipe.StateIngredient; import vazkii.botania.common.block.BotaniaBlocks; import vazkii.botania.common.block.BotaniaFlowerBlocks; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; +import vazkii.botania.common.crafting.ManaInfusionRecipe; import vazkii.botania.common.crafting.StateIngredients; -import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.item.BotaniaItems; import java.util.Arrays; -import java.util.function.Consumer; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @@ -50,155 +44,178 @@ public String getName() { } @Override - public void buildRecipes(Consumer consumer) { - consumer.accept(new FinishedRecipe(id("manasteel"), new ItemStack(BotaniaItems.manaSteel), Ingredient.of(Items.IRON_INGOT), 3000)); - consumer.accept(new FinishedRecipe(id("manasteel_block"), new ItemStack(BotaniaBlocks.manasteelBlock), ingr(Blocks.IRON_BLOCK), 27000)); + public void buildRecipes(RecipeOutput consumer) { + normal(consumer, id("manasteel"), new ItemStack(BotaniaItems.manaSteel), ingr(Items.IRON_INGOT), 3000); + normal(consumer, id("manasteel_block"), new ItemStack(BotaniaBlocks.manasteelBlock), ingr(Blocks.IRON_BLOCK), 27000); - consumer.accept(new FinishedRecipe(id("mana_pearl"), new ItemStack(BotaniaItems.manaPearl), ingr(Items.ENDER_PEARL), 6000)); + normal(consumer, id("mana_pearl"), new ItemStack(BotaniaItems.manaPearl), ingr(Items.ENDER_PEARL), 6000); - consumer.accept(new FinishedRecipe(id("mana_diamond"), new ItemStack(BotaniaItems.manaDiamond), Ingredient.of(Items.DIAMOND), 10000)); - consumer.accept(new FinishedRecipe(id("mana_diamond_block"), new ItemStack(BotaniaBlocks.manaDiamondBlock), ingr(Blocks.DIAMOND_BLOCK), 90000)); + normal(consumer, id("mana_diamond"), new ItemStack(BotaniaItems.manaDiamond), Ingredient.of(Items.DIAMOND), 10000); + normal(consumer, id("mana_diamond_block"), new ItemStack(BotaniaBlocks.manaDiamondBlock), ingr(Blocks.DIAMOND_BLOCK), 90000); + // TODO: make this a tag + // I think the tag exists, so EMI picks it up, but it might as well be in the recipe Ingredient dust = Ingredient.of(Items.GUNPOWDER, Items.REDSTONE, Items.GLOWSTONE_DUST, Items.SUGAR); - consumer.accept(new FinishedRecipe(id("mana_powder_dust"), new ItemStack(BotaniaItems.manaPowder), dust, 500)); + normal(consumer, id("mana_powder_dust"), new ItemStack(BotaniaItems.manaPowder), dust, 500); + // TODO: this one too Ingredient dyeIngredient = Ingredient.of(Arrays.stream(DyeColor.values()).map(DyeItem::byColor).toArray(Item[]::new)); - consumer.accept(new FinishedRecipe(id("mana_powder_dye"), new ItemStack(BotaniaItems.manaPowder), dyeIngredient, 400)); + normal(consumer, id("mana_powder_dye"), new ItemStack(BotaniaItems.manaPowder), dyeIngredient, 400); - consumer.accept(new FinishedRecipe(id("piston_relay"), new ItemStack(BotaniaBlocks.pistonRelay), ingr(Blocks.PISTON), 15000)); - consumer.accept(new FinishedRecipe(id("mana_cookie"), new ItemStack(BotaniaItems.manaCookie), ingr(Items.COOKIE), 20000)); - consumer.accept(new FinishedRecipe(id("grass_seeds"), new ItemStack(BotaniaItems.grassSeeds), ingr(Blocks.GRASS), 2500)); - consumer.accept(new FinishedRecipe(id("podzol_seeds"), new ItemStack(BotaniaItems.podzolSeeds), ingr(Blocks.DEAD_BUSH), 2500)); + normal(consumer, id("piston_relay"), new ItemStack(BotaniaBlocks.pistonRelay), ingr(Blocks.PISTON), 15000); + normal(consumer, id("mana_cookie"), new ItemStack(BotaniaItems.manaCookie), ingr(Items.COOKIE), 20000); + normal(consumer, id("grass_seeds"), new ItemStack(BotaniaItems.grassSeeds), ingr(Blocks.SHORT_GRASS), 2500); + normal(consumer, id("podzol_seeds"), new ItemStack(BotaniaItems.podzolSeeds), ingr(Blocks.DEAD_BUSH), 2500); - consumer.accept(new FinishedRecipe(id("mycel_seeds"), new ItemStack(BotaniaItems.mycelSeeds), Ingredient.of(Blocks.RED_MUSHROOM, Blocks.BROWN_MUSHROOM), 6500)); + normal(consumer, id("mycel_seeds"), new ItemStack(BotaniaItems.mycelSeeds), Ingredient.of(Blocks.RED_MUSHROOM, Blocks.BROWN_MUSHROOM), 6500); - consumer.accept(new FinishedRecipe(id("mana_quartz"), new ItemStack(BotaniaItems.manaQuartz), ingr(Items.QUARTZ), 250)); - consumer.accept(new FinishedRecipe(id("tiny_potato"), new ItemStack(BotaniaBlocks.tinyPotato), ingr(Items.POTATO), 1337)); + normal(consumer, id("mana_quartz"), new ItemStack(BotaniaItems.manaQuartz), ingr(Items.QUARTZ), 250); + normal(consumer, id("tiny_potato"), new ItemStack(BotaniaBlocks.tinyPotato), ingr(Items.POTATO), 1337); - consumer.accept(new FinishedRecipe(id("mana_glass"), new ItemStack(BotaniaBlocks.manaGlass), ingr(Blocks.GLASS), 150)); - consumer.accept(new FinishedRecipe(id("mana_string"), new ItemStack(BotaniaItems.manaString), ingr(Items.STRING), 1250)); + normal(consumer, id("mana_glass"), new ItemStack(BotaniaBlocks.manaGlass), ingr(Blocks.GLASS), 150); + normal(consumer, id("mana_string"), new ItemStack(BotaniaItems.manaString), ingr(Items.STRING), 1250); - consumer.accept(new FinishedRecipe(id("mana_bottle"), new ItemStack(BotaniaItems.manaBottle), ingr(Items.GLASS_BOTTLE), 5000)); + normal(consumer, id("mana_bottle"), new ItemStack(BotaniaItems.manaBottle), ingr(Items.GLASS_BOTTLE), 5000); - consumer.accept(FinishedRecipe.alchemy(id("rotten_flesh_to_leather"), new ItemStack(Items.LEATHER), ingr(Items.ROTTEN_FLESH), 600)); + alchemy(consumer, id("rotten_flesh_to_leather"), new ItemStack(Items.LEATHER), ingr(Items.ROTTEN_FLESH), 600); cycle(consumer, 40, "botania:log_cycle", Blocks.OAK_LOG, Blocks.SPRUCE_LOG, Blocks.BIRCH_LOG, Blocks.JUNGLE_LOG, Blocks.ACACIA_LOG, Blocks.DARK_OAK_LOG, Blocks.MANGROVE_LOG, Blocks.CHERRY_LOG); cycle(consumer, 40, "botania:froglight_cycle", Blocks.OCHRE_FROGLIGHT, Blocks.VERDANT_FROGLIGHT, Blocks.PEARLESCENT_FROGLIGHT); cycle(consumer, 120, "botania:sapling_cycle", Blocks.OAK_SAPLING, Blocks.SPRUCE_SAPLING, Blocks.BIRCH_SAPLING, Blocks.JUNGLE_SAPLING, Blocks.ACACIA_SAPLING, Blocks.DARK_OAK_SAPLING, Blocks.MANGROVE_PROPAGULE, Blocks.CHERRY_SAPLING); - consumer.accept(deconstruct("glowstone_deconstruct", Items.GLOWSTONE_DUST, Blocks.GLOWSTONE)); - consumer.accept(deconstruct("quartz_deconstruct", Items.QUARTZ, Blocks.QUARTZ_BLOCK)); - consumer.accept(deconstruct("dark_quartz_deconstruct", BotaniaItems.darkQuartz, BotaniaBlocks.darkQuartz)); - consumer.accept(deconstruct("mana_quartz_deconstruct", BotaniaItems.manaQuartz, BotaniaBlocks.manaQuartz)); - consumer.accept(deconstruct("blaze_quartz_deconstruct", BotaniaItems.blazeQuartz, BotaniaBlocks.blazeQuartz)); - consumer.accept(deconstruct("lavender_quartz_deconstruct", BotaniaItems.lavenderQuartz, BotaniaBlocks.lavenderQuartz)); - consumer.accept(deconstruct("red_quartz_deconstruct", BotaniaItems.redQuartz, BotaniaBlocks.redQuartz)); - consumer.accept(deconstruct("elf_quartz_deconstruct", BotaniaItems.elfQuartz, BotaniaBlocks.elfQuartz)); - consumer.accept(deconstruct("sunny_quartz_deconstruct", BotaniaItems.sunnyQuartz, BotaniaBlocks.sunnyQuartz)); + deconstruct(consumer, id("glowstone_deconstruct"), Items.GLOWSTONE_DUST, Blocks.GLOWSTONE); + deconstruct(consumer, id("quartz_deconstruct"), Items.QUARTZ, Blocks.QUARTZ_BLOCK); + deconstruct(consumer, id("dark_quartz_deconstruct"), BotaniaItems.darkQuartz, BotaniaBlocks.darkQuartz); + deconstruct(consumer, id("mana_quartz_deconstruct"), BotaniaItems.manaQuartz, BotaniaBlocks.manaQuartz); + deconstruct(consumer, id("blaze_quartz_deconstruct"), BotaniaItems.blazeQuartz, BotaniaBlocks.blazeQuartz); + deconstruct(consumer, id("lavender_quartz_deconstruct"), BotaniaItems.lavenderQuartz, BotaniaBlocks.lavenderQuartz); + deconstruct(consumer, id("red_quartz_deconstruct"), BotaniaItems.redQuartz, BotaniaBlocks.redQuartz); + deconstruct(consumer, id("elf_quartz_deconstruct"), BotaniaItems.elfQuartz, BotaniaBlocks.elfQuartz); + deconstruct(consumer, id("sunny_quartz_deconstruct"), BotaniaItems.sunnyQuartz, BotaniaBlocks.sunnyQuartz); - consumer.accept(FinishedRecipe.alchemy(id("chiseled_stone_bricks"), new ItemStack(Blocks.CHISELED_STONE_BRICKS, 1), ingr(Blocks.STONE_BRICKS), 150)); - consumer.accept(FinishedRecipe.alchemy(id("ice"), new ItemStack(Blocks.ICE), ingr(Blocks.SNOW_BLOCK), 2250)); + alchemy(consumer, id("chiseled_stone_bricks"), new ItemStack(Blocks.CHISELED_STONE_BRICKS, 1), ingr(Blocks.STONE_BRICKS), 150); + alchemy(consumer, id("ice"), new ItemStack(Blocks.ICE), ingr(Blocks.SNOW_BLOCK), 2250); + // TODO: These can use the `cycle` function, right?? check when datagen operational final String vineLilypadGroup = "botania:vine_and_lily_pad_cycle"; - consumer.accept(FinishedRecipe.alchemy(id("vine_to_lily_pad"), new ItemStack(Blocks.LILY_PAD), ingr(Blocks.VINE), 320, vineLilypadGroup)); - consumer.accept(FinishedRecipe.alchemy(id("lily_pad_to_vine"), new ItemStack(Blocks.VINE), ingr(Blocks.LILY_PAD), 320, vineLilypadGroup)); + alchemy(consumer, id("vine_to_lily_pad"), new ItemStack(Blocks.LILY_PAD), ingr(Blocks.VINE), 320, vineLilypadGroup); + alchemy(consumer, id("lily_pad_to_vine"), new ItemStack(Blocks.VINE), ingr(Blocks.LILY_PAD), 320, vineLilypadGroup); cycle(consumer, 200, "botania:fish_cycle", Items.COD, Items.SALMON, Items.TROPICAL_FISH, Items.PUFFERFISH); cycle(consumer, 6000, "botania:crop_cycle", Items.COCOA_BEANS, Items.WHEAT_SEEDS, Items.POTATO, Items.CARROT, Items.BEETROOT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS); - consumer.accept(FinishedRecipe.alchemy(id("potato_unpoison"), new ItemStack(Items.POTATO), ingr(Items.POISONOUS_POTATO), 1200)); - consumer.accept(FinishedRecipe.alchemy(id("blaze_rod_to_nether_wart"), new ItemStack(Items.NETHER_WART), ingr(Items.BLAZE_ROD), 4000)); + alchemy(consumer, id("potato_unpoison"), new ItemStack(Items.POTATO), ingr(Items.POISONOUS_POTATO), 1200); + alchemy(consumer, id("blaze_rod_to_nether_wart"), new ItemStack(Items.NETHER_WART), ingr(Items.BLAZE_ROD), 4000); cycle(consumer, 200, "", Items.GUNPOWDER, Items.FLINT); - consumer.accept(FinishedRecipe.alchemy(id("book_to_name_tag"), new ItemStack(Items.NAME_TAG), ingr(Items.WRITABLE_BOOK), 6000)); + alchemy(consumer, id("book_to_name_tag"), new ItemStack(Items.NAME_TAG), ingr(Items.WRITABLE_BOOK), 6000); - consumer.accept(FinishedRecipe.alchemy(id("wool_deconstruct"), new ItemStack(Items.STRING, 3), Ingredient.of(ItemTags.WOOL), 100)); + alchemy(consumer, id("wool_deconstruct"), new ItemStack(Items.STRING, 3), Ingredient.of(ItemTags.WOOL), 100); final String cactusSlimeGroup = "botania:cactus_and_slime_cycle"; - consumer.accept(FinishedRecipe.alchemy(id("cactus_to_slime"), new ItemStack(Items.SLIME_BALL), ingr(Blocks.CACTUS), 1200, cactusSlimeGroup)); - consumer.accept(FinishedRecipe.alchemy(id("slime_to_cactus"), new ItemStack(Blocks.CACTUS), ingr(Items.SLIME_BALL), 1200, cactusSlimeGroup)); + alchemy(consumer, id("cactus_to_slime"), new ItemStack(Items.SLIME_BALL), ingr(Blocks.CACTUS), 1200, cactusSlimeGroup); + alchemy(consumer, id("slime_to_cactus"), new ItemStack(Blocks.CACTUS), ingr(Items.SLIME_BALL), 1200, cactusSlimeGroup); - consumer.accept(FinishedRecipe.alchemy(id("ender_pearl_from_ghast_tear"), new ItemStack(Items.ENDER_PEARL), ingr(Items.GHAST_TEAR), 28000)); + alchemy(consumer, id("ender_pearl_from_ghast_tear"), new ItemStack(Items.ENDER_PEARL), ingr(Items.GHAST_TEAR), 28000); cycle(consumer, 300, "botania:glowstone_and_redstone_cycle", Items.GLOWSTONE_DUST, Items.REDSTONE); - consumer.accept(FinishedRecipe.alchemy(id("cobble_to_sand"), new ItemStack(Blocks.SAND), ingr(Blocks.COBBLESTONE), 50)); - consumer.accept(FinishedRecipe.alchemy(id("terracotta_to_red_sand"), new ItemStack(Blocks.RED_SAND), ingr(Blocks.TERRACOTTA), 50)); + alchemy(consumer, id("cobble_to_sand"), new ItemStack(Blocks.SAND), ingr(Blocks.COBBLESTONE), 50); + alchemy(consumer, id("terracotta_to_red_sand"), new ItemStack(Blocks.RED_SAND), ingr(Blocks.TERRACOTTA), 50); - consumer.accept(deconstruct("clay_deconstruct", Items.CLAY_BALL, Blocks.CLAY)); - consumer.accept(deconstruct("brick_deconstruct", Items.BRICK, Blocks.BRICKS)); + deconstruct(consumer, id("clay_deconstruct"), Items.CLAY_BALL, Blocks.CLAY); + deconstruct(consumer, id("brick_deconstruct"), Items.BRICK, Blocks.BRICKS); - consumer.accept(FinishedRecipe.alchemy(id("coarse_dirt"), new ItemStack(Blocks.COARSE_DIRT), ingr(Blocks.DIRT), 120)); - consumer.accept(FinishedRecipe.alchemy(id("soul_soil"), new ItemStack(Blocks.SOUL_SOIL), ingr(Blocks.SOUL_SAND), 120)); + alchemy(consumer, id("coarse_dirt"), new ItemStack(Blocks.COARSE_DIRT), ingr(Blocks.DIRT), 120); + alchemy(consumer, id("soul_soil"), new ItemStack(Blocks.SOUL_SOIL), ingr(Blocks.SOUL_SAND), 120); - consumer.accept(FinishedRecipe.alchemy(id("stone_to_andesite"), new ItemStack(Blocks.ANDESITE), ingr(Blocks.STONE), 200)); + alchemy(consumer, id("stone_to_andesite"), new ItemStack(Blocks.ANDESITE), ingr(Blocks.STONE), 200); cycle(consumer, 200, "botania:stone_cycle", Blocks.DIORITE, Blocks.GRANITE, Blocks.ANDESITE); cycle(consumer, 200, "botania:117_stone_cycle", Blocks.TUFF, Blocks.CALCITE, Blocks.DEEPSLATE); - cycle(consumer, 500, "botania:shrub_cycle", Blocks.FERN, Blocks.DEAD_BUSH, Blocks.GRASS); + cycle(consumer, 500, "botania:shrub_cycle", Blocks.FERN, Blocks.DEAD_BUSH, Blocks.SHORT_GRASS); // NB: No wither rose is intentional cycle(consumer, 400, "botania:flower_cycle", Blocks.DANDELION, Blocks.POPPY, Blocks.BLUE_ORCHID, Blocks.ALLIUM, Blocks.AZURE_BLUET, Blocks.RED_TULIP, Blocks.ORANGE_TULIP, Blocks.WHITE_TULIP, Blocks.PINK_TULIP, Blocks.OXEYE_DAISY, Blocks.CORNFLOWER, Blocks.LILY_OF_THE_VALLEY, Blocks.SUNFLOWER, Blocks.LILAC, Blocks.ROSE_BUSH, Blocks.PEONY); - consumer.accept(FinishedRecipe.alchemy(id("dripleaf_shrinking"), new ItemStack(Blocks.SMALL_DRIPLEAF), ingr(Items.BIG_DRIPLEAF), 500)); - consumer.accept(FinishedRecipe.alchemy(id("chorus_fruit_to_flower"), new ItemStack(Blocks.CHORUS_FLOWER), ingr(Items.POPPED_CHORUS_FRUIT), 10000)); + alchemy(consumer, id("dripleaf_shrinking"), new ItemStack(Blocks.SMALL_DRIPLEAF), ingr(Items.BIG_DRIPLEAF), 500); + alchemy(consumer, id("chorus_fruit_to_flower"), new ItemStack(Blocks.CHORUS_FLOWER), ingr(Items.POPPED_CHORUS_FRUIT), 10000); cycle(consumer, 240, "botania:berry_cycle", Items.APPLE, Items.SWEET_BERRIES, Items.GLOW_BERRIES); - consumer.accept(mini(BotaniaFlowerBlocks.agricarnationChibi, BotaniaFlowerBlocks.agricarnation)); - consumer.accept(mini(BotaniaFlowerBlocks.clayconiaChibi, BotaniaFlowerBlocks.clayconia)); - consumer.accept(mini(BotaniaFlowerBlocks.bellethornChibi, BotaniaFlowerBlocks.bellethorn)); - consumer.accept(mini(BotaniaFlowerBlocks.bubbellChibi, BotaniaFlowerBlocks.bubbell)); - consumer.accept(mini(BotaniaFlowerBlocks.hopperhockChibi, BotaniaFlowerBlocks.hopperhock)); - consumer.accept(mini(BotaniaFlowerBlocks.jiyuuliaChibi, BotaniaFlowerBlocks.jiyuulia)); - consumer.accept(mini(BotaniaFlowerBlocks.tangleberrieChibi, BotaniaFlowerBlocks.tangleberrie)); - consumer.accept(mini(BotaniaFlowerBlocks.marimorphosisChibi, BotaniaFlowerBlocks.marimorphosis)); - consumer.accept(mini(BotaniaFlowerBlocks.rannuncarpusChibi, BotaniaFlowerBlocks.rannuncarpus)); - consumer.accept(mini(BotaniaFlowerBlocks.solegnoliaChibi, BotaniaFlowerBlocks.solegnolia)); - - consumer.accept(FinishedRecipe.alchemy(id("hydroangeas_motif"), new ItemStack(BotaniaBlocks.motifHydroangeas), ingr(BotaniaFlowerBlocks.hydroangeas), 2500)); - - consumer.accept(FinishedRecipe.conjuration(id("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000)); - consumer.accept(FinishedRecipe.conjuration(id("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000)); - consumer.accept(FinishedRecipe.conjuration(id("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500)); - consumer.accept(FinishedRecipe.conjuration(id("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100)); - consumer.accept(FinishedRecipe.conjuration(id("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200)); - consumer.accept(FinishedRecipe.conjuration(id("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200)); - consumer.accept(FinishedRecipe.conjuration(id("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500)); - consumer.accept(FinishedRecipe.conjuration(id("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720)); - - consumer.accept(FinishedRecipe.conjuration(id("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("azalea_leaves_dupe"), new ItemStack(Blocks.AZALEA_LEAVES, 2), ingr(Blocks.AZALEA_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("flowering_azalea_leaves_dupe"), new ItemStack(Blocks.FLOWERING_AZALEA_LEAVES, 2), ingr(Blocks.FLOWERING_AZALEA_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("mangrove_leaves_dupe"), new ItemStack(Blocks.MANGROVE_LEAVES, 2), ingr(Blocks.MANGROVE_LEAVES), 2000)); - consumer.accept(FinishedRecipe.conjuration(id("cherry_leaves_dupe"), new ItemStack(Blocks.CHERRY_LEAVES, 2), ingr(Blocks.CHERRY_LEAVES), 2000)); - - consumer.accept(FinishedRecipe.conjuration(id("grass"), new ItemStack(Blocks.GRASS, 2), ingr(Blocks.GRASS), 800)); + mini(consumer, BotaniaFlowerBlocks.agricarnationChibi, BotaniaFlowerBlocks.agricarnation); + mini(consumer, BotaniaFlowerBlocks.clayconiaChibi, BotaniaFlowerBlocks.clayconia); + mini(consumer, BotaniaFlowerBlocks.bellethornChibi, BotaniaFlowerBlocks.bellethorn); + mini(consumer, BotaniaFlowerBlocks.bubbellChibi, BotaniaFlowerBlocks.bubbell); + mini(consumer, BotaniaFlowerBlocks.hopperhockChibi, BotaniaFlowerBlocks.hopperhock); + mini(consumer, BotaniaFlowerBlocks.jiyuuliaChibi, BotaniaFlowerBlocks.jiyuulia); + mini(consumer, BotaniaFlowerBlocks.tangleberrieChibi, BotaniaFlowerBlocks.tangleberrie); + mini(consumer, BotaniaFlowerBlocks.marimorphosisChibi, BotaniaFlowerBlocks.marimorphosis); + mini(consumer, BotaniaFlowerBlocks.rannuncarpusChibi, BotaniaFlowerBlocks.rannuncarpus); + mini(consumer, BotaniaFlowerBlocks.solegnoliaChibi, BotaniaFlowerBlocks.solegnolia); + + alchemy(consumer, id("hydroangeas_motif"), new ItemStack(BotaniaBlocks.motifHydroangeas), ingr(BotaniaFlowerBlocks.hydroangeas), 2500); + + conjuration(consumer, id("redstone_dupe"), new ItemStack(Items.REDSTONE, 2), ingr(Items.REDSTONE), 5000); + conjuration(consumer, id("glowstone_dupe"), new ItemStack(Items.GLOWSTONE_DUST, 2), ingr(Items.GLOWSTONE_DUST), 5000); + conjuration(consumer, id("quartz_dupe"), new ItemStack(Items.QUARTZ, 2), ingr(Items.QUARTZ), 2500); + conjuration(consumer, id("coal_dupe"), new ItemStack(Items.COAL, 2), ingr(Items.COAL), 2100); + conjuration(consumer, id("snowball_dupe"), new ItemStack(Items.SNOWBALL, 2), ingr(Items.SNOWBALL), 200); + conjuration(consumer, id("netherrack_dupe"), new ItemStack(Blocks.NETHERRACK, 2), ingr(Blocks.NETHERRACK), 200); + conjuration(consumer, id("soul_sand_dupe"), new ItemStack(Blocks.SOUL_SAND, 2), ingr(Blocks.SOUL_SAND), 1500); + conjuration(consumer, id("gravel_dupe"), new ItemStack(Blocks.GRAVEL, 2), ingr(Blocks.GRAVEL), 720); + + conjuration(consumer, id("oak_leaves_dupe"), new ItemStack(Blocks.OAK_LEAVES, 2), ingr(Blocks.OAK_LEAVES), 2000); + conjuration(consumer, id("birch_leaves_dupe"), new ItemStack(Blocks.BIRCH_LEAVES, 2), ingr(Blocks.BIRCH_LEAVES), 2000); + conjuration(consumer, id("spruce_leaves_dupe"), new ItemStack(Blocks.SPRUCE_LEAVES, 2), ingr(Blocks.SPRUCE_LEAVES), 2000); + conjuration(consumer, id("jungle_leaves_dupe"), new ItemStack(Blocks.JUNGLE_LEAVES, 2), ingr(Blocks.JUNGLE_LEAVES), 2000); + conjuration(consumer, id("acacia_leaves_dupe"), new ItemStack(Blocks.ACACIA_LEAVES, 2), ingr(Blocks.ACACIA_LEAVES), 2000); + conjuration(consumer, id("dark_oak_leaves_dupe"), new ItemStack(Blocks.DARK_OAK_LEAVES, 2), ingr(Blocks.DARK_OAK_LEAVES), 2000); + conjuration(consumer, id("azalea_leaves_dupe"), new ItemStack(Blocks.AZALEA_LEAVES, 2), ingr(Blocks.AZALEA_LEAVES), 2000); + conjuration(consumer, id("flowering_azalea_leaves_dupe"), new ItemStack(Blocks.FLOWERING_AZALEA_LEAVES, 2), ingr(Blocks.FLOWERING_AZALEA_LEAVES), 2000); + conjuration(consumer, id("mangrove_leaves_dupe"), new ItemStack(Blocks.MANGROVE_LEAVES, 2), ingr(Blocks.MANGROVE_LEAVES), 2000); + conjuration(consumer, id("cherry_leaves_dupe"), new ItemStack(Blocks.CHERRY_LEAVES, 2), ingr(Blocks.CHERRY_LEAVES), 2000); + + conjuration(consumer, id("grass"), new ItemStack(Blocks.SHORT_GRASS, 2), ingr(Blocks.SHORT_GRASS), 800); + } + + private static final StateIngredient ALCHEMY = StateIngredients.of(BotaniaBlocks.alchemyCatalyst); + private static final StateIngredient CONJURATION = StateIngredients.of(BotaniaBlocks.conjurationCatalyst); + + private static void normal(RecipeOutput consumer, ResourceLocation id, ItemStack output, Ingredient input, int mana) { + consumer.accept(id, new ManaInfusionRecipe(output, input, mana, null, null), null); + } + + private static void alchemy(RecipeOutput consumer, ResourceLocation id, ItemStack output, Ingredient input, int mana, String group) { + consumer.accept(id, new ManaInfusionRecipe(output, input, mana, group, ALCHEMY), null); + } + + private static void alchemy(RecipeOutput consumer, ResourceLocation id, ItemStack output, Ingredient input, int mana) { + alchemy(consumer, id, output, input, mana, null); } - protected void cycle(Consumer consumer, int cost, String group, ItemLike... items) { + private static void conjuration(RecipeOutput consumer, ResourceLocation id, ItemStack output, Ingredient input, int mana) { + consumer.accept(id, new ManaInfusionRecipe(output, input, mana, "", CONJURATION), null); + } + + protected void cycle(RecipeOutput consumer, int cost, String group, ItemLike... items) { for (int i = 0; i < items.length; i++) { Ingredient in = ingr(items[i]); ItemStack out = new ItemStack(i == items.length - 1 ? items[0] : items[i + 1]); String id = String.format("%s_to_%s", BuiltInRegistries.ITEM.getKey(items[i].asItem()).getPath(), BuiltInRegistries.ITEM.getKey(out.getItem()).getPath()); - consumer.accept(FinishedRecipe.alchemy(id(id), out, in, cost, group)); + alchemy(consumer, id(id), out, in, cost, group); } } - protected FinishedRecipe mini(ItemLike mini, ItemLike full) { - return FinishedRecipe.alchemy(id(BuiltInRegistries.ITEM.getKey(mini.asItem()).getPath()), new ItemStack(mini), ingr(full), 2500, "botania:flower_shrinking"); + protected void mini(RecipeOutput consumer, ItemLike mini, ItemLike full) { + alchemy(consumer, id(BuiltInRegistries.ITEM.getKey(mini.asItem()).getPath()), new ItemStack(mini), ingr(full), 2500, "botania:flower_shrinking"); } - protected FinishedRecipe deconstruct(String id, ItemLike items, ItemLike block) { - return FinishedRecipe.alchemy(id(id), new ItemStack(items, 4), ingr(block), 25, "botania:block_deconstruction"); + protected void deconstruct(RecipeOutput consumer, ResourceLocation id, ItemLike items, ItemLike block) { + alchemy(consumer, id, new ItemStack(items, 4), ingr(block), 25, "botania:block_deconstruction"); } protected ResourceLocation id(String s) { @@ -208,81 +225,4 @@ protected ResourceLocation id(String s) { protected static Ingredient ingr(ItemLike i) { return Ingredient.of(i); } - - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - private static final StateIngredient CONJURATION = StateIngredients.of(BotaniaBlocks.conjurationCatalyst); - private static final StateIngredient ALCHEMY = StateIngredients.of(BotaniaBlocks.alchemyCatalyst); - - private final ResourceLocation id; - private final Ingredient input; - private final ItemStack output; - private final int mana; - private final String group; - @Nullable - private final StateIngredient catalyst; - - public static FinishedRecipe conjuration(ResourceLocation id, ItemStack output, Ingredient input, int mana) { - return new FinishedRecipe(id, output, input, mana, "", CONJURATION); - } - - public static FinishedRecipe alchemy(ResourceLocation id, ItemStack output, Ingredient input, int mana) { - return alchemy(id, output, input, mana, ""); - } - - public static FinishedRecipe alchemy(ResourceLocation id, ItemStack output, Ingredient input, int mana, String group) { - return new FinishedRecipe(id, output, input, mana, group, ALCHEMY); - } - - public FinishedRecipe(ResourceLocation id, ItemStack output, Ingredient input, int mana) { - this(id, output, input, mana, ""); - } - - public FinishedRecipe(ResourceLocation id, ItemStack output, Ingredient input, int mana, String group) { - this(id, output, input, mana, group, null); - } - - public FinishedRecipe(ResourceLocation id, ItemStack output, Ingredient input, int mana, String group, @Nullable StateIngredient catalyst) { - this.id = id; - this.input = input; - this.output = output; - this.mana = mana; - this.group = group; - this.catalyst = catalyst; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("input", input.toJson()); - json.add("output", ItemNBTHelper.serializeStack(output)); - json.addProperty("mana", mana); - if (!group.isEmpty()) { - json.addProperty("group", group); - } - if (catalyst != null) { - json.add("catalyst", catalyst.serialize()); - } - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.MANA_INFUSION_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/OrechidProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/OrechidProvider.java index 31e40a936d..af0e643c8d 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/OrechidProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/OrechidProvider.java @@ -8,28 +8,20 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonObject; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.Nullable; - -import vazkii.botania.api.recipe.OrechidRecipe; import vazkii.botania.api.recipe.StateIngredient; import vazkii.botania.common.block.BotaniaBlocks; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; -import vazkii.botania.common.crafting.StateIngredients; +import vazkii.botania.common.crafting.*; import vazkii.botania.common.lib.BotaniaTags; -import java.util.function.Consumer; - import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class OrechidProvider extends BotaniaRecipeProvider { @@ -41,37 +33,37 @@ public OrechidProvider(PackOutput packOutput) { // TODO: We had an enormous amount of ores defined for mod compat. // The old data needs to be completely revised. @Override - protected void buildRecipes(Consumer consumer) { - consumer.accept(stone(Blocks.COAL_ORE, 67415)); - consumer.accept(stone(Blocks.IRON_ORE, 29371)); - consumer.accept(stone(Blocks.REDSTONE_ORE, 7654)); - consumer.accept(stone(Blocks.COPPER_ORE, 7000)); - consumer.accept(stone(Blocks.GOLD_ORE, 2647)); - consumer.accept(stone(Blocks.EMERALD_ORE, 1239)); - consumer.accept(stone(Blocks.LAPIS_ORE, 1079)); - consumer.accept(stone(Blocks.DIAMOND_ORE, 883)); - - consumer.accept(deepslate(Blocks.DEEPSLATE_COAL_ORE, 75)); - consumer.accept(deepslate(Blocks.DEEPSLATE_IRON_ORE, 250)); - consumer.accept(deepslate(Blocks.DEEPSLATE_REDSTONE_ORE, 150)); - consumer.accept(deepslate(Blocks.DEEPSLATE_COPPER_ORE, 75)); - consumer.accept(deepslate(Blocks.DEEPSLATE_GOLD_ORE, 125)); - consumer.accept(deepslate(Blocks.DEEPSLATE_EMERALD_ORE, 50)); - consumer.accept(deepslate(Blocks.DEEPSLATE_LAPIS_ORE, 175)); - consumer.accept(deepslate(Blocks.DEEPSLATE_DIAMOND_ORE, 100)); - - consumer.accept(netherrack(Blocks.NETHER_QUARTZ_ORE, 19600)); - consumer.accept(netherrack(Blocks.NETHER_GOLD_ORE, 3635)); - consumer.accept(netherrack(Blocks.ANCIENT_DEBRIS, 148)); - - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneForest, BotaniaTags.Biomes.MARIMORPHOSIS_FOREST_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStonePlains, BotaniaTags.Biomes.MARIMORPHOSIS_PLAINS_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneMountain, BotaniaTags.Biomes.MARIMORPHOSIS_MOUNTAIN_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneFungal, BotaniaTags.Biomes.MARIMORPHOSIS_FUNGAL_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneSwamp, BotaniaTags.Biomes.MARIMORPHOSIS_SWAMP_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneDesert, BotaniaTags.Biomes.MARIMORPHOSIS_DESERT_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneTaiga, BotaniaTags.Biomes.MARIMORPHOSIS_TAIGA_BONUS)); - consumer.accept(biomeStone(BotaniaBlocks.biomeStoneMesa, BotaniaTags.Biomes.MARIMORPHOSIS_MESA_BONUS)); + public void buildRecipes(RecipeOutput consumer) { + stone(consumer, Blocks.COAL_ORE, 67415); + stone(consumer, Blocks.IRON_ORE, 29371); + stone(consumer, Blocks.REDSTONE_ORE, 7654); + stone(consumer, Blocks.COPPER_ORE, 7000); + stone(consumer, Blocks.GOLD_ORE, 2647); + stone(consumer, Blocks.EMERALD_ORE, 1239); + stone(consumer, Blocks.LAPIS_ORE, 1079); + stone(consumer, Blocks.DIAMOND_ORE, 883); + + deepslate(consumer, Blocks.DEEPSLATE_COAL_ORE, 75); + deepslate(consumer, Blocks.DEEPSLATE_IRON_ORE, 250); + deepslate(consumer, Blocks.DEEPSLATE_REDSTONE_ORE, 150); + deepslate(consumer, Blocks.DEEPSLATE_COPPER_ORE, 75); + deepslate(consumer, Blocks.DEEPSLATE_GOLD_ORE, 125); + deepslate(consumer, Blocks.DEEPSLATE_EMERALD_ORE, 50); + deepslate(consumer, Blocks.DEEPSLATE_LAPIS_ORE, 175); + deepslate(consumer, Blocks.DEEPSLATE_DIAMOND_ORE, 100); + + netherrack(consumer, Blocks.NETHER_QUARTZ_ORE, 19600); + netherrack(consumer, Blocks.NETHER_GOLD_ORE, 3635); + netherrack(consumer, Blocks.ANCIENT_DEBRIS, 148); + + biomeStone(consumer, BotaniaBlocks.biomeStoneForest, BotaniaTags.Biomes.MARIMORPHOSIS_FOREST_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStonePlains, BotaniaTags.Biomes.MARIMORPHOSIS_PLAINS_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneMountain, BotaniaTags.Biomes.MARIMORPHOSIS_MOUNTAIN_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneFungal, BotaniaTags.Biomes.MARIMORPHOSIS_FUNGAL_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneSwamp, BotaniaTags.Biomes.MARIMORPHOSIS_SWAMP_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneDesert, BotaniaTags.Biomes.MARIMORPHOSIS_DESERT_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneTaiga, BotaniaTags.Biomes.MARIMORPHOSIS_TAIGA_BONUS); + biomeStone(consumer, BotaniaBlocks.biomeStoneMesa, BotaniaTags.Biomes.MARIMORPHOSIS_MESA_BONUS); } protected ResourceLocation orechidId(Block b) { @@ -86,24 +78,24 @@ protected ResourceLocation marimorphosisId(Block b) { return prefix("marimorphosis/" + BuiltInRegistries.BLOCK.getKey(b).getPath()); } - protected Result stone(Block output, int weight) { - return new Result(BotaniaRecipeTypes.ORECHID_SERIALIZER, orechidId(output), - forBlock(Blocks.STONE), forBlock(output), weight); + protected void stone(RecipeOutput consumer, Block output, int weight) { + consumer.accept(orechidId(output), new OrechidRecipe(forBlock(Blocks.STONE), + forBlock(output), weight, null), null); } - protected Result deepslate(Block output, int weight) { - return new Result(BotaniaRecipeTypes.ORECHID_SERIALIZER, orechidId(output), - forBlock(Blocks.DEEPSLATE), forBlock(output), weight); + protected void deepslate(RecipeOutput consumer, Block output, int weight) { + consumer.accept(orechidId(output), new OrechidRecipe(forBlock(Blocks.DEEPSLATE), + forBlock(output), weight, null), null); } - protected Result netherrack(Block output, int weight) { - return new Result(BotaniaRecipeTypes.ORECHID_IGNEM_SERIALIZER, ignemId(output), - forBlock(Blocks.NETHERRACK), forBlock(output), weight); + protected void netherrack(RecipeOutput consumer, Block output, int weight) { + consumer.accept(ignemId(output), new OrechidIgnemRecipe(forBlock(Blocks.NETHERRACK), + forBlock(output), weight, null), null); } - protected Result biomeStone(Block output, TagKey biome) { - return new BiomeResult(BotaniaRecipeTypes.MARIMORPHOSIS_SERIALIZER, marimorphosisId(output), - forTag(BotaniaTags.Blocks.MARIMORPHOSIS_CONVERTABLE), forBlock(output), 1, 11, biome); + protected void biomeStone(RecipeOutput consumer, Block output, TagKey biome) { + consumer.accept(marimorphosisId(output), new MarimorphosisRecipe(forTag(BotaniaTags.Blocks.MARIMORPHOSIS_CONVERTABLE), + forBlock(output), 1, null, 11, biome), null); } protected static StateIngredient forBlock(Block block) { @@ -119,70 +111,4 @@ public String getName() { return "Botania Orechid and Marimorphosis recipes"; } - protected static class Result implements net.minecraft.data.recipes.FinishedRecipe { - private final RecipeSerializer type; - private final ResourceLocation id; - private final StateIngredient input; - private final StateIngredient output; - private final int weight; - - public Result(RecipeSerializer type, ResourceLocation id, - StateIngredient input, StateIngredient output, int weight) { - this.type = type; - this.id = id; - this.input = input; - this.output = output; - this.weight = weight; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("input", input.serialize()); - json.add("output", output.serialize()); - json.addProperty("weight", weight); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return type; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } - - protected static class BiomeResult extends Result { - private final int bonusWeight; - private final TagKey biome; - - public BiomeResult(RecipeSerializer type, ResourceLocation id, - StateIngredient input, StateIngredient output, int weight, int bonusWeight, - TagKey biome) { - super(type, id, input, output, weight); - this.bonusWeight = bonusWeight; - this.biome = biome; - } - - @Override - public void serializeRecipeData(JsonObject json) { - super.serializeRecipeData(json); - json.addProperty("biome_bonus_tag", biome.location().toString()); - json.addProperty("biome_bonus", bonusWeight); - } - } - } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/PetalApothecaryProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/PetalApothecaryProvider.java index 69133101c1..8bbc58a9cb 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/PetalApothecaryProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/PetalApothecaryProvider.java @@ -8,31 +8,27 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.ItemLike; -import org.jetbrains.annotations.Nullable; - import vazkii.botania.common.block.BotaniaBlocks; import vazkii.botania.common.block.BotaniaFlowerBlocks; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; +import vazkii.botania.common.crafting.PetalApothecaryRecipe; +import vazkii.botania.common.crafting.recipe.GogAlternationRecipe; +import vazkii.botania.common.crafting.recipe.NbtOutputRecipe; import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.lib.BotaniaTags; import java.util.Arrays; -import java.util.function.Consumer; import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; @@ -49,7 +45,7 @@ public String getName() { } @Override - public void buildRecipes(Consumer consumer) { + public void buildRecipes(RecipeOutput consumer) { Ingredient white = tagIngr("petals/white"); Ingredient orange = tagIngr("petals/orange"); Ingredient magenta = tagIngr("petals/magenta"); @@ -87,124 +83,78 @@ public void buildRecipes(Consumer con Ingredient pixieDust = Ingredient.of(BotaniaItems.pixieDust); Ingredient gaiaSpirit = Ingredient.of(BotaniaItems.lifeEssence); - consumer.accept(make(BotaniaFlowerBlocks.pureDaisy, white, white, white, white)); - consumer.accept(make(BotaniaFlowerBlocks.manastar, lightBlue, green, red, cyan)); - - consumer.accept(make(BotaniaFlowerBlocks.endoflame, brown, brown, red, lightGray)); - consumer.accept(make(BotaniaFlowerBlocks.hydroangeas, blue, blue, cyan, cyan)); - consumer.accept(make(BotaniaFlowerBlocks.thermalily, red, orange, orange, runeEarth, runeFire)); - consumer.accept(make(BotaniaFlowerBlocks.rosaArcana, pink, pink, purple, purple, lime, runeMana)); - consumer.accept(make(BotaniaFlowerBlocks.munchdew, lime, lime, red, red, green, runeGluttony)); - consumer.accept(make(BotaniaFlowerBlocks.entropinnyum, red, red, gray, gray, white, white, runeWrath, runeFire)); - consumer.accept(make(BotaniaFlowerBlocks.kekimurus, white, white, orange, orange, brown, brown, runeGluttony, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.gourmaryllis, lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer)); - consumer.accept(make(BotaniaFlowerBlocks.narslimmus, lime, lime, green, green, black, runeSummer, runeWater)); - consumer.accept(make(BotaniaFlowerBlocks.spectrolus, red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.rafflowsia, purple, purple, green, green, black, runeEarth, runePride, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.shulkMeNot, purple, purple, magenta, magenta, lightGray, gaiaSpirit, runeEnvy, runeWrath)); - consumer.accept(make(BotaniaFlowerBlocks.dandelifeon, purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, redstoneRoot, gaiaSpirit)); - - consumer.accept(make(BotaniaFlowerBlocks.jadedAmaranthus, purple, lime, green, runeSpring, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.bellethorn, red, red, red, cyan, cyan, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.dreadthorn, black, black, black, cyan, cyan, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.heiseiDream, magenta, magenta, purple, pink, runeWrath, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.tigerseye, yellow, brown, orange, lime, runeAutumn)); - - net.minecraft.data.recipes.FinishedRecipe base = make(BotaniaFlowerBlocks.orechid, gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust); - net.minecraft.data.recipes.FinishedRecipe gog = make(BotaniaFlowerBlocks.orechid, gray, gray, yellow, yellow, green, green, red, red); - consumer.accept(new GogAlternationResult(gog, base)); - - consumer.accept(make(BotaniaFlowerBlocks.orechidIgnem, red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.fallenKanade, white, white, yellow, yellow, orange, runeSpring)); - consumer.accept(make(BotaniaFlowerBlocks.exoflame, red, red, gray, lightGray, runeFire, runeSummer)); - consumer.accept(make(BotaniaFlowerBlocks.agricarnation, lime, lime, green, yellow, runeSpring, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.hopperhock, gray, gray, lightGray, lightGray, runeAir, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.tangleberrie, cyan, cyan, gray, lightGray, runeAir, runeEarth)); - consumer.accept(make(BotaniaFlowerBlocks.jiyuulia, pink, pink, purple, lightGray, runeWater, runeAir)); - consumer.accept(make(BotaniaFlowerBlocks.rannuncarpus, orange, orange, yellow, runeEarth, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.hyacidus, purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.pollidisiac, red, red, pink, pink, orange, runeLust, runeFire)); - consumer.accept(make(BotaniaFlowerBlocks.clayconia, lightGray, lightGray, gray, cyan, runeEarth)); - consumer.accept(make(BotaniaFlowerBlocks.loonium, green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.daffomill, white, white, brown, yellow, runeAir, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.vinculotus, black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.spectranthemum, white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.medumone, brown, brown, gray, gray, runeEarth, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.marimorphosis, gray, yellow, green, red, runeEarth, runeFire, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.bubbell, cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust)); - consumer.accept(make(BotaniaFlowerBlocks.solegnolia, brown, brown, red, blue, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.bergamute, orange, green, green, redstoneRoot)); - consumer.accept(make(BotaniaFlowerBlocks.labellia, yellow, yellow, blue, white, black, runeAutumn, redstoneRoot, pixieDust)); - - consumer.accept(make(BotaniaBlocks.motifDaybloom, yellow, yellow, orange, lightBlue)); - consumer.accept(make(BotaniaBlocks.motifNightshade, black, black, purple, gray)); - - ItemStack stack = new ItemStack(Items.PLAYER_HEAD); - ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii"); + make(consumer, BotaniaFlowerBlocks.pureDaisy, white, white, white, white); + make(consumer, BotaniaFlowerBlocks.manastar, lightBlue, green, red, cyan); + + make(consumer, BotaniaFlowerBlocks.endoflame, brown, brown, red, lightGray); + make(consumer, BotaniaFlowerBlocks.hydroangeas, blue, blue, cyan, cyan); + make(consumer, BotaniaFlowerBlocks.thermalily, red, orange, orange, runeEarth, runeFire); + make(consumer, BotaniaFlowerBlocks.rosaArcana, pink, pink, purple, purple, lime, runeMana); + make(consumer, BotaniaFlowerBlocks.munchdew, lime, lime, red, red, green, runeGluttony); + make(consumer, BotaniaFlowerBlocks.entropinnyum, red, red, gray, gray, white, white, runeWrath, runeFire); + make(consumer, BotaniaFlowerBlocks.kekimurus, white, white, orange, orange, brown, brown, runeGluttony, pixieDust); + make(consumer, BotaniaFlowerBlocks.gourmaryllis, lightGray, lightGray, yellow, yellow, red, runeFire, runeSummer); + make(consumer, BotaniaFlowerBlocks.narslimmus, lime, lime, green, green, black, runeSummer, runeWater); + make(consumer, BotaniaFlowerBlocks.spectrolus, red, red, green, green, blue, blue, white, white, runeWinter, runeAir, pixieDust); + make(consumer, BotaniaFlowerBlocks.rafflowsia, purple, purple, green, green, black, runeEarth, runePride, pixieDust); + make(consumer, BotaniaFlowerBlocks.shulkMeNot, purple, purple, magenta, magenta, lightGray, gaiaSpirit, runeEnvy, runeWrath); + make(consumer, BotaniaFlowerBlocks.dandelifeon, purple, purple, lime, green, runeWater, runeFire, runeEarth, runeAir, redstoneRoot, gaiaSpirit); + + make(consumer, BotaniaFlowerBlocks.jadedAmaranthus, purple, lime, green, runeSpring, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.bellethorn, red, red, red, cyan, cyan, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.dreadthorn, black, black, black, cyan, cyan, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.heiseiDream, magenta, magenta, purple, pink, runeWrath, pixieDust); + make(consumer, BotaniaFlowerBlocks.tigerseye, yellow, brown, orange, lime, runeAutumn); + + PetalApothecaryRecipe base = new PetalApothecaryRecipe(new ItemStack(BotaniaFlowerBlocks.orechid), DEFAULT_REAGENT, gray, gray, yellow, green, red, runePride, runeGreed, redstoneRoot, pixieDust); + PetalApothecaryRecipe gog = new PetalApothecaryRecipe(new ItemStack(BotaniaFlowerBlocks.orechid), DEFAULT_REAGENT, gray, gray, yellow, yellow, green, green, red, red); + consumer.accept(idFor(prefix("orechid")), new GogAlternationRecipe<>(base, gog), null); + + make(consumer, BotaniaFlowerBlocks.orechidIgnem, red, red, white, white, pink, runePride, runeGreed, redstoneRoot, pixieDust); + make(consumer, BotaniaFlowerBlocks.fallenKanade, white, white, yellow, yellow, orange, runeSpring); + make(consumer, BotaniaFlowerBlocks.exoflame, red, red, gray, lightGray, runeFire, runeSummer); + make(consumer, BotaniaFlowerBlocks.agricarnation, lime, lime, green, yellow, runeSpring, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.hopperhock, gray, gray, lightGray, lightGray, runeAir, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.tangleberrie, cyan, cyan, gray, lightGray, runeAir, runeEarth); + make(consumer, BotaniaFlowerBlocks.jiyuulia, pink, pink, purple, lightGray, runeWater, runeAir); + make(consumer, BotaniaFlowerBlocks.rannuncarpus, orange, orange, yellow, runeEarth, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.hyacidus, purple, purple, magenta, magenta, green, runeWater, runeAutumn, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.pollidisiac, red, red, pink, pink, orange, runeLust, runeFire); + make(consumer, BotaniaFlowerBlocks.clayconia, lightGray, lightGray, gray, cyan, runeEarth); + make(consumer, BotaniaFlowerBlocks.loonium, green, green, green, green, gray, runeSloth, runeGluttony, runeEnvy, redstoneRoot, pixieDust); + make(consumer, BotaniaFlowerBlocks.daffomill, white, white, brown, yellow, runeAir, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.vinculotus, black, black, purple, purple, green, runeWater, runeSloth, runeLust, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.spectranthemum, white, white, lightGray, lightGray, cyan, runeEnvy, runeWater, redstoneRoot, pixieDust); + make(consumer, BotaniaFlowerBlocks.medumone, brown, brown, gray, gray, runeEarth, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.marimorphosis, gray, yellow, green, red, runeEarth, runeFire, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.bubbell, cyan, cyan, lightBlue, lightBlue, blue, blue, runeWater, runeSummer, pixieDust); + make(consumer, BotaniaFlowerBlocks.solegnolia, brown, brown, red, blue, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.bergamute, orange, green, green, redstoneRoot); + make(consumer, BotaniaFlowerBlocks.labellia, yellow, yellow, blue, white, black, runeAutumn, redstoneRoot, pixieDust); + + make(consumer, BotaniaBlocks.motifDaybloom, yellow, yellow, orange, lightBlue); + make(consumer, BotaniaBlocks.motifNightshade, black, black, purple, gray); + + ItemStack vazkiiHead = new ItemStack(Items.PLAYER_HEAD); + ItemNBTHelper.setString(vazkiiHead, "SkullOwner", "Vazkii"); Ingredient[] inputs = new Ingredient[16]; Arrays.fill(inputs, pink); - consumer.accept(new NbtOutputResult( - new FinishedRecipe(idFor(prefix("vazkii_head")), stack, DEFAULT_REAGENT, inputs), - stack.getTag())); + output.accept(idFor(prefix("vazkii_head")), new NbtOutputRecipe<>( + new PetalApothecaryRecipe(vazkiiHead, DEFAULT_REAGENT, inputs), + vazkiiHead.getTag() + ), null); } protected static Ingredient tagIngr(String tag) { return Ingredient.of(TagKey.create(Registries.ITEM, prefix(tag))); } - protected static FinishedRecipe make(ItemLike item, Ingredient... ingredients) { - return new FinishedRecipe(idFor(BuiltInRegistries.ITEM.getKey(item.asItem())), - new ItemStack(item), DEFAULT_REAGENT, ingredients); + protected static void make(RecipeOutput consumer, ItemLike output, Ingredient... ingredients) { + consumer.accept(idFor(BuiltInRegistries.ITEM.getKey(output.asItem())), + new PetalApothecaryRecipe(new ItemStack(output), DEFAULT_REAGENT, ingredients), null); } protected static ResourceLocation idFor(ResourceLocation name) { return new ResourceLocation(name.getNamespace(), "petal_apothecary/" + name.getPath()); } - - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - private final ResourceLocation id; - private final ItemStack output; - private final Ingredient reagent; - private final Ingredient[] inputs; - - private FinishedRecipe(ResourceLocation id, ItemStack output, Ingredient reagent, Ingredient... inputs) { - this.id = id; - this.output = output; - this.reagent = reagent; - this.inputs = inputs; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("output", ItemNBTHelper.serializeStack(output)); - JsonArray ingredients = new JsonArray(); - for (Ingredient ingr : inputs) { - ingredients.add(ingr.toJson()); - } - json.add("reagent", reagent.toJson()); - json.add("ingredients", ingredients); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.PETAL_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/PureDaisyProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/PureDaisyProvider.java index e308a22a87..53307e1cfa 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/PureDaisyProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/PureDaisyProvider.java @@ -8,14 +8,11 @@ */ package vazkii.botania.data.recipes; -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; - -import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.commands.CacheableFunction; import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -24,11 +21,9 @@ import vazkii.botania.api.recipe.StateIngredient; import vazkii.botania.common.block.BotaniaBlocks; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; +import vazkii.botania.common.crafting.PureDaisyRecipe; import vazkii.botania.common.crafting.StateIngredients; -import java.util.function.Consumer; - import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class PureDaisyProvider extends BotaniaRecipeProvider { @@ -37,20 +32,19 @@ public PureDaisyProvider(PackOutput packOutput) { } @Override - public void buildRecipes(Consumer consumer) { - - consumer.accept(new FinishedRecipe(id("livingrock"), StateIngredients.of(Blocks.STONE), BotaniaBlocks.livingrock.defaultBlockState())); - consumer.accept(new StateCopyingRecipe(id("livingwood"), - StateIngredients.of(BlockTags.LOGS), - BotaniaBlocks.livingwoodLog)); - - consumer.accept(new FinishedRecipe(id("cobblestone"), StateIngredients.of(Blocks.NETHERRACK), Blocks.COBBLESTONE.defaultBlockState())); - consumer.accept(new FinishedRecipe(id("end_stone_to_cobbled_deepslate"), StateIngredients.of(Blocks.END_STONE), Blocks.COBBLED_DEEPSLATE.defaultBlockState(), FinishedRecipe.DEFAULT_TIME, prefix("ender_air_release"))); - consumer.accept(new FinishedRecipe(id("sand"), StateIngredients.of(Blocks.SOUL_SAND), Blocks.SAND.defaultBlockState())); - consumer.accept(new FinishedRecipe(id("packed_ice"), StateIngredients.of(Blocks.ICE), Blocks.PACKED_ICE.defaultBlockState())); - consumer.accept(new FinishedRecipe(id("blue_ice"), StateIngredients.of(Blocks.PACKED_ICE), Blocks.BLUE_ICE.defaultBlockState())); - consumer.accept(new FinishedRecipe(id("obsidian"), StateIngredients.of(BotaniaBlocks.blazeBlock), Blocks.OBSIDIAN.defaultBlockState())); - consumer.accept(new FinishedRecipe(id("snow_block"), StateIngredients.of(Blocks.WATER), Blocks.SNOW_BLOCK.defaultBlockState())); + public void buildRecipes(RecipeOutput consumer) { + + normal(consumer, id("livingrock"), StateIngredients.of(Blocks.STONE), BotaniaBlocks.livingrock.defaultBlockState()); + stateCopying(consumer, id("livingwood"), StateIngredients.of(BlockTags.LOGS), BotaniaBlocks.livingwoodLog); + + normal(consumer, id("cobblestone"), StateIngredients.of(Blocks.NETHERRACK), Blocks.COBBLESTONE.defaultBlockState()); + withFunction(consumer, id("end_stone_to_cobbled_deepslate"), StateIngredients.of(Blocks.END_STONE), + Blocks.COBBLED_DEEPSLATE.defaultBlockState(), new CacheableFunction(prefix("ender_air_release"))); + normal(consumer, id("sand"), StateIngredients.of(Blocks.SOUL_SAND), Blocks.SAND.defaultBlockState()); + normal(consumer, id("packed_ice"), StateIngredients.of(Blocks.ICE), Blocks.PACKED_ICE.defaultBlockState()); + normal(consumer, id("blue_ice"), StateIngredients.of(Blocks.PACKED_ICE), Blocks.BLUE_ICE.defaultBlockState()); + normal(consumer, id("obsidian"), StateIngredients.of(BotaniaBlocks.blazeBlock), Blocks.OBSIDIAN.defaultBlockState()); + normal(consumer, id("snow_block"), StateIngredients.of(Blocks.WATER), Blocks.SNOW_BLOCK.defaultBlockState()); } @Override @@ -58,89 +52,19 @@ public String getName() { return "Botania Pure Daisy recipes"; } - private static ResourceLocation id(String path) { - return prefix("pure_daisy/" + path); + private void normal(RecipeOutput consumer, ResourceLocation id, StateIngredient input, BlockState output) { + withFunction(consumer, id, input, output, null); } - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - public static final int DEFAULT_TIME = 150; - - protected final ResourceLocation id; - protected final StateIngredient input; - protected final BlockState outputState; - protected final int time; - @Nullable - private final ResourceLocation function; - - public FinishedRecipe(ResourceLocation id, StateIngredient input, BlockState state) { - this(id, input, state, DEFAULT_TIME); - } - - public FinishedRecipe(ResourceLocation id, StateIngredient input, BlockState state, int time) { - this(id, input, state, time, null); - } - - public FinishedRecipe(ResourceLocation id, StateIngredient input, BlockState state, int time, @Nullable ResourceLocation function) { - Preconditions.checkArgument(time >= 0, "Time must be nonnegative"); - this.id = id; - this.input = input; - this.outputState = state; - this.time = time; - this.function = function; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("input", input.serialize()); - json.add("output", StateIngredients.serializeBlockState(outputState)); - if (time != DEFAULT_TIME) { - json.addProperty("time", time); - } - if (function != null) { - json.addProperty("success_function", function.toString()); - } - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.PURE_DAISY_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } + private void withFunction(RecipeOutput consumer, ResourceLocation id, StateIngredient input, BlockState output, @Nullable CacheableFunction successFunction) { + consumer.accept(id, new PureDaisyRecipe(input, StateIngredients.of(output), 150, false, successFunction), null); } - protected static class StateCopyingRecipe extends FinishedRecipe { - public StateCopyingRecipe(ResourceLocation id, StateIngredient input, Block block) { - super(id, input, block.defaultBlockState()); - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("input", input.serialize()); - json.addProperty("output", BuiltInRegistries.BLOCK.getKey(outputState.getBlock()).toString()); - if (time != DEFAULT_TIME) { - json.addProperty("time", time); - } - } + private void stateCopying(RecipeOutput consumer, ResourceLocation id, StateIngredient input, Block output) { + consumer.accept(id, new PureDaisyRecipe(input, StateIngredients.of(output), 150, true, null), null); + } - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.COPYING_PURE_DAISY_SERIALIZER; - } + private static ResourceLocation id(String path) { + return prefix("pure_daisy/" + path); } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/RunicAltarProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/RunicAltarProvider.java index bca9373ca7..a8ea0a2f84 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/RunicAltarProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/RunicAltarProvider.java @@ -8,27 +8,21 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.block.Blocks; -import org.jetbrains.annotations.Nullable; - -import vazkii.botania.common.crafting.BotaniaRecipeTypes; -import vazkii.botania.common.helper.ItemNBTHelper; +import vazkii.botania.common.block.BotaniaBlocks; +import vazkii.botania.common.crafting.RunicAltarRecipe; +import vazkii.botania.common.crafting.recipe.HeadRecipe; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.lib.BotaniaTags; -import java.util.function.Consumer; - import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class RunicAltarProvider extends BotaniaRecipeProvider { @@ -42,7 +36,7 @@ public String getName() { } @Override - public void buildRecipes(Consumer consumer) { + public void buildRecipes(RecipeOutput consumer) { final int costTier1 = 5200; final int costTier2 = 8000; final int costTier3 = 12000; @@ -50,14 +44,14 @@ public void buildRecipes(Consumer con Ingredient manaSteel = Ingredient.of(BotaniaTags.Items.INGOTS_MANASTEEL); Ingredient manaDiamond = Ingredient.of(BotaniaTags.Items.GEMS_MANA_DIAMOND); Ingredient manaPowder = Ingredient.of(BotaniaTags.Items.DUSTS_MANA); - consumer.accept(new FinishedRecipe(idFor("water"), new ItemStack(BotaniaItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.of(Items.BONE_MEAL), Ingredient.of(Blocks.SUGAR_CANE), Ingredient.of(Items.FISHING_ROD))); - consumer.accept(new FinishedRecipe(idFor("fire"), new ItemStack(BotaniaItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.of(Items.NETHER_BRICK), Ingredient.of(Items.GUNPOWDER), Ingredient.of(Items.NETHER_WART))); + defaultReagent(consumer, idFor("water"), new ItemStack(BotaniaItems.runeWater, 2), costTier1, manaPowder, manaSteel, Ingredient.of(Items.BONE_MEAL), Ingredient.of(Blocks.SUGAR_CANE), Ingredient.of(Items.FISHING_ROD)); + defaultReagent(consumer, idFor("fire"), new ItemStack(BotaniaItems.runeFire, 2), costTier1, manaPowder, manaSteel, Ingredient.of(Items.NETHER_BRICK), Ingredient.of(Items.GUNPOWDER), Ingredient.of(Items.NETHER_WART)); Ingredient stone = Ingredient.of(Blocks.STONE); Ingredient coalBlock = Ingredient.of(Blocks.COAL_BLOCK); - consumer.accept(new FinishedRecipe(idFor("earth"), new ItemStack(BotaniaItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.of(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM))); + defaultReagent(consumer, idFor("earth"), new ItemStack(BotaniaItems.runeEarth, 2), costTier1, manaPowder, manaSteel, stone, coalBlock, Ingredient.of(Blocks.BROWN_MUSHROOM, Blocks.RED_MUSHROOM)); - consumer.accept(new FinishedRecipe(idFor("air"), new ItemStack(BotaniaItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.of(ItemTags.WOOL_CARPETS), Ingredient.of(Items.FEATHER), Ingredient.of(Items.STRING))); + defaultReagent(consumer, idFor("air"), new ItemStack(BotaniaItems.runeAir, 2), costTier1, manaPowder, manaSteel, Ingredient.of(ItemTags.WOOL_CARPETS), Ingredient.of(Items.FEATHER), Ingredient.of(Items.STRING)); Ingredient fire = Ingredient.of(BotaniaItems.runeFire); Ingredient water = Ingredient.of(BotaniaItems.runeWater); @@ -67,89 +61,37 @@ public void buildRecipes(Consumer con Ingredient sapling = Ingredient.of(ItemTags.SAPLINGS); Ingredient leaves = Ingredient.of(ItemTags.LEAVES); Ingredient sand = Ingredient.of(ItemTags.SAND); - consumer.accept(new FinishedRecipe(idFor("spring"), new ItemStack(BotaniaItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.of(Items.WHEAT))); - consumer.accept(new FinishedRecipe(idFor("summer"), new ItemStack(BotaniaItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.of(Items.SLIME_BALL), Ingredient.of(Items.MELON_SLICE))); - consumer.accept(new FinishedRecipe(idFor("autumn"), new ItemStack(BotaniaItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.of(Items.SPIDER_EYE))); + defaultReagent(consumer, idFor("spring"), new ItemStack(BotaniaItems.runeSpring), costTier2, water, fire, sapling, sapling, sapling, Ingredient.of(Items.WHEAT)); + defaultReagent(consumer, idFor("summer"), new ItemStack(BotaniaItems.runeSummer), costTier2, earth, air, sand, sand, Ingredient.of(Items.SLIME_BALL), Ingredient.of(Items.MELON_SLICE)); + defaultReagent(consumer, idFor("autumn"), new ItemStack(BotaniaItems.runeAutumn), costTier2, fire, air, leaves, leaves, leaves, Ingredient.of(Items.SPIDER_EYE)); - consumer.accept(new FinishedRecipe(idFor("winter"), new ItemStack(BotaniaItems.runeWinter), costTier2, water, earth, Ingredient.of(Blocks.SNOW_BLOCK), Ingredient.of(Blocks.SNOW_BLOCK), Ingredient.of(ItemTags.WOOL), Ingredient.of(Blocks.CAKE))); + defaultReagent(consumer, idFor("winter"), new ItemStack(BotaniaItems.runeWinter), costTier2, water, earth, Ingredient.of(Blocks.SNOW_BLOCK), Ingredient.of(Blocks.SNOW_BLOCK), Ingredient.of(ItemTags.WOOL), Ingredient.of(Blocks.CAKE)); Ingredient spring = Ingredient.of(BotaniaItems.runeSpring); Ingredient summer = Ingredient.of(BotaniaItems.runeSummer); Ingredient autumn = Ingredient.of(BotaniaItems.runeAutumn); Ingredient winter = Ingredient.of(BotaniaItems.runeWinter); - consumer.accept(new FinishedRecipe(idFor("mana"), new ItemStack(BotaniaItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.of(BotaniaItems.manaPearl))); + defaultReagent(consumer, idFor("mana"), new ItemStack(BotaniaItems.runeMana), costTier2, manaSteel, manaSteel, manaSteel, manaSteel, manaSteel, Ingredient.of(BotaniaItems.manaPearl)); - consumer.accept(new FinishedRecipe(idFor("lust"), new ItemStack(BotaniaItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air)); - consumer.accept(new FinishedRecipe(idFor("gluttony"), new ItemStack(BotaniaItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire)); - consumer.accept(new FinishedRecipe(idFor("greed"), new ItemStack(BotaniaItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water)); - consumer.accept(new FinishedRecipe(idFor("sloth"), new ItemStack(BotaniaItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air)); - consumer.accept(new FinishedRecipe(idFor("wrath"), new ItemStack(BotaniaItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth)); - consumer.accept(new FinishedRecipe(idFor("envy"), new ItemStack(BotaniaItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water)); - consumer.accept(new FinishedRecipe(idFor("pride"), new ItemStack(BotaniaItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire)); + defaultReagent(consumer, idFor("lust"), new ItemStack(BotaniaItems.runeLust), costTier3, manaDiamond, manaDiamond, summer, air); + defaultReagent(consumer, idFor("gluttony"), new ItemStack(BotaniaItems.runeGluttony), costTier3, manaDiamond, manaDiamond, winter, fire); + defaultReagent(consumer, idFor("greed"), new ItemStack(BotaniaItems.runeGreed), costTier3, manaDiamond, manaDiamond, spring, water); + defaultReagent(consumer, idFor("sloth"), new ItemStack(BotaniaItems.runeSloth), costTier3, manaDiamond, manaDiamond, autumn, air); + defaultReagent(consumer, idFor("wrath"), new ItemStack(BotaniaItems.runeWrath), costTier3, manaDiamond, manaDiamond, winter, earth); + defaultReagent(consumer, idFor("envy"), new ItemStack(BotaniaItems.runeEnvy), costTier3, manaDiamond, manaDiamond, winter, water); + defaultReagent(consumer, idFor("pride"), new ItemStack(BotaniaItems.runePride), costTier3, manaDiamond, manaDiamond, summer, fire); - consumer.accept(new FinishedHeadRecipe(idFor("head"), new ItemStack(Items.PLAYER_HEAD), 22500, Ingredient.of(Items.SKELETON_SKULL), Ingredient.of(BotaniaItems.pixieDust), Ingredient.of(Items.PRISMARINE_CRYSTALS), Ingredient.of(Items.NAME_TAG), Ingredient.of(Items.GOLDEN_APPLE))); + consumer.accept(idFor("head"), new HeadRecipe(new ItemStack(Items.PLAYER_HEAD), DEFAULT_REAGENT, 22500, Ingredient.of(Items.SKELETON_SKULL), Ingredient.of(BotaniaItems.pixieDust), Ingredient.of(Items.PRISMARINE_CRYSTALS), Ingredient.of(Items.NAME_TAG), Ingredient.of(Items.GOLDEN_APPLE)), null); } private static ResourceLocation idFor(String s) { return prefix("runic_altar/" + s); } - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - private final ResourceLocation id; - private final ItemStack output; - private final int mana; - private final Ingredient[] inputs; - - protected FinishedRecipe(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) { - this.id = id; - this.output = output; - this.mana = mana; - this.inputs = inputs; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.add("output", ItemNBTHelper.serializeStack(output)); - JsonArray ingredients = new JsonArray(); - for (Ingredient ingr : inputs) { - ingredients.add(ingr.toJson()); - } - json.addProperty("mana", mana); - json.add("ingredients", ingredients); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.RUNE_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } - - private static class FinishedHeadRecipe extends FinishedRecipe { - private FinishedHeadRecipe(ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) { - super(id, output, mana, inputs); - } + protected static Ingredient DEFAULT_REAGENT = Ingredient.of(BotaniaBlocks.livingrock); - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.RUNE_HEAD_SERIALIZER; - } + protected static void defaultReagent(RecipeOutput consumer, ResourceLocation id, ItemStack output, int mana, Ingredient... inputs) { + consumer.accept(id, new RunicAltarRecipe(output, DEFAULT_REAGENT, mana, inputs, new Ingredient[] {}), null); } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/SmeltingProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/SmeltingProvider.java index d1e4bfaf70..f21788f1a5 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/SmeltingProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/SmeltingProvider.java @@ -8,29 +8,28 @@ */ package vazkii.botania.data.recipes; +import net.minecraft.advancements.Criterion; import net.minecraft.advancements.critereon.InventoryChangeTrigger; import net.minecraft.data.PackOutput; -import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.RecipeCategory; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.data.recipes.SimpleCookingRecipeBuilder; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.ItemLike; import vazkii.botania.common.block.BotaniaBlocks; -import java.util.function.Consumer; - public class SmeltingProvider extends BotaniaRecipeProvider { public SmeltingProvider(PackOutput packOutput) { super(packOutput); } - private static InventoryChangeTrigger.TriggerInstance conditionsFromItem(ItemLike item) { + private static Criterion conditionsFromItem(ItemLike item) { return CraftingRecipeProvider.conditionsFromItem(item); } @Override - public void buildRecipes(Consumer consumer) { + public void buildRecipes(RecipeOutput consumer) { SimpleCookingRecipeBuilder.smelting(Ingredient.of(BotaniaBlocks.biomeCobblestoneForest), RecipeCategory.BUILDING_BLOCKS, BotaniaBlocks.biomeStoneForest, 0.1f, 200) .unlockedBy("has_item", conditionsFromItem(BotaniaBlocks.biomeCobblestoneForest)) diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/StonecuttingProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/StonecuttingProvider.java index c1a5ed787f..22174eb608 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/StonecuttingProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/StonecuttingProvider.java @@ -8,38 +8,36 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonObject; - import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.PackOutput; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.SingleItemRecipeBuilder; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.StonecutterRecipe; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import vazkii.botania.common.block.BotaniaBlocks; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.ResourceLocationHelper; import java.util.List; -import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.IntStream; +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + public class StonecuttingProvider extends BotaniaRecipeProvider { public StonecuttingProvider(PackOutput packOutput) { super(packOutput); } @Override - public void buildRecipes(Consumer consumer) { + public void buildRecipes(RecipeOutput consumer) { for (String variant : LibBlockNames.METAMORPHIC_VARIANTS) { registerForMetamorphic(variant, consumer); } @@ -52,77 +50,75 @@ public void buildRecipes(Consumer consumer) { registerForQuartz(variant, consumer); } - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolished)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrick)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickChiseled)); - consumer.accept(stonecutting(BotaniaBlocks.livingrock, BotaniaBlocks.livingrockSlate)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrick)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickChiseled)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickWall)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickChiseled)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossySlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossyStairs)); - consumer.accept(stonecutting(BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossyWall)); - consumer.accept(stonecutting(BotaniaBlocks.shimmerrock, BotaniaBlocks.shimmerrockSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.shimmerrock, BotaniaBlocks.shimmerrockStairs)); - - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaStairs)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrick)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickStairs)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickWall)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickSlab, 2)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickStairs)); - consumer.accept(stonecutting(BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickWall)); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockStairs); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockWall); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolished); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedStairs); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockPolishedWall); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrick); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickStairs); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickWall); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockBrickChiseled); + stonecutting(consumer, BotaniaBlocks.livingrock, BotaniaBlocks.livingrockSlate); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedStairs); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockPolishedWall); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrick); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickStairs); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickWall); + stonecutting(consumer, BotaniaBlocks.livingrockPolished, BotaniaBlocks.livingrockBrickChiseled); + stonecutting(consumer, BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickSlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickStairs); + stonecutting(consumer, BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickWall); + stonecutting(consumer, BotaniaBlocks.livingrockBrick, BotaniaBlocks.livingrockBrickChiseled); + stonecutting(consumer, BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossySlab, 2); + stonecutting(consumer, BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossyStairs); + stonecutting(consumer, BotaniaBlocks.livingrockBrickMossy, BotaniaBlocks.livingrockBrickMossyWall); + stonecutting(consumer, BotaniaBlocks.shimmerrock, BotaniaBlocks.shimmerrockSlab, 2); + stonecutting(consumer, BotaniaBlocks.shimmerrock, BotaniaBlocks.shimmerrockStairs); + + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaSlab, 2); + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaStairs); + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrick); + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickSlab, 2); + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickStairs); + stonecutting(consumer, BotaniaBlocks.corporeaBlock, BotaniaBlocks.corporeaBrickWall); + stonecutting(consumer, BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickSlab, 2); + stonecutting(consumer, BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickStairs); + stonecutting(consumer, BotaniaBlocks.corporeaBrick, BotaniaBlocks.corporeaBrickWall); List allAzulejos = IntStream.range(0, 16).mapToObj(i -> "azulejo_" + i) .map(ResourceLocationHelper::prefix) .map(BuiltInRegistries.ITEM::get) .collect(Collectors.toList()); - for (Item azulejo : allAzulejos) { - consumer.accept(anyToAnyStonecutting(allAzulejos, azulejo)); - } + anyToAnyStonecutting(consumer, allAzulejos); } - private void registerForQuartz(String variant, Consumer consumer) { + private void registerForQuartz(String variant, RecipeOutput consumer) { Block base = BuiltInRegistries.BLOCK.get(prefix(variant)); Block slab = BuiltInRegistries.BLOCK.get(prefix(variant + LibBlockNames.SLAB_SUFFIX)); Block stairs = BuiltInRegistries.BLOCK.get(prefix(variant + LibBlockNames.STAIR_SUFFIX)); Block chiseled = BuiltInRegistries.BLOCK.get(prefix("chiseled_" + variant)); Block pillar = BuiltInRegistries.BLOCK.get(prefix(variant + "_pillar")); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stairs)); - consumer.accept(stonecutting(base, chiseled)); - consumer.accept(stonecutting(base, pillar)); + stonecutting(consumer, base, slab, 2); + stonecutting(consumer, base, stairs); + stonecutting(consumer, base, chiseled); + stonecutting(consumer, base, pillar); } - private void registerForPavement(String color, Consumer consumer) { + private void registerForPavement(String color, RecipeOutput consumer) { Block base = BuiltInRegistries.BLOCK.get(prefix(color + LibBlockNames.PAVEMENT_SUFFIX)); Block slab = BuiltInRegistries.BLOCK.get(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.SLAB_SUFFIX)); Block stair = BuiltInRegistries.BLOCK.get(prefix(color + LibBlockNames.PAVEMENT_SUFFIX + LibBlockNames.STAIR_SUFFIX)); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stair)); + stonecutting(consumer, base, slab, 2); + stonecutting(consumer, base, stair); } - private void registerForMetamorphic(String variant, Consumer consumer) { + private void registerForMetamorphic(String variant, RecipeOutput consumer) { Block base = BuiltInRegistries.BLOCK.get(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone")); Block slab = BuiltInRegistries.BLOCK.get(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.SLAB_SUFFIX)); Block stair = BuiltInRegistries.BLOCK.get(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_stone" + LibBlockNames.STAIR_SUFFIX)); @@ -137,23 +133,23 @@ private void registerForMetamorphic(String variant, Consumer con Block cobbleStair = BuiltInRegistries.BLOCK.get(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.STAIR_SUFFIX)); Block cobbleWall = BuiltInRegistries.BLOCK.get(prefix(LibBlockNames.METAMORPHIC_PREFIX + variant + "_cobblestone" + LibBlockNames.WALL_SUFFIX)); - consumer.accept(stonecutting(base, slab, 2)); - consumer.accept(stonecutting(base, stair)); - consumer.accept(stonecutting(base, wall)); - consumer.accept(stonecutting(base, brick)); - consumer.accept(stonecutting(base, brickSlab, 2)); - consumer.accept(stonecutting(base, brickStair)); - consumer.accept(stonecutting(base, brickWall)); - consumer.accept(stonecutting(base, chiseledBrick)); - - consumer.accept(stonecutting(brick, brickSlab, 2)); - consumer.accept(stonecutting(brick, brickStair)); - consumer.accept(stonecutting(brick, brickWall)); - consumer.accept(stonecutting(brick, chiseledBrick)); - - consumer.accept(stonecutting(cobble, cobbleSlab, 2)); - consumer.accept(stonecutting(cobble, cobbleStair)); - consumer.accept(stonecutting(cobble, cobbleWall)); + stonecutting(consumer, base, slab, 2); + stonecutting(consumer, base, stair); + stonecutting(consumer, base, wall); + stonecutting(consumer, base, brick); + stonecutting(consumer, base, brickSlab, 2); + stonecutting(consumer, base, brickStair); + stonecutting(consumer, base, brickWall); + stonecutting(consumer, base, chiseledBrick); + + stonecutting(consumer, brick, brickSlab, 2); + stonecutting(consumer, brick, brickStair); + stonecutting(consumer, brick, brickWall); + stonecutting(consumer, brick, chiseledBrick); + + stonecutting(consumer, cobble, cobbleSlab, 2); + stonecutting(consumer, cobble, cobbleStair); + stonecutting(consumer, cobble, cobbleWall); } @NotNull @@ -168,39 +164,31 @@ protected ResourceLocation idFor(ItemLike a, ItemLike b) { return prefix("stonecutting/" + aId.getPath() + "_to_" + bId.getPath()); } - protected FinishedRecipe stonecutting(ItemLike input, ItemLike output) { - return stonecutting(input, output, 1); + protected void stonecutting(RecipeOutput consumer, ResourceLocation id, Ingredient input, ItemLike output) { + stonecutting(consumer, id, input, output, 1); } - protected FinishedRecipe stonecutting(ItemLike input, ItemLike output, int count) { - return new Result(idFor(input, output), RecipeSerializer.STONECUTTER, Ingredient.of(input), output.asItem(), count); + protected void stonecutting(RecipeOutput consumer, ResourceLocation id, Ingredient input, ItemLike output, int count) { + ItemStack outputStack = new ItemStack(output); + outputStack.setCount(count); + consumer.accept(id, new StonecutterRecipe("", input, outputStack), null); } - protected FinishedRecipe anyToAnyStonecutting(List inputs, ItemLike output) { - Ingredient input = Ingredient.of(inputs.stream().filter(obj -> output != obj).toArray(ItemLike[]::new)); - return new Result(prefix("stonecutting/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()), RecipeSerializer.STONECUTTER, input, output.asItem(), 1); + protected void stonecutting(RecipeOutput consumer, ItemLike input, ItemLike output) { + stonecutting(consumer, input, output, 1); } - protected ResourceLocation prefix(String path) { - return ResourceLocationHelper.prefix(path); + protected void stonecutting(RecipeOutput consumer, ItemLike input, ItemLike output, int count) { + ItemStack outputStack = new ItemStack(output); + outputStack.setCount(count); + consumer.accept(idFor(input, output), new StonecutterRecipe("", Ingredient.of(input), outputStack), null); } - // Wrapper without advancements - public static class Result extends SingleItemRecipeBuilder.Result { - public Result(ResourceLocation id, RecipeSerializer serializer, Ingredient input, Item result, int count) { - super(id, serializer, "", input, result, count, null, null); - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; + protected void anyToAnyStonecutting(RecipeOutput consumer, List inputs) { + for (ItemLike output : inputs) { + Ingredient input = Ingredient.of(inputs.stream().filter(thisInput -> output != thisInput).toArray(ItemLike[]::new)); + ResourceLocation id = prefix("stonecutting/" + BuiltInRegistries.ITEM.getKey(output.asItem()).getPath()); + stonecutting(consumer, id, input, output); } } } diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/TerrestrialAgglomerationProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/TerrestrialAgglomerationProvider.java index 8f60d6a753..907b7d4286 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/TerrestrialAgglomerationProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/TerrestrialAgglomerationProvider.java @@ -8,24 +8,16 @@ */ package vazkii.botania.data.recipes; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - import net.minecraft.data.PackOutput; +import net.minecraft.data.recipes.RecipeOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; - -import org.jetbrains.annotations.Nullable; import vazkii.botania.common.block.block_entity.mana.ManaPoolBlockEntity; -import vazkii.botania.common.crafting.BotaniaRecipeTypes; -import vazkii.botania.common.helper.ItemNBTHelper; +import vazkii.botania.common.crafting.TerrestrialAgglomerationRecipe; import vazkii.botania.common.item.BotaniaItems; -import java.util.function.Consumer; - import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class TerrestrialAgglomerationProvider extends BotaniaRecipeProvider { @@ -39,60 +31,15 @@ public String getName() { } @Override - public void buildRecipes(Consumer consumer) { - consumer.accept(new FinishedRecipe(idFor("terrasteel_ingot"), ManaPoolBlockEntity.MAX_MANA / 2, + public void buildRecipes(RecipeOutput consumer) { + consumer.accept(idFor("terrasteel_ingot"), new TerrestrialAgglomerationRecipe( + ManaPoolBlockEntity.MAX_MANA / 2, new ItemStack(BotaniaItems.terrasteel), Ingredient.of(BotaniaItems.manaSteel), - Ingredient.of(BotaniaItems.manaPearl), Ingredient.of(BotaniaItems.manaDiamond))); + Ingredient.of(BotaniaItems.manaPearl), Ingredient.of(BotaniaItems.manaDiamond) + ), null); } private static ResourceLocation idFor(String s) { return prefix("terra_plate/" + s); } - - protected static class FinishedRecipe implements net.minecraft.data.recipes.FinishedRecipe { - private final ResourceLocation id; - private final int mana; - private final ItemStack output; - private final Ingredient[] inputs; - - public FinishedRecipe(ResourceLocation id, int mana, ItemStack output, Ingredient... inputs) { - this.id = id; - this.mana = mana; - this.output = output; - this.inputs = inputs; - } - - @Override - public void serializeRecipeData(JsonObject json) { - json.addProperty("mana", mana); - JsonArray ingredients = new JsonArray(); - for (Ingredient ingr : inputs) { - ingredients.add(ingr.toJson()); - } - json.add("ingredients", ingredients); - json.add("result", ItemNBTHelper.serializeStack(output)); - } - - @Override - public ResourceLocation getId() { - return id; - } - - @Override - public RecipeSerializer getType() { - return BotaniaRecipeTypes.TERRA_PLATE_SERIALIZER; - } - - @Nullable - @Override - public JsonObject serializeAdvancement() { - return null; - } - - @Nullable - @Override - public ResourceLocation getAdvancementId() { - return null; - } - } }