Skip to content

Commit

Permalink
Add back vanilla RecipeProvider constructor, deprecate added construc…
Browse files Browse the repository at this point in the history
…tor and lookup provider field
  • Loading branch information
XFactHD committed Jan 25, 2024
1 parent 1c41643 commit be15c6e
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 90 deletions.
27 changes: 0 additions & 27 deletions patches/net/minecraft/data/Main.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> tagsprovider3 = datagenerator$packgenerator2.addProvider(bindRegistries(VanillaBlockTagsProvider::new, completablefuture2));
TagsProvider<Item> 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<HolderLookup.Provider> completablefuture = completablefuture3.thenApply(RegistrySetBuilder.PatchedRegistries::full);
CompletableFuture<HolderLookup.Provider> 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<Block> tagsprovider2 = datagenerator$packgenerator3.addProvider(
p_307133_ -> new UpdateOneTwentyOneBlockTagsProvider(p_307133_, completablefuture1, tagsprovider3.contentsGetter())
);
23 changes: 9 additions & 14 deletions patches/net/minecraft/data/recipes/RecipeProvider.java.patch
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
--- 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<net.minecraft.core.HolderLookup.Provider> lookupProvider;
private static final Map<BlockFamily.Variant, BiFunction<ItemLike, ItemLike, RecipeBuilder>> SHAPE_BUILDERS = ImmutableMap.<BlockFamily.Variant, BiFunction<ItemLike, ItemLike, RecipeBuilder>>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<net.minecraft.core.HolderLookup.Provider> lookupProvider) {
this.recipePathProvider = p_248933_.createPathProvider(PackOutput.Target.DATA_PACK, "recipes");
this.advancementPathProvider = p_248933_.createPathProvider(PackOutput.Target.DATA_PACK, "advancements");
+ this.lookupProvider = lookupProvider;
}

@Override
public CompletableFuture<?> run(final CachedOutput p_254020_) {
+ return this.lookupProvider.thenCompose(provider -> {
final Set<ResourceLocation> set = Sets.newHashSet();
final List<CompletableFuture<?>> list = new ArrayList<>();
@@ -78,15 +_,15 @@
this.buildRecipes(
new RecipeOutput() {
@Override
Expand All @@ -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_) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,8 +43,8 @@ public final class NeoForgeRecipeProvider extends VanillaRecipeProvider {
private final Map<Item, TagKey<Item>> replacements = new HashMap<>();
private final Set<ResourceLocation> excludes = new HashSet<>();

public NeoForgeRecipeProvider(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(packOutput, lookupProvider);
public NeoForgeRecipeProvider(PackOutput packOutput) {
super(packOutput);
}

private void exclude(ItemLike item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand All @@ -196,8 +196,8 @@ public static void levelStem(BootstapContext<LevelStem> context) {
}

public static class Recipes extends RecipeProvider implements IConditionBuilder {
public Recipes(PackOutput gen, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(gen, lookupProvider);
public Recipes(PackOutput gen) {
super(gen);
}

@Override
Expand Down

0 comments on commit be15c6e

Please sign in to comment.