From bd833486b6603116466674242ecbdd7d7c31e365 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sat, 6 Aug 2022 09:38:33 -0400 Subject: [PATCH] skilletsexual --- .../datagen/IXplatConditionsBuilder.java | 9 + .../hexcasting/datagen/IXplatIngredients.java | 2 + ...{HexplatRecipes.java => HexplatRecipes.kt} | 386 ++++++++++-------- .../builders/CompatIngredientValue.java | 33 ++ .../builders/CreateCrushingRecipeBuilder.java | 10 +- .../src/main/resources/hexplat.accesswidener | 2 + Fabric/gradle.properties | 2 +- Fabric/src/generated/resources/.cache/cache | 16 +- .../recipes/crushing/amethyst_block.json | 10 +- .../recipes/crushing/amethyst_cluster.json | 10 +- .../create/crushing/amethyst_shard.json | 10 +- .../farmersdelight/cutting/akashic_door.json | 8 + .../farmersdelight/cutting/akashic_log.json | 10 +- .../cutting/akashic_trapdoor.json | 8 + .../farmersdelight/cutting/akashic_wood.json | 10 +- .../recipes/pride_colorizer_pansexual.json | 9 +- .../hexcasting/fabric/FabricHexInitializer.kt | 5 +- .../datagen/HexFabricConditionsBuilder.java | 96 +++++ .../datagen/HexFabricDataGenerators.java | 9 +- .../FabricCreateCrushingRecipeBuilder.java | 37 -- .../FabricModConditionalIngredient.java | 105 +++++ .../recipe/FabricUnsealedIngredient.java | 3 +- .../main/resources/fabricasting.accesswidener | 1 + Forge/src/generated/resources/.cache/cache | 16 +- .../recipes/crushing/amethyst_block.json | 45 +- .../recipes/crushing/amethyst_cluster.json | 51 ++- .../create/crushing/amethyst_shard.json | 43 +- .../farmersdelight/cutting/akashic_door.json | 37 +- .../farmersdelight/cutting/akashic_log.json | 47 ++- .../cutting/akashic_trapdoor.json | 37 +- .../farmersdelight/cutting/akashic_wood.json | 47 ++- .../recipes/pride_colorizer_pansexual.json | 9 +- .../hexcasting/forge/ForgeHexInitializer.java | 6 +- .../datagen/HexForgeConditionsBuilder.java | 63 +++ .../forge/datagen/HexForgeDataGenerators.java | 11 +- .../ForgeCreateCrushingRecipeBuilder.java | 40 -- .../recipe/ForgeModConditionalIngredient.java | 105 +++++ .../forge/recipe/ForgeUnsealedIngredient.java | 5 + .../resources/META-INF/accesstransformer.cfg | 2 + 39 files changed, 952 insertions(+), 403 deletions(-) create mode 100644 Common/src/main/java/at/petrak/hexcasting/datagen/IXplatConditionsBuilder.java rename Common/src/main/java/at/petrak/hexcasting/datagen/recipe/{HexplatRecipes.java => HexplatRecipes.kt} (65%) create mode 100644 Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CompatIngredientValue.java create mode 100644 Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricConditionsBuilder.java delete mode 100644 Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/builders/FabricCreateCrushingRecipeBuilder.java create mode 100644 Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricModConditionalIngredient.java create mode 100644 Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeConditionsBuilder.java delete mode 100644 Forge/src/main/java/at/petrak/hexcasting/forge/datagen/builders/ForgeCreateCrushingRecipeBuilder.java create mode 100644 Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeModConditionalIngredient.java diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatConditionsBuilder.java b/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatConditionsBuilder.java new file mode 100644 index 00000000..d283711f --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatConditionsBuilder.java @@ -0,0 +1,9 @@ +package at.petrak.hexcasting.datagen; + +import net.minecraft.data.recipes.RecipeBuilder; + +public interface IXplatConditionsBuilder extends RecipeBuilder { + IXplatConditionsBuilder whenModLoaded(String modid); + + IXplatConditionsBuilder whenModMissing(String modid); +} diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatIngredients.java b/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatIngredients.java index 0f233b30..274de8b9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatIngredients.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/IXplatIngredients.java @@ -25,6 +25,8 @@ public interface IXplatIngredients { Ingredient stick(); + Ingredient whenModIngredient(Ingredient defaultIngredient, String modid, Ingredient modIngredient); + ToolIngredient axeStrip(); ToolIngredient axeDig(); diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt similarity index 65% rename from Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java rename to Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt index 59321e00..3a23a697 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt @@ -1,71 +1,66 @@ -package at.petrak.hexcasting.datagen.recipe; +package at.petrak.hexcasting.datagen.recipe -import at.petrak.hexcasting.api.HexAPI; -import at.petrak.hexcasting.api.advancements.OvercastTrigger; -import at.petrak.hexcasting.api.mod.HexItemTags; -import at.petrak.hexcasting.common.items.ItemWand; -import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer; -import at.petrak.hexcasting.common.lib.HexBlocks; -import at.petrak.hexcasting.common.lib.HexItems; -import at.petrak.hexcasting.common.recipe.SealFocusRecipe; -import at.petrak.hexcasting.common.recipe.SealSpellbookRecipe; -import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper; -import at.petrak.hexcasting.common.recipe.ingredient.VillagerIngredient; -import at.petrak.hexcasting.datagen.IXplatIngredients; -import at.petrak.hexcasting.datagen.recipe.builders.BrainsweepRecipeBuilder; -import at.petrak.hexcasting.datagen.recipe.builders.CreateCrushingRecipeBuilder; -import at.petrak.hexcasting.datagen.recipe.builders.FarmersDelightCuttingRecipeBuilder; -import at.petrak.paucal.api.datagen.PaucalRecipeProvider; -import net.minecraft.advancements.critereon.EntityPredicate; -import net.minecraft.advancements.critereon.MinMaxBounds; -import net.minecraft.core.Registry; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.recipes.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.tags.ItemTags; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.DyeItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.SimpleRecipeSerializer; -import net.minecraft.world.level.block.Blocks; +import at.petrak.hexcasting.api.HexAPI +import at.petrak.hexcasting.api.advancements.OvercastTrigger +import at.petrak.hexcasting.api.mod.HexItemTags +import at.petrak.hexcasting.common.items.ItemWand +import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer +import at.petrak.hexcasting.common.lib.HexBlocks +import at.petrak.hexcasting.common.lib.HexItems +import at.petrak.hexcasting.common.recipe.SealFocusRecipe +import at.petrak.hexcasting.common.recipe.SealSpellbookRecipe +import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper +import at.petrak.hexcasting.common.recipe.ingredient.VillagerIngredient +import at.petrak.hexcasting.datagen.IXplatConditionsBuilder +import at.petrak.hexcasting.datagen.IXplatIngredients +import at.petrak.hexcasting.datagen.recipe.builders.BrainsweepRecipeBuilder +import at.petrak.hexcasting.datagen.recipe.builders.CompatIngredientValue +import at.petrak.hexcasting.datagen.recipe.builders.CreateCrushingRecipeBuilder +import at.petrak.hexcasting.datagen.recipe.builders.FarmersDelightCuttingRecipeBuilder +import at.petrak.paucal.api.datagen.PaucalRecipeProvider +import net.minecraft.advancements.critereon.EntityPredicate +import net.minecraft.advancements.critereon.MinMaxBounds +import net.minecraft.core.Registry +import net.minecraft.data.DataGenerator +import net.minecraft.data.recipes.* +import net.minecraft.resources.ResourceLocation +import net.minecraft.sounds.SoundEvents +import net.minecraft.tags.ItemTags +import net.minecraft.world.item.DyeColor +import net.minecraft.world.item.DyeItem +import net.minecraft.world.item.Item +import net.minecraft.world.item.Items +import net.minecraft.world.item.crafting.Ingredient +import net.minecraft.world.item.crafting.SimpleRecipeSerializer +import net.minecraft.world.level.block.Blocks +import java.util.function.Consumer -import java.util.function.Consumer; -import java.util.function.Supplier; +class HexplatRecipes( + val generator: DataGenerator, + val ingredients: IXplatIngredients, + val conditions: (RecipeBuilder) -> IXplatConditionsBuilder +) : PaucalRecipeProvider(generator, HexAPI.MOD_ID) { + override fun makeRecipes(recipes: Consumer) { + specialRecipe(recipes, SealFocusRecipe.SERIALIZER) + specialRecipe(recipes, SealSpellbookRecipe.SERIALIZER) -public class HexplatRecipes extends PaucalRecipeProvider { - public DataGenerator generator; - public IXplatIngredients ingredients; - public Supplier createCrushing; + wandRecipe(recipes, HexItems.WAND_OAK, Items.OAK_PLANKS) + wandRecipe(recipes, HexItems.WAND_BIRCH, Items.BIRCH_PLANKS) + wandRecipe(recipes, HexItems.WAND_SPRUCE, Items.SPRUCE_PLANKS) + wandRecipe(recipes, HexItems.WAND_JUNGLE, Items.JUNGLE_PLANKS) + wandRecipe(recipes, HexItems.WAND_DARK_OAK, Items.DARK_OAK_PLANKS) + wandRecipe(recipes, HexItems.WAND_ACACIA, Items.ACACIA_PLANKS) + wandRecipe(recipes, HexItems.WAND_CRIMSON, Items.CRIMSON_PLANKS) + wandRecipe(recipes, HexItems.WAND_WARPED, Items.WARPED_PLANKS) + wandRecipe(recipes, HexItems.WAND_AKASHIC, HexBlocks.AKASHIC_PLANKS.asItem()) - public HexplatRecipes(DataGenerator pGenerator, IXplatIngredients ingredients, Supplier createCrushing) { - super(pGenerator, HexAPI.MOD_ID); - this.generator = pGenerator; - this.ingredients = ingredients; - this.createCrushing = createCrushing; - } - - protected void makeRecipes(Consumer recipes) { - specialRecipe(recipes, SealFocusRecipe.SERIALIZER); - specialRecipe(recipes, SealSpellbookRecipe.SERIALIZER); - - wandRecipe(recipes, HexItems.WAND_OAK, Items.OAK_PLANKS); - wandRecipe(recipes, HexItems.WAND_BIRCH, Items.BIRCH_PLANKS); - wandRecipe(recipes, HexItems.WAND_SPRUCE, Items.SPRUCE_PLANKS); - wandRecipe(recipes, HexItems.WAND_JUNGLE, Items.JUNGLE_PLANKS); - wandRecipe(recipes, HexItems.WAND_DARK_OAK, Items.DARK_OAK_PLANKS); - wandRecipe(recipes, HexItems.WAND_ACACIA, Items.ACACIA_PLANKS); - wandRecipe(recipes, HexItems.WAND_CRIMSON, Items.CRIMSON_PLANKS); - wandRecipe(recipes, HexItems.WAND_WARPED, Items.WARPED_PLANKS); - wandRecipe(recipes, HexItems.WAND_AKASHIC, HexBlocks.AKASHIC_PLANKS.asItem()); - - ringCornered(HexItems.FOCUS, 1, ingredients.glowstoneDust(), - ingredients.leather(), Ingredient.of(HexItems.CHARGED_AMETHYST)) + ringCornered(HexItems.FOCUS, 1, + ingredients.glowstoneDust(), + ingredients.leather(), + Ingredient.of(HexItems.CHARGED_AMETHYST)) .unlockedBy("has_item", hasItem(HexItemTags.WANDS)) - .save(recipes); + .save(recipes) ShapedRecipeBuilder.shaped(HexItems.SPELLBOOK) .define('N', ingredients.goldNugget()) @@ -77,17 +72,19 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("NFA") .pattern("NBA") .unlockedBy("has_focus", hasItem(HexItems.FOCUS)) - .unlockedBy("has_chorus", hasItem(Items.CHORUS_FRUIT)).save(recipes); + .unlockedBy("has_chorus", hasItem(Items.CHORUS_FRUIT)).save(recipes) - ringCornerless(HexItems.CYPHER, 1, + ringCornerless( + HexItems.CYPHER, 1, ingredients.copperIngot(), Ingredient.of(HexItems.AMETHYST_DUST)) - .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes) - ringCornerless(HexItems.TRINKET, 1, + ringCornerless( + HexItems.TRINKET, 1, ingredients.ironIngot(), Ingredient.of(Items.AMETHYST_SHARD)) - .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.ARTIFACT) .define('F', ingredients.goldIngot()) @@ -97,10 +94,10 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern(" F ") .pattern("FAF") .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes) ringCornerless(HexItems.SCRYING_LENS, 1, Items.GLASS, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.ABACUS) .define('S', Items.STICK) @@ -109,7 +106,7 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("WAW") .pattern("SAS") .pattern("WAW") - .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.WANDS)).save(recipes) // Why am I like this ShapedRecipeBuilder.shaped(HexItems.SUBMARINE_SANDWICH) @@ -120,35 +117,39 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern(" SA") .pattern(" C ") .pattern(" B ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) - for (var dye : DyeColor.values()) { - var item = HexItems.DYE_COLORIZERS.get(dye); + for (dye in DyeColor.values()) { + val item = HexItems.DYE_COLORIZERS[dye]!! ShapedRecipeBuilder.shaped(item) .define('D', HexItems.AMETHYST_DUST) .define('C', DyeItem.byColor(dye)) .pattern(" D ") .pattern("DCD") .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) } - gayRecipe(recipes, ItemPrideColorizer.Type.AGENDER, Items.GLASS); - gayRecipe(recipes, ItemPrideColorizer.Type.AROACE, Items.WHEAT_SEEDS); - gayRecipe(recipes, ItemPrideColorizer.Type.AROMANTIC, Items.ARROW); - gayRecipe(recipes, ItemPrideColorizer.Type.ASEXUAL, Items.BREAD); - gayRecipe(recipes, ItemPrideColorizer.Type.BISEXUAL, Items.WHEAT); - gayRecipe(recipes, ItemPrideColorizer.Type.DEMIBOY, Items.RAW_IRON); - gayRecipe(recipes, ItemPrideColorizer.Type.DEMIGIRL, Items.RAW_COPPER); - gayRecipe(recipes, ItemPrideColorizer.Type.GAY, Items.STONE_BRICK_WALL); - gayRecipe(recipes, ItemPrideColorizer.Type.GENDERFLUID, Items.WATER_BUCKET); - gayRecipe(recipes, ItemPrideColorizer.Type.GENDERQUEER, Items.GLASS_BOTTLE); - gayRecipe(recipes, ItemPrideColorizer.Type.INTERSEX, Items.AZALEA); - gayRecipe(recipes, ItemPrideColorizer.Type.LESBIAN, Items.HONEYCOMB); - gayRecipe(recipes, ItemPrideColorizer.Type.NONBINARY, Items.MOSS_BLOCK); - gayRecipe(recipes, ItemPrideColorizer.Type.PANSEXUAL, Items.CARROT); - gayRecipe(recipes, ItemPrideColorizer.Type.PLURAL, Items.REPEATER); - gayRecipe(recipes, ItemPrideColorizer.Type.TRANSGENDER, Items.EGG); + gayRecipe(recipes, ItemPrideColorizer.Type.AGENDER, Ingredient.of(Items.GLASS)) + gayRecipe(recipes, ItemPrideColorizer.Type.AROACE, Ingredient.of(Items.WHEAT_SEEDS)) + gayRecipe(recipes, ItemPrideColorizer.Type.AROMANTIC, Ingredient.of(Items.ARROW)) + gayRecipe(recipes, ItemPrideColorizer.Type.ASEXUAL, Ingredient.of(Items.BREAD)) + gayRecipe(recipes, ItemPrideColorizer.Type.BISEXUAL, Ingredient.of(Items.WHEAT)) + gayRecipe(recipes, ItemPrideColorizer.Type.DEMIBOY, Ingredient.of(Items.RAW_IRON)) + gayRecipe(recipes, ItemPrideColorizer.Type.DEMIGIRL, Ingredient.of(Items.RAW_COPPER)) + gayRecipe(recipes, ItemPrideColorizer.Type.GAY, Ingredient.of(Items.STONE_BRICK_WALL)) + gayRecipe(recipes, ItemPrideColorizer.Type.GENDERFLUID, Ingredient.of(Items.WATER_BUCKET)) + gayRecipe(recipes, ItemPrideColorizer.Type.GENDERQUEER, Ingredient.of(Items.GLASS_BOTTLE)) + gayRecipe(recipes, ItemPrideColorizer.Type.INTERSEX, Ingredient.of(Items.AZALEA)) + gayRecipe(recipes, ItemPrideColorizer.Type.LESBIAN, Ingredient.of(Items.HONEYCOMB)) + gayRecipe(recipes, ItemPrideColorizer.Type.NONBINARY, Ingredient.of(Items.MOSS_BLOCK)) + gayRecipe(recipes, ItemPrideColorizer.Type.PANSEXUAL, ingredients.whenModIngredient( + Ingredient.of(Items.CARROT), + "farmersdelight", + CompatIngredientValue.of("farmersdelight:skillet") + )) + gayRecipe(recipes, ItemPrideColorizer.Type.PLURAL, Ingredient.of(Items.REPEATER)) + gayRecipe(recipes, ItemPrideColorizer.Type.TRANSGENDER, Ingredient.of(Items.EGG)) ShapedRecipeBuilder.shaped(HexItems.UUID_COLORIZER) .define('B', Items.BOWL) @@ -157,35 +158,37 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern(" C ") .pattern(" D ") .pattern(" B ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SCROLL_SMOL) .define('P', Items.PAPER) .define('A', Items.AMETHYST_SHARD) .pattern(" A") .pattern("P ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + ShapedRecipeBuilder.shaped(HexItems.SCROLL_MEDIUM) .define('P', Items.PAPER) .define('A', Items.AMETHYST_SHARD) .pattern(" A") .pattern("PP ") .pattern("PP ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + ShapedRecipeBuilder.shaped(HexItems.SCROLL_LARGE) .define('P', Items.PAPER) .define('A', Items.AMETHYST_SHARD) .pattern("PPA") .pattern("PPP") .pattern("PPP") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SLATE, 6) .define('S', Items.DEEPSLATE) .define('A', HexItems.AMETHYST_DUST) .pattern(" A ") .pattern("SSS") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.JEWELER_HAMMER) .define('I', ingredients.ironIngot()) @@ -195,103 +198,120 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("IAN") .pattern(" S ") .pattern(" S ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.SLATE_BLOCK) .define('S', HexItems.SLATE) .pattern("S") .pattern("S") .unlockedBy("has_item", hasItem(HexItems.SLATE)) - .save(recipes, modLoc("slate_block_from_slates")); + .save(recipes, modLoc("slate_block_from_slates")) ringAll(HexBlocks.SLATE_BLOCK, 8, Blocks.DEEPSLATE, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItems.SLATE)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.SLATE)).save(recipes) packing(HexItems.AMETHYST_DUST, HexBlocks.AMETHYST_DUST_BLOCK.asItem(), "amethyst_dust", - false, recipes); + false, recipes) ringAll(HexBlocks.AMETHYST_TILES, 8, Blocks.AMETHYST_BLOCK, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) + SingleItemRecipeBuilder.stonecutting(Ingredient.of(Blocks.AMETHYST_BLOCK), HexBlocks.AMETHYST_TILES) .unlockedBy("has_item", hasItem(Blocks.AMETHYST_BLOCK)) - .save(recipes, modLoc("stonecutting/amethyst_tiles")); + .save(recipes, modLoc("stonecutting/amethyst_tiles")) ringAll(HexBlocks.SCROLL_PAPER, 8, Items.PAPER, Items.AMETHYST_SHARD) - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes); + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + ShapelessRecipeBuilder.shapeless(HexBlocks.ANCIENT_SCROLL_PAPER, 8) - .requires(ingredients.dyes().get(DyeColor.BROWN)) + .requires(ingredients.dyes()[DyeColor.BROWN]!!) .requires(HexBlocks.SCROLL_PAPER, 8) - .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes); + .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) + stack(HexBlocks.SCROLL_PAPER_LANTERN, 1, HexBlocks.SCROLL_PAPER, Items.TORCH) - .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes); + .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) + stack(HexBlocks.ANCIENT_SCROLL_PAPER_LANTERN, 1, HexBlocks.ANCIENT_SCROLL_PAPER, Items.TORCH) - .unlockedBy("has_item", hasItem(HexBlocks.ANCIENT_SCROLL_PAPER)).save(recipes); + .unlockedBy("has_item", hasItem(HexBlocks.ANCIENT_SCROLL_PAPER)).save(recipes) + ShapelessRecipeBuilder.shapeless(HexBlocks.ANCIENT_SCROLL_PAPER_LANTERN, 8) - .requires(ingredients.dyes().get(DyeColor.BROWN)) + .requires(ingredients.dyes()[DyeColor.BROWN]!!) .requires(HexBlocks.SCROLL_PAPER_LANTERN, 8) .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER_LANTERN)) - .save(recipes, modLoc("ageing_scroll_paper_lantern")); + .save(recipes, modLoc("ageing_scroll_paper_lantern")) - stack(HexBlocks.SCONCE, 4, Ingredient.of(HexItems.CHARGED_AMETHYST), + stack(HexBlocks.SCONCE, 4, + Ingredient.of(HexItems.CHARGED_AMETHYST), ingredients.copperIngot()) - .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)).save(recipes) ShapelessRecipeBuilder.shapeless(HexBlocks.AKASHIC_PLANKS, 4) .requires(HexItemTags.AKASHIC_LOGS) - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_LOGS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_LOGS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_WOOD, 3) .define('W', HexBlocks.AKASHIC_LOG) .pattern("WW") .pattern("WW") - .unlockedBy("has_item", hasItem(HexBlocks.AKASHIC_LOG)).save(recipes); + .unlockedBy("has_item", hasItem(HexBlocks.AKASHIC_LOG)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_WOOD_STRIPPED, 3) .define('W', HexBlocks.AKASHIC_LOG_STRIPPED) .pattern("WW") .pattern("WW") - .unlockedBy("has_item", hasItem(HexBlocks.AKASHIC_LOG_STRIPPED)).save(recipes); - ring(HexBlocks.AKASHIC_PANEL, 8, HexItemTags.AKASHIC_PLANKS, null) - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexBlocks.AKASHIC_LOG_STRIPPED)).save(recipes) + + ring(HexBlocks.AKASHIC_PANEL, 8, + HexItemTags.AKASHIC_PLANKS, null) + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_TILE, 6) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("WW ") .pattern("W W") .pattern(" WW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_DOOR, 3) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("WW") .pattern("WW") .pattern("WW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_TRAPDOOR, 2) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("WWW") .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_STAIRS, 4) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("W ") .pattern("WW ") .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_SLAB, 6) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_PRESSURE_PLATE, 1) .define('W', HexItemTags.AKASHIC_PLANKS) .pattern("WW") - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) + ShapelessRecipeBuilder.shapeless(HexBlocks.AKASHIC_BUTTON) .requires(HexItemTags.AKASHIC_PLANKS) - .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes); + .unlockedBy("has_item", hasItem(HexItemTags.AKASHIC_PLANKS)).save(recipes) - var enlightenment = new OvercastTrigger.Instance(EntityPredicate.Composite.ANY, - MinMaxBounds.Ints.ANY, - // add a little bit of slop here + val enlightenment = OvercastTrigger.Instance( + EntityPredicate.Composite.ANY, + MinMaxBounds.Ints.ANY, // add a little bit of slop here MinMaxBounds.Doubles.atLeast(0.8), - MinMaxBounds.Doubles.between(0.1, 2.05)); - + MinMaxBounds.Doubles.between(0.1, 2.05) + ) ShapedRecipeBuilder.shaped(HexBlocks.EMPTY_IMPETUS) .define('B', Items.IRON_BARS) .define('A', HexItems.CHARGED_AMETHYST) @@ -300,7 +320,7 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("PSS") .pattern("BAB") .pattern("SSP") - .unlockedBy("enlightenment", enlightenment).save(recipes); + .unlockedBy("enlightenment", enlightenment).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EMPTY_DIRECTRIX) .define('C', Items.COMPARATOR) @@ -310,16 +330,17 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("CSS") .pattern("OAO") .pattern("SSC") - .unlockedBy("enlightenment", enlightenment).save(recipes); + .unlockedBy("enlightenment", enlightenment).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_BOOKSHELF) .define('L', HexItemTags.AKASHIC_LOGS) .define('P', HexItemTags.AKASHIC_PLANKS) .define('C', Items.BOOK) - /*this is the*/.pattern("LPL") // and what i have for you today is + /*this is the*/ .pattern("LPL") // and what i have for you today is .pattern("CCC") .pattern("LPL") - .unlockedBy("enlightenment", enlightenment).save(recipes); + .unlockedBy("enlightenment", enlightenment).save(recipes) + ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_CONNECTOR) .define('L', HexItemTags.AKASHIC_LOGS) .define('P', HexItemTags.AKASHIC_PLANKS) @@ -327,98 +348,112 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern("LPL") .pattern("CCC") .pattern("LPL") - .unlockedBy("enlightenment", enlightenment).save(recipes); + .unlockedBy("enlightenment", enlightenment).save(recipes) - new BrainsweepRecipeBuilder(StateIngredientHelper.of(Blocks.AMETHYST_BLOCK), - new VillagerIngredient(null, null, 3), + BrainsweepRecipeBuilder(StateIngredientHelper.of(Blocks.AMETHYST_BLOCK), + VillagerIngredient(null, null, 3), Blocks.BUDDING_AMETHYST.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/budding_amethyst")); + .save(recipes, modLoc("brainsweep/budding_amethyst")) - new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - new VillagerIngredient(new ResourceLocation("toolsmith"), null, 2), + BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), + VillagerIngredient(ResourceLocation("toolsmith"), null, 2), HexBlocks.IMPETUS_RIGHTCLICK.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_rightclick")); - new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - new VillagerIngredient(new ResourceLocation("fletcher"), null, 2), + .save(recipes, modLoc("brainsweep/impetus_rightclick")) + + BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), + VillagerIngredient(ResourceLocation("fletcher"), null, 2), HexBlocks.IMPETUS_LOOK.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_look")); - new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - new VillagerIngredient(new ResourceLocation("cleric"), null, 2), + .save(recipes, modLoc("brainsweep/impetus_look")) + + BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), + VillagerIngredient(ResourceLocation("cleric"), null, 2), HexBlocks.IMPETUS_STOREDPLAYER.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_storedplayer")); + .save(recipes, modLoc("brainsweep/impetus_storedplayer")) - new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_DIRECTRIX), - new VillagerIngredient(new ResourceLocation("mason"), null, 1), + BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_DIRECTRIX), + VillagerIngredient(ResourceLocation("mason"), null, 1), HexBlocks.DIRECTRIX_REDSTONE.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/directrix_redstone")); + .save(recipes, modLoc("brainsweep/directrix_redstone")) - new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.AKASHIC_CONNECTOR), - new VillagerIngredient(new ResourceLocation("librarian"), null, 5), + BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.AKASHIC_CONNECTOR), + VillagerIngredient(ResourceLocation("librarian"), null, 5), HexBlocks.AKASHIC_RECORD.defaultBlockState()) .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/akashic_record")); + .save(recipes, modLoc("brainsweep/akashic_record")) // Create compat - - createCrushing.get() + CreateCrushingRecipeBuilder() .withInput(Blocks.AMETHYST_CLUSTER) .duration(150) .withOutput(Items.AMETHYST_SHARD, 7) .withOutput(HexItems.AMETHYST_DUST, 5) .withOutput(0.25f, HexItems.CHARGED_AMETHYST) - .save(recipes, new ResourceLocation("create", "crushing/amethyst_cluster")); + .withConditions() + .whenModLoaded("create") + .save(recipes, ResourceLocation("create", "crushing/amethyst_cluster")) - createCrushing.get() + CreateCrushingRecipeBuilder() .withInput(Blocks.AMETHYST_BLOCK) .duration(150) .withOutput(Items.AMETHYST_SHARD, 3) .withOutput(0.5f, HexItems.AMETHYST_DUST, 4) - .save(recipes, new ResourceLocation("create", "crushing/amethyst_block")); + .withConditions() + .whenModLoaded("create") + .save(recipes, ResourceLocation("create", "crushing/amethyst_block")) - createCrushing.get() + CreateCrushingRecipeBuilder() .withInput(Items.AMETHYST_SHARD) .duration(150) .withOutput(HexItems.AMETHYST_DUST, 4) .withOutput(0.5f, HexItems.AMETHYST_DUST) - .save(recipes, modLoc("compat/create/crushing/amethyst_shard")); + .withConditions() + .whenModLoaded("create") + .save(recipes, modLoc("compat/create/crushing/amethyst_shard")) // FD compat - - new FarmersDelightCuttingRecipeBuilder() + FarmersDelightCuttingRecipeBuilder() .withInput(HexBlocks.AKASHIC_LOG) .withTool(ingredients.axeStrip()) .withOutput(HexBlocks.AKASHIC_LOG_STRIPPED) .withOutput("farmersdelight:tree_bark") .withSound(SoundEvents.AXE_STRIP) - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_log")); + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_log")) - new FarmersDelightCuttingRecipeBuilder() + FarmersDelightCuttingRecipeBuilder() .withInput(HexBlocks.AKASHIC_WOOD) .withTool(ingredients.axeStrip()) .withOutput(HexBlocks.AKASHIC_WOOD_STRIPPED) .withOutput("farmersdelight:tree_bark") .withSound(SoundEvents.AXE_STRIP) - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_wood")); + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_wood")) - new FarmersDelightCuttingRecipeBuilder() + FarmersDelightCuttingRecipeBuilder() .withInput(HexBlocks.AKASHIC_TRAPDOOR) .withTool(ingredients.axeDig()) .withOutput(HexBlocks.AKASHIC_PLANKS) - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_trapdoor")); + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_trapdoor")) - new FarmersDelightCuttingRecipeBuilder() + FarmersDelightCuttingRecipeBuilder() .withInput(HexBlocks.AKASHIC_DOOR) .withTool(ingredients.axeDig()) .withOutput(HexBlocks.AKASHIC_PLANKS) - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_door")); + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_door")) } - private void wandRecipe(Consumer recipes, ItemWand wand, Item plank) { + private fun wandRecipe(recipes: Consumer, wand: ItemWand, plank: Item) { ShapedRecipeBuilder.shaped(wand) .define('W', plank) .define('S', Items.STICK) @@ -427,22 +462,25 @@ public class HexplatRecipes extends PaucalRecipeProvider { .pattern(" WS") .pattern("S ") .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)) - .save(recipes); + .save(recipes) } - private void gayRecipe(Consumer recipes, ItemPrideColorizer.Type type, Item material) { - var colorizer = HexItems.PRIDE_COLORIZERS.get(type); + private fun gayRecipe(recipes: Consumer, type: ItemPrideColorizer.Type, material: Ingredient) { + val colorizer = HexItems.PRIDE_COLORIZERS[type]!! ShapedRecipeBuilder.shaped(colorizer) .define('D', HexItems.AMETHYST_DUST) .define('C', material) .pattern(" D ") .pattern("DCD") .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes); + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)) + .save(recipes) } - protected void specialRecipe(Consumer consumer, SimpleRecipeSerializer serializer) { - var name = Registry.RECIPE_SERIALIZER.getKey(serializer); - SpecialRecipeBuilder.special(serializer).save(consumer, HexAPI.MOD_ID + ":dynamic/" + name.getPath()); + private fun specialRecipe(consumer: Consumer, serializer: SimpleRecipeSerializer<*>) { + val name = Registry.RECIPE_SERIALIZER.getKey(serializer) + SpecialRecipeBuilder.special(serializer).save(consumer, HexAPI.MOD_ID + ":dynamic/" + name!!.path) } + + private fun RecipeBuilder.withConditions(): IXplatConditionsBuilder = conditions(this) } diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CompatIngredientValue.java b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CompatIngredientValue.java new file mode 100644 index 00000000..4feffa64 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CompatIngredientValue.java @@ -0,0 +1,33 @@ +package at.petrak.hexcasting.datagen.recipe.builders; + +import com.google.gson.JsonObject; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Stream; + +public class CompatIngredientValue implements Ingredient.Value { + public final String item; + + public CompatIngredientValue(String name) { + this.item = name; + } + + public @NotNull Collection getItems() { + return Collections.emptyList(); + } + + public @NotNull JsonObject serialize() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("item", item); + return jsonObject; + } + + public static Ingredient of(String itemName) { + return new Ingredient(Stream.of(new CompatIngredientValue(itemName))); + } +} + diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CreateCrushingRecipeBuilder.java b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CreateCrushingRecipeBuilder.java index ecf933a7..95cf6be0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CreateCrushingRecipeBuilder.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/CreateCrushingRecipeBuilder.java @@ -24,7 +24,7 @@ import java.util.function.Consumer; // https://github.com/Creators-of-Create/Create/blob/82be76d8934af03b4e52cad6a9f74a4175ba7b05/src/main/java/com/simibubi/create/foundation/data/recipe/ProcessingRecipeGen.java // https://github.com/Creators-of-Create/Create/blob/82be76d8934af03b4e52cad6a9f74a4175ba7b05/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeBuilder.java // https://github.com/Creators-of-Create/Create/blob/82be76d8934af03b4e52cad6a9f74a4175ba7b05/src/main/java/com/simibubi/create/content/contraptions/processing/ProcessingRecipeSerializer.java -public abstract class CreateCrushingRecipeBuilder implements RecipeBuilder { +public class CreateCrushingRecipeBuilder implements RecipeBuilder { private String group = ""; private Ingredient input; private final List results = new ArrayList<>(); @@ -107,12 +107,6 @@ public abstract class CreateCrushingRecipeBuilder implements RecipeBuilder { consumer.accept(new CrushingRecipe(resourceLocation)); } - public abstract void serializeConditions(JsonObject object); - - public abstract CreateCrushingRecipeBuilder whenModLoaded(String modid); - - public abstract CreateCrushingRecipeBuilder whenModMissing(String modid); - public class CrushingRecipe implements FinishedRecipe { private final ResourceLocation id; @@ -143,8 +137,6 @@ public abstract class CreateCrushingRecipeBuilder implements RecipeBuilder { if (processingDuration > 0) { json.addProperty("processingTime", processingDuration); } - - serializeConditions(json); } @Override diff --git a/Common/src/main/resources/hexplat.accesswidener b/Common/src/main/resources/hexplat.accesswidener index 53c99887..478bd440 100644 --- a/Common/src/main/resources/hexplat.accesswidener +++ b/Common/src/main/resources/hexplat.accesswidener @@ -3,3 +3,5 @@ accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType accessible class net/minecraft/client/renderer/RenderType$CompositeState accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard; accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard +accessible class net/minecraft/world/item/crafting/Ingredient$Value +accessible method net/minecraft/world/item/crafting/Ingredient (Ljava/util/stream/Stream;)V diff --git a/Fabric/gradle.properties b/Fabric/gradle.properties index 82438c20..0b6172c3 100644 --- a/Fabric/gradle.properties +++ b/Fabric/gradle.properties @@ -4,7 +4,7 @@ fabricLoaderVersion=0.14.5 fiberVersion=0.23.0-2 cardinalComponentsVersion=4.1.4 -serializationHooksVersion=0.1.0+1.18.095e8a6 +serializationHooksVersion=0.3.22 reiVersion=8.0.442 emiVersion=0.1.0+1.18.2 diff --git a/Fabric/src/generated/resources/.cache/cache b/Fabric/src/generated/resources/.cache/cache index 2aafde8b..115eda47 100644 --- a/Fabric/src/generated/resources/.cache/cache +++ b/Fabric/src/generated/resources/.cache/cache @@ -1,6 +1,6 @@ 556d2e6068965e90c307a435b372ae761cd1c606 data/minecraft/tags/items/wooden_doors.json b596d96eebb4f7bad5930f4eebc589f292b59c98 data/minecraft/tags/items/planks.json -568ac8a13b7762b92cc274d74a7c729cc6e16687 data/hexcasting/recipes/pride_colorizer_pansexual.json +39ef3ab2effbae595b45400e7db7a8ad693e0d13 data/hexcasting/recipes/pride_colorizer_pansexual.json c521621c409275e219f72abf5c6089d60408e646 data/hexcasting/loot_tables/blocks/impetus_rightclick.json 023c32e8834eb313c4fa94a84a8f6390ee951ef0 data/hexcasting/advancements/recipes/hexcasting.creative_tab/empty_impetus.json bdf848284137f0116ddf4725b0dda6eaa0cef5fd data/hexcasting/loot_tables/blocks/akashic_wood_stripped.json @@ -55,14 +55,14 @@ f3c6b6917e504e1c3d5d8875f7cce6f311e791d2 data/minecraft/tags/blocks/logs_that_bu 2ad42dd4a4877a23cb7f45e8b75c9f53f58d12f5 data/hexcasting/recipes/wand_acacia.json b0b1c5fff194b92ff8c5d6468e177271fd910abd data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_red.json 9c619750b17ac95e339882ce6c097ba9a000cc82 data/hexcasting/advancements/recipes/hexcasting.creative_tab/pride_colorizer_pansexual.json -ad85e0162a7c68d431fd700700906ccbcadf91ce data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json +21041998b3f1de0b45c731295576fc4b2ec6905a data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json 2d79a41ba8697f9e1fa26b1bff48f33c824d3823 data/minecraft/tags/blocks/wooden_pressure_plates.json 8334a42636f045b4dc34c0fe5b3b3d3902aa4b7e data/hexcasting/recipes/scroll_small.json 584bd8806ef8df5f0e623ed727d6e54a61e60dea data/hexcasting/loot_tables/blocks/slate_block.json c11dc4388c18dadff5d93126eb0f7ae848d627b9 data/hexcasting/advancements/recipes/brainsweep/brainsweep/directrix_redstone.json 5f3e3813757d8300acad523d45ac7c4d85728399 data/minecraft/tags/items/buttons.json 4066f098ef104eadf6729bb372d9e643c598b477 data/hexcasting/advancements/recipes/hexcasting.creative_tab/akashic_wood_stripped.json -42a8f3ea310d25760b3374c7b7338f445d51a005 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json +ffe8e09c41222b5b909626436dbd7099e01ccc64 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json 310e2440f26f130c81d32d9fcd93a3384c2b1e72 data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_brown.json 5f3e3813757d8300acad523d45ac7c4d85728399 data/minecraft/tags/blocks/buttons.json 30950c6dd31102cf145f8f7d2979df0736a7ba1e data/hexcasting/advancements/recipes/hexcasting.creative_tab/wand_oak.json @@ -101,7 +101,7 @@ e5ae652aee1567ac2e626fa0f88f160993a6f9a5 data/hexcasting/advancements/recipes/he 7c0107192c0e24ff9f23ab0f59834b6081ca5b33 data/hexcasting/advancements/recipes/hexcasting.creative_tab/wand_crimson.json 1266b263056dd15c862bff27b05a119c4bbc89ee data/hexcasting/advancements/recipes/hexcasting.creative_tab/akashic_door.json a92e5560c774bb81cd9f38bd9378af8695cac622 data/hexcasting/recipes/akashic_stairs.json -59e0c3893a64d84b5fde52291067b3601c43ffc9 data/create/recipes/crushing/amethyst_cluster.json +8a9b22b846968e9120c3a63a9f18694aa5703cab data/create/recipes/crushing/amethyst_cluster.json f3a33396e071f3afd61eadab2aabdb9acf2ae775 data/hexcasting/recipes/slate.json f7bbc60f547a02378ddb1f23395add4822725fed data/hexcasting/recipes/wand_oak.json 0529b25d154715d6b1c030d87e59e6f9d41d91d6 data/hexcasting/recipes/focus.json @@ -160,7 +160,7 @@ a84bf48a188d7b250db5c971a6d9b63d82279ba3 data/hexcasting/recipes/akashic_wood.js 3f9756b2c5137b285c4faa88ab43c4996b6b2bb6 data/hexcasting/recipes/ancient_scroll_paper_lantern.json c375ba3f7105d6f57ef982f6f4e9326ad88a947d data/hexcasting/loot_tables/blocks/ancient_scroll_paper_lantern.json b596d96eebb4f7bad5930f4eebc589f292b59c98 data/hexcasting/tags/blocks/akashic_planks.json -e60c478db2f8552e8c1e9ee5d361658dd8eafaa4 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json +4d8667ebdad42e7220009f69a1f6f465a73b2a9a data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json a27a2514fd3acb6cf0a4f2a6b176ca4c2a3ee064 data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_cyan.json 1d19457c9843d97d2ed59199d9077940d9e5e46a data/hexcasting/recipes/akashic_button.json b596d96eebb4f7bad5930f4eebc589f292b59c98 data/minecraft/tags/blocks/planks.json @@ -223,7 +223,7 @@ c25784941d6416744fb2ca2d43a3203e5c3e7c8a data/minecraft/tags/items/leaves.json ef016ca292fa4edc7496b64e6f2931f4e7d90636 data/hexcasting/recipes/amethyst_dust_packing.json 35a9b4beac7c6eddb990464eaeaebec2a9ab9951 data/hexcasting/loot_tables/inject/scroll_loot_many.json 949f05968c562d5e4d35630ce8e3189a2060dee7 data/hexcasting/advancements/recipes/hexcasting.creative_tab/pride_colorizer_intersex.json -cfda8a0bb9051f9f876cd5b9afcd8a7f6a1e4290 data/create/recipes/crushing/amethyst_block.json +d189977c9c5d2048ba1ba40ee49d182af2836330 data/create/recipes/crushing/amethyst_block.json 02dcee696b1e162f20dbfcf02bdb9e2144a64a27 data/hexcasting/recipes/pride_colorizer_gay.json 7c08784f2de139be380b5299f8ea8b8c78126ed8 data/minecraft/tags/blocks/mineable/axe.json 32e3d36398fa63e017ed6c46e7e19d7ba041c3d9 data/hexcasting/recipes/pride_colorizer_bisexual.json @@ -240,7 +240,7 @@ db8a00478e1c4b0f9b143b5946d1ba25e489591d data/hexcasting/recipes/dynamic/seal_fo 076dd8bb2ce1508293384fa93fa138a369d10751 data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_green.json 3147422bed290cb47ea3763dbdc6f0e96eed5c2a data/hexcasting/loot_tables/inject/scroll_loot_few.json aab3082b3303f358cc265fb10bc9bbe08c96eef0 data/hexcasting/recipes/trinket.json -c15a0780a2cd9c92dad948479049ab8495a33635 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json +77afbbd8280136eb11d1aab1219d6057063e8f75 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json c3aed1dbaa46e084711a116d1bb4522df9a7405a data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_light_blue.json 3a376402af89128dc37adaa0a72b6de66d58309d data/hexcasting/recipes/dynamic/seal_spellbook.json 2ec90cd941acad6eabfb38d21466ef8e9b9bf2c1 data/hexcasting/recipes/wand_jungle.json @@ -253,7 +253,7 @@ f3c6b6917e504e1c3d5d8875f7cce6f311e791d2 data/hexcasting/tags/items/akashic_logs c64f5e56ca18eb68d2e58827920ca0e3ae4617ca data/hexcasting/recipes/dye_colorizer_blue.json 5f3e3813757d8300acad523d45ac7c4d85728399 data/minecraft/tags/blocks/wooden_buttons.json e125117befadda0785e370969a8e04eff070d057 data/hexcasting/loot_tables/blocks/amethyst_sconce.json -37461a314331d79691c48cd13b6540260021cba4 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json +b8825decc5079bbe72c8a189e36bda2efefaf26f data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json 4da41a82a17f58c9342944f214e745696c1d8ed7 data/hexcasting/loot_tables/blocks/impetus_storedplayer.json 67d4c536be3762833a4af33cd7cdfc68eb4ad629 data/hexcasting/advancements/recipes/hexcasting.creative_tab/wand_dark_oak.json 22ad2496732633bb5539a1fa761051d7add48055 data/hexcasting/advancements/recipes/hexcasting.creative_tab/slate.json diff --git a/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_block.json b/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_block.json index d162220c..4d640f5c 100644 --- a/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_block.json +++ b/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_block.json @@ -16,5 +16,13 @@ "chance": 0.5 } ], - "processingTime": 150 + "processingTime": 150, + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "create" + ] + } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json b/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json index f326bf4a..dcabb9ec 100644 --- a/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json +++ b/Fabric/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json @@ -19,5 +19,13 @@ "chance": 0.25 } ], - "processingTime": 150 + "processingTime": 150, + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "create" + ] + } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json index ffa35cc3..b9ecda86 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json @@ -15,5 +15,13 @@ "chance": 0.5 } ], - "processingTime": 150 + "processingTime": 150, + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "create" + ] + } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json index 4f66808a..701b7c6f 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json @@ -13,5 +13,13 @@ { "item": "hexcasting:akashic_planks" } + ], + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json index cae5afbf..1e13e009 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json @@ -17,5 +17,13 @@ "item": "farmersdelight:tree_bark" } ], - "sound": "minecraft:item.axe.strip" + "sound": "minecraft:item.axe.strip", + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json index 96dd858d..90fc66af 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json @@ -13,5 +13,13 @@ { "item": "hexcasting:akashic_planks" } + ], + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json index 6e293322..95286f7e 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json @@ -17,5 +17,13 @@ "item": "farmersdelight:tree_bark" } ], - "sound": "minecraft:item.axe.strip" + "sound": "minecraft:item.axe.strip", + "fabric:load_conditions": [ + { + "condition": "fabric:all_mods_loaded", + "values": [ + "farmersdelight" + ] + } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json b/Fabric/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json index ec18619d..cfac72f2 100644 --- a/Fabric/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json +++ b/Fabric/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json @@ -10,7 +10,14 @@ "item": "hexcasting:amethyst_dust" }, "C": { - "item": "minecraft:carrot" + "type": "hexcasting:mod_conditional", + "default": { + "item": "minecraft:carrot" + }, + "modid": "farmersdelight", + "if_loaded": { + "item": "farmersdelight:skillet" + } } }, "result": { diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt index bdf941af..2517a6df 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt @@ -1,6 +1,5 @@ package at.petrak.hexcasting.fabric -import at.petrak.hexcasting.api.HexAPI.modLoc import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers import at.petrak.hexcasting.api.mod.HexStatistics import at.petrak.hexcasting.common.blocks.behavior.HexComposting @@ -17,6 +16,7 @@ import at.petrak.hexcasting.common.misc.PlayerPositionRecorder import at.petrak.hexcasting.common.recipe.HexRecipeSerializers import at.petrak.hexcasting.fabric.event.VillagerConversionCallback import at.petrak.hexcasting.fabric.network.FabricPacketHandler +import at.petrak.hexcasting.fabric.recipe.FabricModConditionalIngredient import at.petrak.hexcasting.fabric.recipe.FabricUnsealedIngredient import at.petrak.hexcasting.fabric.storage.FabricImpetusStorage import at.petrak.hexcasting.interop.HexInterop @@ -90,7 +90,8 @@ object FabricHexInitializer : ModInitializer { HexBlocks.registerBlockItems(bind(Registry.ITEM)) HexBlockEntities.registerTiles(bind(Registry.BLOCK_ENTITY_TYPE)) HexItems.registerItems(bind(Registry.ITEM)) - Registry.register(IngredientDeserializer.REGISTRY, modLoc("unsealed"), FabricUnsealedIngredient.Deserializer.INSTANCE) + Registry.register(IngredientDeserializer.REGISTRY, FabricUnsealedIngredient.ID, FabricUnsealedIngredient.Deserializer.INSTANCE) + Registry.register(IngredientDeserializer.REGISTRY, FabricModConditionalIngredient.ID, FabricModConditionalIngredient.Deserializer.INSTANCE) HexEntities.registerEntities(bind(Registry.ENTITY_TYPE)) diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricConditionsBuilder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricConditionsBuilder.java new file mode 100644 index 00000000..f196de36 --- /dev/null +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricConditionsBuilder.java @@ -0,0 +1,96 @@ +package at.petrak.hexcasting.fabric.datagen; + +import at.petrak.hexcasting.datagen.IXplatConditionsBuilder; +import com.google.gson.JsonObject; +import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider; +import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions; +import net.fabricmc.fabric.impl.datagen.FabricDataGenHelper; +import net.minecraft.advancements.CriterionTriggerInstance; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeBuilder; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class HexFabricConditionsBuilder implements IXplatConditionsBuilder { + private final List conditions = new ArrayList<>(); + private final RecipeBuilder parent; + + public HexFabricConditionsBuilder(RecipeBuilder parent) { + this.parent = parent; + } + + @Override + public IXplatConditionsBuilder whenModLoaded(String modid) { + conditions.add(DefaultResourceConditions.allModsLoaded(modid)); + return this; + } + + @Override + public IXplatConditionsBuilder whenModMissing(String modid) { + conditions.add(DefaultResourceConditions.not(DefaultResourceConditions.allModsLoaded(modid))); + return this; + } + + @Override + public RecipeBuilder unlockedBy(@NotNull String string, @NotNull CriterionTriggerInstance criterionTriggerInstance) { + return parent.unlockedBy(string, criterionTriggerInstance); + } + + @Override + public RecipeBuilder group(@Nullable String string) { + return parent.group(string); + } + + @Override + public Item getResult() { + return parent.getResult(); + } + + @Override + @SuppressWarnings("UnstableApiUsage") + public void save(@NotNull Consumer consumer, @NotNull ResourceLocation resourceLocation) { + Consumer withConditions = json -> { + FabricDataGenHelper.addConditions(json, conditions.toArray(new ConditionJsonProvider[0])); + + consumer.accept(new FinishedRecipe() { + @Override + public void serializeRecipeData(@NotNull JsonObject jsonObject) { + json.serializeRecipeData(jsonObject); + ConditionJsonProvider[] conditions = FabricDataGenHelper.consumeConditions(json); + ConditionJsonProvider.write(jsonObject, conditions); + } + + @Override + public ResourceLocation getId() { + return json.getId(); + } + + @Override + public RecipeSerializer getType() { + return json.getType(); + } + + @Nullable + @Override + public JsonObject serializeAdvancement() { + return json.serializeAdvancement(); + } + + @Nullable + @Override + public ResourceLocation getAdvancementId() { + return json.getAdvancementId(); + } + }); + }; + + parent.save(withConditions, resourceLocation); + } +} diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricDataGenerators.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricDataGenerators.java index 343f34b6..3dcd23de 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricDataGenerators.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/HexFabricDataGenerators.java @@ -7,7 +7,7 @@ import at.petrak.hexcasting.datagen.HexLootTables; import at.petrak.hexcasting.datagen.IXplatIngredients; import at.petrak.hexcasting.datagen.recipe.HexplatRecipes; import at.petrak.hexcasting.datagen.recipe.builders.ToolIngredient; -import at.petrak.hexcasting.fabric.datagen.builders.FabricCreateCrushingRecipeBuilder; +import at.petrak.hexcasting.fabric.recipe.FabricModConditionalIngredient; import at.petrak.hexcasting.xplat.IXplatAbstractions; import com.google.gson.JsonObject; import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; @@ -26,7 +26,7 @@ public class HexFabricDataGenerators implements DataGeneratorEntrypoint { public void onInitializeDataGenerator(FabricDataGenerator gen) { HexAPI.LOGGER.info("Starting Fabric-specific datagen"); - gen.addProvider(new HexplatRecipes(gen, INGREDIENTS, FabricCreateCrushingRecipeBuilder::new)); + gen.addProvider(new HexplatRecipes(gen, INGREDIENTS, HexFabricConditionsBuilder::new)); var xtags = IXplatAbstractions.INSTANCE.tags(); var blockTagProvider = new HexBlockTagProvider(gen, xtags); @@ -116,6 +116,11 @@ public class HexFabricDataGenerators implements DataGeneratorEntrypoint { )); } + @Override + public Ingredient whenModIngredient(Ingredient defaultIngredient, String modid, Ingredient modIngredient) { + return FabricModConditionalIngredient.of(defaultIngredient, modid, modIngredient); + } + private final ToolIngredient AXE_INGREDIENT = () -> { JsonObject object = new JsonObject(); object.addProperty("type", "farmersdelight:tool"); diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/builders/FabricCreateCrushingRecipeBuilder.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/builders/FabricCreateCrushingRecipeBuilder.java deleted file mode 100644 index 5d0f8467..00000000 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/datagen/builders/FabricCreateCrushingRecipeBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -package at.petrak.hexcasting.fabric.datagen.builders; - -import at.petrak.hexcasting.datagen.recipe.builders.CreateCrushingRecipeBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import net.fabricmc.fabric.api.resource.conditions.v1.ConditionJsonProvider; -import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions; -import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions; - -import java.util.ArrayList; -import java.util.List; - -public class FabricCreateCrushingRecipeBuilder extends CreateCrushingRecipeBuilder { - private final List conditions = new ArrayList<>(); - - public FabricCreateCrushingRecipeBuilder whenModLoaded(String modid) { - return withCondition(DefaultResourceConditions.anyModLoaded(modid)); - } - - public FabricCreateCrushingRecipeBuilder whenModMissing(String modid) { - return withCondition(DefaultResourceConditions.not(DefaultResourceConditions.anyModLoaded(modid))); - } - - public FabricCreateCrushingRecipeBuilder withCondition(ConditionJsonProvider condition) { - conditions.add(condition); - return this; - } - - @Override - public void serializeConditions(JsonObject object) { - if (!conditions.isEmpty()) { - JsonArray conds = new JsonArray(); - conditions.forEach(c -> conds.add(c.toJson())); - object.add(ResourceConditions.CONDITIONS_KEY, conds); - } - } -} diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricModConditionalIngredient.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricModConditionalIngredient.java new file mode 100644 index 00000000..a063eb0d --- /dev/null +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricModConditionalIngredient.java @@ -0,0 +1,105 @@ +package at.petrak.hexcasting.fabric.recipe; + +import at.petrak.hexcasting.xplat.IXplatAbstractions; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.tropheusj.serialization_hooks.ingredient.BaseCustomIngredient; +import io.github.tropheusj.serialization_hooks.ingredient.IngredientDeserializer; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.Objects; + +import static at.petrak.hexcasting.api.HexAPI.modLoc; + +public class FabricModConditionalIngredient extends BaseCustomIngredient { + public static final ResourceLocation ID = modLoc("mod_conditional"); + + private final Ingredient main; + private final String modid; + private final Ingredient ifModLoaded; + + private final Ingredient toUse; + + protected FabricModConditionalIngredient(Ingredient main, String modid, Ingredient ifModLoaded) { + super(IXplatAbstractions.INSTANCE.isModPresent(modid) ? Arrays.stream(ifModLoaded.values) : Arrays.stream(main.values)); + this.main = main; + this.modid = modid; + this.ifModLoaded = ifModLoaded; + + this.toUse = IXplatAbstractions.INSTANCE.isModPresent(modid) ? ifModLoaded : main; + } + + /** + * Creates a new ingredient matching the given stack + */ + public static FabricModConditionalIngredient of(Ingredient main, String modid, Ingredient ifModLoaded) { + return new FabricModConditionalIngredient(main, modid, ifModLoaded); + } + + @Override + public boolean test(@Nullable ItemStack input) { + return toUse.test(input); + } + + @Override + public @NotNull JsonElement toJson() { + JsonObject json = new JsonObject(); + json.addProperty("type", Objects.toString(ID)); + json.add("default", main.toJson()); + json.addProperty("modid", modid); + json.add("if_loaded", ifModLoaded.toJson()); + return json; + } + + @Override + public IngredientDeserializer getDeserializer() { + return Deserializer.INSTANCE; + } + + public static Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { + return Ingredient.fromNetwork(friendlyByteBuf); // Just send the actual ingredient + } + + public static Ingredient fromJson(JsonElement element) { + if (element == null || element.isJsonNull() || !element.isJsonObject()) + return null; + + JsonObject object = element.getAsJsonObject(); + + if (object.has("type") && object.getAsJsonPrimitive("type").getAsString().equals(ID.toString())) { + if (object.has("modid") && IXplatAbstractions.INSTANCE.isModPresent(object.getAsJsonPrimitive("modid").getAsString())) + return Ingredient.fromJson(object.get("if_loaded")); + else + return Ingredient.fromJson(object.get("default")); + } + + return null; + } + + @Override + public void toNetwork(@NotNull FriendlyByteBuf friendlyByteBuf) { + friendlyByteBuf.writeResourceLocation(ID); + toUse.toNetwork(friendlyByteBuf); + } + + public static class Deserializer implements IngredientDeserializer { + public static final Deserializer INSTANCE = new Deserializer(); + + @Override + public Ingredient fromNetwork(FriendlyByteBuf buffer) { + return FabricModConditionalIngredient.fromNetwork(buffer); + } + + @Nullable + @Override + public Ingredient fromJson(JsonObject object) { + return FabricModConditionalIngredient.fromJson(object); + } + } +} diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java index 21704daa..2a55e0f0 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/recipe/FabricUnsealedIngredient.java @@ -26,7 +26,7 @@ import java.util.Objects; import static at.petrak.hexcasting.api.HexAPI.modLoc; public class FabricUnsealedIngredient extends BaseCustomIngredient { - private static final ResourceLocation ID = modLoc("unsealed"); + public static final ResourceLocation ID = modLoc("unsealed"); private final ItemStack stack; @@ -94,6 +94,7 @@ public class FabricUnsealedIngredient extends BaseCustomIngredient { @Override public void toNetwork(FriendlyByteBuf friendlyByteBuf) { + friendlyByteBuf.writeResourceLocation(ID); friendlyByteBuf.writeItem(stack); } diff --git a/Fabric/src/main/resources/fabricasting.accesswidener b/Fabric/src/main/resources/fabricasting.accesswidener index 19d32353..004416f8 100644 --- a/Fabric/src/main/resources/fabricasting.accesswidener +++ b/Fabric/src/main/resources/fabricasting.accesswidener @@ -3,6 +3,7 @@ extendable class net/minecraft/world/item/crafting/Ingredient accessible class net/minecraft/world/item/crafting/Ingredient$ItemValue accessible class net/minecraft/world/item/crafting/Ingredient$TagValue accessible class net/minecraft/world/item/crafting/Ingredient$Value +accessible field net/minecraft/world/item/crafting/Ingredient values [Lnet/minecraft/world/item/crafting/Ingredient$Value; accessible method net/minecraft/world/item/crafting/Ingredient$ItemValue (Lnet/minecraft/world/item/ItemStack;)V accessible method net/minecraft/world/item/crafting/Ingredient$TagValue (Lnet/minecraft/tags/TagKey;)V accessible method net/minecraft/world/item/crafting/Ingredient (Ljava/util/stream/Stream;)V diff --git a/Forge/src/generated/resources/.cache/cache b/Forge/src/generated/resources/.cache/cache index 17ee2a24..0df6f7df 100644 --- a/Forge/src/generated/resources/.cache/cache +++ b/Forge/src/generated/resources/.cache/cache @@ -1,5 +1,5 @@ -cfda8a0bb9051f9f876cd5b9afcd8a7f6a1e4290 data/create/recipes/crushing/amethyst_block.json -59e0c3893a64d84b5fde52291067b3601c43ffc9 data/create/recipes/crushing/amethyst_cluster.json +b7afb34e0e611ff567a25e46bcd8943fe7d352c0 data/create/recipes/crushing/amethyst_block.json +6c91ac492b7fa487095894963568113c5e0203a7 data/create/recipes/crushing/amethyst_cluster.json 4d4caaea035ae4ee878843dd2455042b299b4e5e data/forge/tags/items/dusts/amethyst.json 05e86742a71afd740f47639be62f93bc9898fcde data/forge/tags/items/gems.json cf0ad981bebbb79414d955fb40fbf537fe88b89d data/hexcasting/advancements/recipes/brainsweep/brainsweep/akashic_record.json @@ -156,11 +156,11 @@ d7f85ce9d46aacc7ec89dc7aa0f88a331ccfbae7 data/hexcasting/recipes/brainsweep/akas 5861845c3cd84021c7c19ac4f5b3bcc8e1bd3916 data/hexcasting/recipes/brainsweep/impetus_look.json ab5d271371323d93ff6eed18179ee4f7fd8c939c data/hexcasting/recipes/brainsweep/impetus_rightclick.json d5c6f9a31a8310ec440fc8c14da8988f0d166586 data/hexcasting/recipes/brainsweep/impetus_storedplayer.json -ad85e0162a7c68d431fd700700906ccbcadf91ce data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json -27665eed65acfdb692027afe52588b30cec085ea data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json -1ed27f68186cb70984eeeae13365fc3c3149ebc3 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json -4c842bb202b181cc861544a08a4ad53f399aaa30 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json -e339675f24dd528d429a1386666d69fc8f23c426 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json +0d0067c9639ec00db605a24a9e098a43ada049c8 data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json +6bb3d3093004c4a5671702768d6f4553a35f2fe0 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json +3975a2c4ababae89dcd087028be1fadb3831e882 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json +b60ebb134e23687de8d909f02b629559b904135b data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json +4df73af5a14a33fbbc087090e25fd33702c392a5 data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json bc140b6c5d999b4bc5d12c302297f56bde3b161c data/hexcasting/recipes/cypher.json 8c22db477365a800ce1e715aeaad896550467047 data/hexcasting/recipes/dye_colorizer_black.json c64f5e56ca18eb68d2e58827920ca0e3ae4617ca data/hexcasting/recipes/dye_colorizer_blue.json @@ -198,7 +198,7 @@ d3ad9a9e92dd125f872d9671930d4e57f24894ed data/hexcasting/recipes/pride_colorizer ac128e72adda8fea0ad63d7e6e18dd9399f53d65 data/hexcasting/recipes/pride_colorizer_intersex.json 1d558c1b63dd3c3e129261f53db5fd6748b59051 data/hexcasting/recipes/pride_colorizer_lesbian.json cd7e618d7c08ffff67683852f799362fb8aaebaf data/hexcasting/recipes/pride_colorizer_nonbinary.json -568ac8a13b7762b92cc274d74a7c729cc6e16687 data/hexcasting/recipes/pride_colorizer_pansexual.json +39ef3ab2effbae595b45400e7db7a8ad693e0d13 data/hexcasting/recipes/pride_colorizer_pansexual.json b2d8fb979a3fbe47404da349318f38ab45bac760 data/hexcasting/recipes/pride_colorizer_plural.json f50c71bbbbf7d77665c9008fcdd9be0d571ce48e data/hexcasting/recipes/pride_colorizer_transgender.json 49508c455626eeca18c957edc0cde016e823f7b0 data/hexcasting/recipes/scroll.json diff --git a/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_block.json b/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_block.json index d162220c..7fde51bf 100644 --- a/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_block.json +++ b/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_block.json @@ -1,20 +1,33 @@ { - "type": "create:crushing", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "minecraft:amethyst_block" + "conditions": [ + { + "modid": "create", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:amethyst_block" + } + ], + "results": [ + { + "item": "minecraft:amethyst_shard", + "count": 3 + }, + { + "item": "hexcasting:amethyst_dust", + "count": 4, + "chance": 0.5 + } + ], + "processingTime": 150 + } } - ], - "results": [ - { - "item": "minecraft:amethyst_shard", - "count": 3 - }, - { - "item": "hexcasting:amethyst_dust", - "count": 4, - "chance": 0.5 - } - ], - "processingTime": 150 + ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json b/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json index f326bf4a..9f41e187 100644 --- a/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json +++ b/Forge/src/generated/resources/data/create/recipes/crushing/amethyst_cluster.json @@ -1,23 +1,36 @@ { - "type": "create:crushing", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "minecraft:amethyst_cluster" + "conditions": [ + { + "modid": "create", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:amethyst_cluster" + } + ], + "results": [ + { + "item": "minecraft:amethyst_shard", + "count": 7 + }, + { + "item": "hexcasting:amethyst_dust", + "count": 5 + }, + { + "item": "hexcasting:charged_amethyst", + "chance": 0.25 + } + ], + "processingTime": 150 + } } - ], - "results": [ - { - "item": "minecraft:amethyst_shard", - "count": 7 - }, - { - "item": "hexcasting:amethyst_dust", - "count": 5 - }, - { - "item": "hexcasting:charged_amethyst", - "chance": 0.25 - } - ], - "processingTime": 150 + ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json b/Forge/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json index ffa35cc3..028cefb8 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/compat/create/crushing/amethyst_shard.json @@ -1,19 +1,32 @@ { - "type": "create:crushing", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "minecraft:amethyst_shard" + "conditions": [ + { + "modid": "create", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "create:crushing", + "ingredients": [ + { + "item": "minecraft:amethyst_shard" + } + ], + "results": [ + { + "item": "hexcasting:amethyst_dust", + "count": 4 + }, + { + "item": "hexcasting:amethyst_dust", + "chance": 0.5 + } + ], + "processingTime": 150 + } } - ], - "results": [ - { - "item": "hexcasting:amethyst_dust", - "count": 4 - }, - { - "item": "hexcasting:amethyst_dust", - "chance": 0.5 - } - ], - "processingTime": 150 + ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json index 296c6338..034ea1d8 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_door.json @@ -1,17 +1,30 @@ { - "type": "farmersdelight:cutting", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "hexcasting:akashic_door" - } - ], - "tool": { - "type": "farmersdelight:tool_action", - "action": "axe_dig" - }, - "result": [ - { - "item": "hexcasting:akashic_planks" + "conditions": [ + { + "modid": "farmersdelight", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "farmersdelight:cutting", + "ingredients": [ + { + "item": "hexcasting:akashic_door" + } + ], + "tool": { + "type": "farmersdelight:tool_action", + "action": "axe_dig" + }, + "result": [ + { + "item": "hexcasting:akashic_planks" + } + ] + } } ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json index eb1a75d3..35d3172e 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_log.json @@ -1,21 +1,34 @@ { - "type": "farmersdelight:cutting", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "hexcasting:akashic_log" + "conditions": [ + { + "modid": "farmersdelight", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "farmersdelight:cutting", + "ingredients": [ + { + "item": "hexcasting:akashic_log" + } + ], + "tool": { + "type": "farmersdelight:tool_action", + "action": "axe_strip" + }, + "result": [ + { + "item": "hexcasting:akashic_log_stripped" + }, + { + "item": "farmersdelight:tree_bark" + } + ], + "sound": "minecraft:item.axe.strip" + } } - ], - "tool": { - "type": "farmersdelight:tool_action", - "action": "axe_strip" - }, - "result": [ - { - "item": "hexcasting:akashic_log_stripped" - }, - { - "item": "farmersdelight:tree_bark" - } - ], - "sound": "minecraft:item.axe.strip" + ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json index 86da1e84..ff10f76c 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_trapdoor.json @@ -1,17 +1,30 @@ { - "type": "farmersdelight:cutting", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "hexcasting:akashic_trapdoor" - } - ], - "tool": { - "type": "farmersdelight:tool_action", - "action": "axe_dig" - }, - "result": [ - { - "item": "hexcasting:akashic_planks" + "conditions": [ + { + "modid": "farmersdelight", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "farmersdelight:cutting", + "ingredients": [ + { + "item": "hexcasting:akashic_trapdoor" + } + ], + "tool": { + "type": "farmersdelight:tool_action", + "action": "axe_dig" + }, + "result": [ + { + "item": "hexcasting:akashic_planks" + } + ] + } } ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json index ce7beb5c..af981c0e 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/compat/farmersdelight/cutting/akashic_wood.json @@ -1,21 +1,34 @@ { - "type": "farmersdelight:cutting", - "ingredients": [ + "type": "forge:conditional", + "recipes": [ { - "item": "hexcasting:akashic_wood" + "conditions": [ + { + "modid": "farmersdelight", + "type": "forge:mod_loaded" + } + ], + "recipe": { + "type": "farmersdelight:cutting", + "ingredients": [ + { + "item": "hexcasting:akashic_wood" + } + ], + "tool": { + "type": "farmersdelight:tool_action", + "action": "axe_strip" + }, + "result": [ + { + "item": "hexcasting:akashic_wood_stripped" + }, + { + "item": "farmersdelight:tree_bark" + } + ], + "sound": "minecraft:item.axe.strip" + } } - ], - "tool": { - "type": "farmersdelight:tool_action", - "action": "axe_strip" - }, - "result": [ - { - "item": "hexcasting:akashic_wood_stripped" - }, - { - "item": "farmersdelight:tree_bark" - } - ], - "sound": "minecraft:item.axe.strip" + ] } \ No newline at end of file diff --git a/Forge/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json b/Forge/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json index ec18619d..cfac72f2 100644 --- a/Forge/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json +++ b/Forge/src/generated/resources/data/hexcasting/recipes/pride_colorizer_pansexual.json @@ -10,7 +10,14 @@ "item": "hexcasting:amethyst_dust" }, "C": { - "item": "minecraft:carrot" + "type": "hexcasting:mod_conditional", + "default": { + "item": "minecraft:carrot" + }, + "modid": "farmersdelight", + "if_loaded": { + "item": "farmersdelight:skillet" + } } }, "result": { diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java index ef1fc043..648999dd 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java @@ -25,6 +25,7 @@ import at.petrak.hexcasting.forge.interop.curios.CuriosApiInterop; import at.petrak.hexcasting.forge.interop.curios.CuriosRenderers; import at.petrak.hexcasting.forge.network.ForgePacketHandler; import at.petrak.hexcasting.forge.network.MsgBrainsweepAck; +import at.petrak.hexcasting.forge.recipe.ForgeModConditionalIngredient; import at.petrak.hexcasting.forge.recipe.ForgeUnsealedIngredient; import at.petrak.hexcasting.interop.HexInterop; import at.petrak.hexcasting.xplat.IXplatAbstractions; @@ -71,8 +72,6 @@ import thedarkcolour.kotlinforforge.KotlinModLoadingContext; import java.util.function.BiConsumer; import java.util.function.Consumer; -import static at.petrak.hexcasting.api.HexAPI.modLoc; - @Mod(HexAPI.MOD_ID) public class ForgeHexInitializer { public ForgeHexInitializer() { @@ -144,7 +143,8 @@ public class ForgeHexInitializer { // We have to do these at some point when the registries are still open modBus.addGenericListener(Item.class, (RegistryEvent evt) -> { HexRecipeSerializers.registerTypes(); - CraftingHelper.register(modLoc("unsealed"), ForgeUnsealedIngredient.Serializer.INSTANCE); + CraftingHelper.register(ForgeUnsealedIngredient.ID, ForgeUnsealedIngredient.Serializer.INSTANCE); + CraftingHelper.register(ForgeModConditionalIngredient.ID, ForgeModConditionalIngredient.Serializer.INSTANCE); HexStatistics.register(); HexLootFunctions.registerSerializers((lift, id) -> Registry.register(Registry.LOOT_FUNCTION_TYPE, id, lift)); diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeConditionsBuilder.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeConditionsBuilder.java new file mode 100644 index 00000000..8521b99d --- /dev/null +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeConditionsBuilder.java @@ -0,0 +1,63 @@ +package at.petrak.hexcasting.forge.datagen; + +import at.petrak.hexcasting.datagen.IXplatConditionsBuilder; +import net.minecraft.advancements.CriterionTriggerInstance; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.RecipeBuilder; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraftforge.common.crafting.ConditionalRecipe; +import net.minecraftforge.common.crafting.conditions.ICondition; +import net.minecraftforge.common.crafting.conditions.IConditionBuilder; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class HexForgeConditionsBuilder implements IXplatConditionsBuilder, IConditionBuilder { + private final List conditions = new ArrayList<>(); + private final RecipeBuilder parent; + + public HexForgeConditionsBuilder(RecipeBuilder parent) { + this.parent = parent; + } + + @Override + public IXplatConditionsBuilder whenModLoaded(String modid) { + conditions.add(modLoaded(modid)); + return this; + } + + @Override + public IXplatConditionsBuilder whenModMissing(String modid) { + conditions.add(not(modLoaded(modid))); + return this; + } + + @Override + public @NotNull RecipeBuilder unlockedBy(@NotNull String string, @NotNull CriterionTriggerInstance criterionTriggerInstance) { + return parent.unlockedBy(string, criterionTriggerInstance); + } + + @Override + public @NotNull RecipeBuilder group(@Nullable String string) { + return parent.group(string); + } + + @Override + public @NotNull Item getResult() { + return parent.getResult(); + } + + @Override + public void save(@NotNull Consumer consumer, @NotNull ResourceLocation resourceLocation) { + var conditionalBuilder = ConditionalRecipe.builder(); + for (ICondition condition : conditions) { + conditionalBuilder.addCondition(condition); + } + conditionalBuilder.addRecipe(recipeConsumer -> parent.save(recipeConsumer, resourceLocation)) + .build(consumer, resourceLocation); + } +} diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeDataGenerators.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeDataGenerators.java index b0de4f11..50b5fa10 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeDataGenerators.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/HexForgeDataGenerators.java @@ -4,9 +4,9 @@ import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.datagen.*; import at.petrak.hexcasting.datagen.recipe.HexplatRecipes; import at.petrak.hexcasting.datagen.recipe.builders.ToolIngredient; -import at.petrak.hexcasting.forge.datagen.builders.ForgeCreateCrushingRecipeBuilder; import at.petrak.hexcasting.forge.datagen.xplat.HexBlockStatesAndModels; import at.petrak.hexcasting.forge.datagen.xplat.HexItemModels; +import at.petrak.hexcasting.forge.recipe.ForgeModConditionalIngredient; import at.petrak.hexcasting.xplat.IXplatAbstractions; import at.petrak.paucal.api.forge.datagen.PaucalForgeDatagenWrappers; import com.google.gson.JsonObject; @@ -58,7 +58,7 @@ public class HexForgeDataGenerators { ExistingFileHelper efh = ev.getExistingFileHelper(); if (ev.includeServer()) { gen.addProvider(new HexLootTables(gen)); - gen.addProvider(new HexplatRecipes(gen, INGREDIENTS, ForgeCreateCrushingRecipeBuilder::new)); + gen.addProvider(new HexplatRecipes(gen, INGREDIENTS, HexForgeConditionsBuilder::new)); var xtags = IXplatAbstractions.INSTANCE.tags(); var blockTagProvider = PaucalForgeDatagenWrappers.addEFHToTagProvider( @@ -70,7 +70,7 @@ public class HexForgeDataGenerators { } } - private static IXplatIngredients INGREDIENTS = new IXplatIngredients() { + private static final IXplatIngredients INGREDIENTS = new IXplatIngredients() { @Override public Ingredient glowstoneDust() { return Ingredient.of(Tags.Items.DUSTS_GLOWSTONE); @@ -123,6 +123,11 @@ public class HexForgeDataGenerators { )); } + @Override + public Ingredient whenModIngredient(Ingredient defaultIngredient, String modid, Ingredient modIngredient) { + return ForgeModConditionalIngredient.of(defaultIngredient, modid, modIngredient); + } + @Override public ToolIngredient axeStrip() { return () -> { diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/builders/ForgeCreateCrushingRecipeBuilder.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/builders/ForgeCreateCrushingRecipeBuilder.java deleted file mode 100644 index 57fbf30e..00000000 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/builders/ForgeCreateCrushingRecipeBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -package at.petrak.hexcasting.forge.datagen.builders; - -import at.petrak.hexcasting.datagen.recipe.builders.CreateCrushingRecipeBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.crafting.conditions.ICondition; -import net.minecraftforge.common.crafting.conditions.ModLoadedCondition; -import net.minecraftforge.common.crafting.conditions.NotCondition; - -import java.util.ArrayList; -import java.util.List; - -public class ForgeCreateCrushingRecipeBuilder extends CreateCrushingRecipeBuilder { - private final List conditions = new ArrayList<>(); - - @Override - public ForgeCreateCrushingRecipeBuilder whenModLoaded(String modid) { - return withCondition(new ModLoadedCondition(modid)); - } - - @Override - public ForgeCreateCrushingRecipeBuilder whenModMissing(String modid) { - return withCondition(new NotCondition(new ModLoadedCondition(modid))); - } - - public ForgeCreateCrushingRecipeBuilder withCondition(ICondition condition) { - conditions.add(condition); - return this; - } - - @Override - public void serializeConditions(JsonObject object) { - if (!conditions.isEmpty()) { - JsonArray conds = new JsonArray(); - conditions.forEach(c -> conds.add(CraftingHelper.serialize(c))); - object.add("conditions", conds); - } - } -} diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeModConditionalIngredient.java b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeModConditionalIngredient.java new file mode 100644 index 00000000..ebd81652 --- /dev/null +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeModConditionalIngredient.java @@ -0,0 +1,105 @@ +package at.petrak.hexcasting.forge.recipe; + +import at.petrak.hexcasting.xplat.IXplatAbstractions; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.common.crafting.AbstractIngredient; +import net.minecraftforge.common.crafting.IIngredientSerializer; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.Objects; + +import static at.petrak.hexcasting.api.HexAPI.modLoc; + +public class ForgeModConditionalIngredient extends AbstractIngredient { + public static final ResourceLocation ID = modLoc("mod_conditional"); + + private final Ingredient main; + private final String modid; + private final Ingredient ifModLoaded; + + private final Ingredient toUse; + + protected ForgeModConditionalIngredient(Ingredient main, String modid, Ingredient ifModLoaded) { + super(IXplatAbstractions.INSTANCE.isModPresent(modid) ? Arrays.stream(ifModLoaded.values) : Arrays.stream(main.values)); + this.main = main; + this.modid = modid; + this.ifModLoaded = ifModLoaded; + + this.toUse = IXplatAbstractions.INSTANCE.isModPresent(modid) ? ifModLoaded : main; + } + + /** + * Creates a new ingredient matching the given stack + */ + public static ForgeModConditionalIngredient of(Ingredient main, String modid, Ingredient ifModLoaded) { + return new ForgeModConditionalIngredient(main, modid, ifModLoaded); + } + + @Override + public boolean test(@Nullable ItemStack input) { + return toUse.test(input); + } + + @Override + public boolean isSimple() { + return toUse.isSimple(); + } + + @Override + public @NotNull JsonElement toJson() { + JsonObject json = new JsonObject(); + json.addProperty("type", Objects.toString(ID)); + json.add("default", main.toJson()); + json.addProperty("modid", modid); + json.add("if_loaded", ifModLoaded.toJson()); + return json; + } + + @Override + public @NotNull IIngredientSerializer getSerializer() { + return Serializer.INSTANCE; + } + + public static @NotNull Ingredient fromNetwork(FriendlyByteBuf friendlyByteBuf) { + return Ingredient.fromNetwork(friendlyByteBuf); // Just send the actual ingredient + } + + public static Ingredient fromJson(JsonObject object) { + if (object.has("type") && object.getAsJsonPrimitive("type").getAsString().equals(ID.toString())) { + if (object.has("modid") && IXplatAbstractions.INSTANCE.isModPresent(object.getAsJsonPrimitive("modid").getAsString())) + return Ingredient.fromJson(object.get("if_loaded")); + else + return Ingredient.fromJson(object.get("default")); + } + + return Ingredient.of(); + } + + public static class Serializer implements IIngredientSerializer { + public static final Serializer INSTANCE = new Serializer(); + + @Override + public @NotNull Ingredient parse(@NotNull FriendlyByteBuf buffer) { + return fromNetwork(buffer); + } + + @Override + public @NotNull Ingredient parse(@NotNull JsonObject json) { + return fromJson(json); + } + + @Override + public void write(@NotNull FriendlyByteBuf buffer, @NotNull Ingredient ingredient) { + if (ingredient instanceof ForgeModConditionalIngredient conditionalIngredient) + conditionalIngredient.toUse.toNetwork(buffer); + // It shouldn't be possible to not be a ForgeModConditionalIngredient here + } + } +} diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java index ec83826d..e8bf7587 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/recipe/ForgeUnsealedIngredient.java @@ -10,6 +10,7 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.common.crafting.AbstractIngredient; @@ -22,7 +23,11 @@ import javax.annotation.Nullable; import java.util.Arrays; import java.util.Objects; +import static at.petrak.hexcasting.api.HexAPI.modLoc; + public class ForgeUnsealedIngredient extends AbstractIngredient { + public static final ResourceLocation ID = modLoc("unsealed"); + private final ItemStack stack; protected ForgeUnsealedIngredient(ItemStack stack) { diff --git a/Forge/src/main/resources/META-INF/accesstransformer.cfg b/Forge/src/main/resources/META-INF/accesstransformer.cfg index 523d6dd0..0004e92f 100644 --- a/Forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/Forge/src/main/resources/META-INF/accesstransformer.cfg @@ -1,2 +1,4 @@ public net.minecraft.client.renderer.RenderType$CompositeRenderType public net.minecraft.client.renderer.RenderType$CompositeState f_110576_ # textureState +public net.minecraft.world.item.crafting.Ingredient (Ljava/util/stream/Stream;)V +public net.minecraft.world.item.crafting.Ingredient f_43902_ # values