From be15c6eddc46aede4e7ccb4dd8ccd3d161d4d785 Mon Sep 17 00:00:00 2001 From: XFactHD Date: Thu, 25 Jan 2024 19:59:37 +0100 Subject: [PATCH] Add back vanilla RecipeProvider constructor, deprecate added constructor and lookup provider field --- patches/net/minecraft/data/Main.java.patch | 27 ------------------- .../data/recipes/RecipeProvider.java.patch | 23 +++++++--------- .../packs/BundleRecipeProvider.java.patch | 13 --------- ...pdateOneTwentyOneRecipeProvider.java.patch | 13 --------- .../packs/VanillaRecipeProvider.java.patch | 13 --------- .../neoforge/common/NeoForgeMod.java | 2 +- .../data/internal/NeoForgeRecipeProvider.java | 5 ++-- .../debug/attachment/AttachmentTests.java | 2 +- .../debug/crafting/IngredientTests.java | 4 +-- .../neoforge/oldtest/DataGeneratorTest.java | 6 ++--- 10 files changed, 18 insertions(+), 90 deletions(-) delete mode 100644 patches/net/minecraft/data/recipes/packs/BundleRecipeProvider.java.patch delete mode 100644 patches/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java.patch delete mode 100644 patches/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java.patch diff --git a/patches/net/minecraft/data/Main.java.patch b/patches/net/minecraft/data/Main.java.patch index f1b022cb415..4b87d8da939 100644 --- a/patches/net/minecraft/data/Main.java.patch +++ b/patches/net/minecraft/data/Main.java.patch @@ -44,30 +44,3 @@ } else { optionparser.printHelpOn(System.out); } -@@ -132,7 +_,7 @@ - datagenerator$packgenerator2.addProvider(bindRegistries(RegistriesDatapackGenerator::new, completablefuture2)); - datagenerator$packgenerator2.addProvider(bindRegistries(VanillaAdvancementProvider::create, completablefuture2)); - datagenerator$packgenerator2.addProvider(VanillaLootTableProvider::create); -- datagenerator$packgenerator2.addProvider(VanillaRecipeProvider::new); -+ datagenerator$packgenerator2.addProvider(bindRegistries(VanillaRecipeProvider::new, completablefuture2)); - TagsProvider tagsprovider3 = datagenerator$packgenerator2.addProvider(bindRegistries(VanillaBlockTagsProvider::new, completablefuture2)); - TagsProvider tagsprovider = datagenerator$packgenerator2.addProvider( - p_274753_ -> new VanillaItemTagsProvider(p_274753_, completablefuture2, tagsprovider3.contentsGetter()) -@@ -158,7 +_,7 @@ - datagenerator$packgenerator2.addProvider(bindRegistries(CommandsReport::new, completablefuture2)); - datagenerator$packgenerator2.addProvider(RegistryDumpReport::new); - datagenerator$packgenerator2 = datagenerator.getBuiltinDatapack(p_236683_, "bundle"); -- datagenerator$packgenerator2.addProvider(BundleRecipeProvider::new); -+ datagenerator$packgenerator2.addProvider(bindRegistries(BundleRecipeProvider::new, completablefuture2)); - datagenerator$packgenerator2.addProvider( - p_253392_ -> PackMetadataGenerator.forFeaturePack( - p_253392_, Component.translatable("dataPack.bundle.description"), FeatureFlagSet.of(FeatureFlags.BUNDLE) -@@ -176,7 +_,7 @@ - CompletableFuture completablefuture = completablefuture3.thenApply(RegistrySetBuilder.PatchedRegistries::full); - CompletableFuture completablefuture1 = completablefuture3.thenApply(RegistrySetBuilder.PatchedRegistries::patches); - DataGenerator.PackGenerator datagenerator$packgenerator3 = datagenerator.getBuiltinDatapack(p_236683_, "update_1_21"); -- datagenerator$packgenerator3.addProvider(UpdateOneTwentyOneRecipeProvider::new); -+ datagenerator$packgenerator3.addProvider(bindRegistries(UpdateOneTwentyOneRecipeProvider::new, completablefuture2)); - TagsProvider tagsprovider2 = datagenerator$packgenerator3.addProvider( - p_307133_ -> new UpdateOneTwentyOneBlockTagsProvider(p_307133_, completablefuture1, tagsprovider3.contentsGetter()) - ); diff --git a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch index b01513e80b6..9a46a9c896c 100644 --- a/patches/net/minecraft/data/recipes/RecipeProvider.java.patch +++ b/patches/net/minecraft/data/recipes/RecipeProvider.java.patch @@ -1,18 +1,21 @@ --- a/net/minecraft/data/recipes/RecipeProvider.java +++ b/net/minecraft/data/recipes/RecipeProvider.java -@@ -46,6 +_,7 @@ +@@ -46,6 +_,8 @@ public abstract class RecipeProvider implements DataProvider { protected final PackOutput.PathProvider recipePathProvider; protected final PackOutput.PathProvider advancementPathProvider; ++ @Deprecated(forRemoval = true, since = "1.20.4") // TODO: remove in 1.20.5 + protected final CompletableFuture lookupProvider; private static final Map> SHAPE_BUILDERS = ImmutableMap.>builder( ) -@@ -66,27 +_,29 @@ - .put(BlockFamily.Variant.WALL, (p_248024_, p_248025_) -> wallBuilder(RecipeCategory.DECORATIONS, p_248024_, Ingredient.of(p_248025_))) +@@ -67,8 +_,13 @@ .build(); -- public RecipeProvider(PackOutput p_248933_) { + public RecipeProvider(PackOutput p_248933_) { ++ this(p_248933_, CompletableFuture.completedFuture(net.minecraft.core.RegistryAccess.EMPTY)); ++ } ++ @Deprecated(forRemoval = true, since = "1.20.4") // TODO: remove in 1.20.5 + public RecipeProvider(PackOutput p_248933_, CompletableFuture lookupProvider) { this.recipePathProvider = p_248933_.createPathProvider(PackOutput.Target.DATA_PACK, "recipes"); this.advancementPathProvider = p_248933_.createPathProvider(PackOutput.Target.DATA_PACK, "advancements"); @@ -20,10 +23,7 @@ } @Override - public CompletableFuture run(final CachedOutput p_254020_) { -+ return this.lookupProvider.thenCompose(provider -> { - final Set set = Sets.newHashSet(); - final List> list = new ArrayList<>(); +@@ -78,15 +_,15 @@ this.buildRecipes( new RecipeOutput() { @Override @@ -42,12 +42,7 @@ ) ); } -@@ -99,16 +_,20 @@ - } - } - ); -- return CompletableFuture.allOf(list.toArray(p_253414_ -> new CompletableFuture[p_253414_])); -+ return CompletableFuture.allOf(list.toArray(p_253414_ -> new CompletableFuture[p_253414_])); }); +@@ -103,12 +_,16 @@ } protected CompletableFuture buildAdvancement(CachedOutput p_253674_, AdvancementHolder p_301116_) { diff --git a/patches/net/minecraft/data/recipes/packs/BundleRecipeProvider.java.patch b/patches/net/minecraft/data/recipes/packs/BundleRecipeProvider.java.patch deleted file mode 100644 index 9cdf7d2595e..00000000000 --- a/patches/net/minecraft/data/recipes/packs/BundleRecipeProvider.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/data/recipes/packs/BundleRecipeProvider.java -+++ b/net/minecraft/data/recipes/packs/BundleRecipeProvider.java -@@ -8,8 +_,8 @@ - import net.minecraft.world.item.Items; - - public class BundleRecipeProvider extends RecipeProvider { -- public BundleRecipeProvider(PackOutput p_248813_) { -- super(p_248813_); -+ public BundleRecipeProvider(PackOutput p_248813_, java.util.concurrent.CompletableFuture lookupProvider) { -+ super(p_248813_, lookupProvider); - } - - @Override diff --git a/patches/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java.patch b/patches/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java.patch deleted file mode 100644 index ce3b22c8e06..00000000000 --- a/patches/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java -+++ b/net/minecraft/data/recipes/packs/UpdateOneTwentyOneRecipeProvider.java -@@ -11,8 +_,8 @@ - import net.minecraft.world.level.block.Blocks; - - public class UpdateOneTwentyOneRecipeProvider extends RecipeProvider { -- public UpdateOneTwentyOneRecipeProvider(PackOutput p_307326_) { -- super(p_307326_); -+ public UpdateOneTwentyOneRecipeProvider(PackOutput p_307326_, java.util.concurrent.CompletableFuture lookupProvider) { -+ super(p_307326_, lookupProvider); - } - - @Override diff --git a/patches/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java.patch b/patches/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java.patch deleted file mode 100644 index 33683f67311..00000000000 --- a/patches/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java -+++ b/net/minecraft/data/recipes/packs/VanillaRecipeProvider.java -@@ -61,8 +_,8 @@ - public static final ImmutableList REDSTONE_SMELTABLES = ImmutableList.of(Items.REDSTONE_ORE, Items.DEEPSLATE_REDSTONE_ORE); - public static final ImmutableList EMERALD_SMELTABLES = ImmutableList.of(Items.EMERALD_ORE, Items.DEEPSLATE_EMERALD_ORE); - -- public VanillaRecipeProvider(PackOutput p_250820_) { -- super(p_250820_); -+ public VanillaRecipeProvider(PackOutput p_250820_, CompletableFuture lookupProvider) { -+ super(p_250820_, lookupProvider); - } - - @Override diff --git a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java index 7ec1c385d7b..dac2c6a05ea 100644 --- a/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java +++ b/src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java @@ -639,7 +639,7 @@ public void gatherData(GatherDataEvent event) { gen.addProvider(event.includeServer(), new NeoForgeItemTagsProvider(packOutput, lookupProvider, blockTags.contentsGetter(), existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeEntityTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeFluidTagsProvider(packOutput, lookupProvider, existingFileHelper)); - gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput, lookupProvider)); + gen.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput)); gen.addProvider(event.includeServer(), new NeoForgeLootTableProvider(packOutput)); gen.addProvider(event.includeServer(), new NeoForgeBiomeTagsProvider(packOutput, lookupProvider, existingFileHelper)); gen.addProvider(event.includeServer(), new NeoForgeDamageTypeTagsProvider(packOutput, lookupProvider, existingFileHelper)); diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java index b4970563f13..6b067f1563c 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeRecipeProvider.java @@ -14,7 +14,6 @@ import java.util.concurrent.CompletableFuture; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementHolder; -import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.data.CachedOutput; import net.minecraft.data.PackOutput; @@ -44,8 +43,8 @@ public final class NeoForgeRecipeProvider extends VanillaRecipeProvider { private final Map> replacements = new HashMap<>(); private final Set excludes = new HashSet<>(); - public NeoForgeRecipeProvider(PackOutput packOutput, CompletableFuture lookupProvider) { - super(packOutput, lookupProvider); + public NeoForgeRecipeProvider(PackOutput packOutput) { + super(packOutput); } private void exclude(ItemLike item) { diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/attachment/AttachmentTests.java b/tests/src/main/java/net/neoforged/neoforge/debug/attachment/AttachmentTests.java index 59d349e7f60..351a73b992f 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/attachment/AttachmentTests.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/attachment/AttachmentTests.java @@ -187,7 +187,7 @@ static void itemAttachmentRecipeOutput(final DynamicTest test, final Registratio var shapedId = new ResourceLocation(reg.modId(), "test_shaped"); var blastingId = new ResourceLocation(reg.modId(), "test_blasting"); - reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput(), event.getLookupProvider()) { + reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput()) { @Override protected void buildRecipes(RecipeOutput recipeOutput) { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, outputStack.get()) diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/crafting/IngredientTests.java b/tests/src/main/java/net/neoforged/neoforge/debug/crafting/IngredientTests.java index 5704fc86915..295912972d3 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/crafting/IngredientTests.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/crafting/IngredientTests.java @@ -35,7 +35,7 @@ public class IngredientTests { @EmptyTemplate @TestHolder(description = "Tests if partial NBT ingredients match the correct stacks") static void partialNBTIngredient(final DynamicTest test, final RegistrationHelper reg) { - reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput(), event.getLookupProvider()) { + reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput()) { @Override protected void buildRecipes(RecipeOutput output) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, Items.ALLIUM) @@ -81,7 +81,7 @@ protected void buildRecipes(RecipeOutput output) { @EmptyTemplate @TestHolder(description = "Tests if strict NBT ingredients match the correct stacks") static void strictNBTIngredient(final DynamicTest test, final RegistrationHelper reg) { - reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput(), event.getLookupProvider()) { + reg.addProvider(event -> new RecipeProvider(event.getGenerator().getPackOutput()) { @Override protected void buildRecipes(RecipeOutput output) { ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Items.ACACIA_BOAT) diff --git a/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java b/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java index 0453143be4e..008323b3c33 100644 --- a/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java @@ -179,7 +179,7 @@ public static void gatherData(GatherDataEvent event) { gen.addProvider(event.includeClient(), new SoundDefinitions(packOutput, event.getExistingFileHelper())); gen.addProvider(event.includeClient(), new ParticleDescriptions(packOutput, event.getExistingFileHelper())); - gen.addProvider(event.includeServer(), new Recipes(packOutput, event.getLookupProvider())); + gen.addProvider(event.includeServer(), new Recipes(packOutput)); gen.addProvider(event.includeServer(), new Tags(packOutput, lookupProvider, event.getExistingFileHelper())); gen.addProvider(event.includeServer(), new AdvancementProvider(packOutput, lookupProvider, event.getExistingFileHelper(), List.of(new Advancements()))); gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(packOutput, lookupProvider, BUILDER, Set.of(MODID))); @@ -196,8 +196,8 @@ public static void levelStem(BootstapContext context) { } public static class Recipes extends RecipeProvider implements IConditionBuilder { - public Recipes(PackOutput gen, CompletableFuture lookupProvider) { - super(gen, lookupProvider); + public Recipes(PackOutput gen) { + super(gen); } @Override