Skip to content

Commit

Permalink
[1.21.4] Tear out ExistingFileHelper (#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder authored Dec 28, 2024
1 parent 069ab04 commit 821e47f
Show file tree
Hide file tree
Showing 48 changed files with 259 additions and 689 deletions.
8 changes: 3 additions & 5 deletions patches/net/minecraft/client/data/Main.java.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
--- a/net/minecraft/client/data/Main.java
+++ b/net/minecraft/client/data/Main.java
@@ -30,16 +_,33 @@
@@ -30,16 +_,31 @@
OptionSpec<Void> optionspec1 = optionparser.accepts("client", "Include client generators");
OptionSpec<Void> optionspec2 = optionparser.accepts("all", "Include all generators");
OptionSpec<String> optionspec3 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
+ OptionSpec<String> existing = optionparser.accepts("existing", "Existing resource packs that generated resources can reference").withRequiredArg();
+ OptionSpec<String> existingMod = optionparser.accepts("existing-mod", "Existing mods that generated resources can reference the resource packs of").withRequiredArg();
+ OptionSpec<java.io.File> gameDir = optionparser.accepts("gameDir").withRequiredArg().ofType(java.io.File.class).defaultsTo(new java.io.File(".")).required(); //Need by modlauncher, so lets just eat it
+ optionparser.accepts("gameDir").withRequiredArg().ofType(java.io.File.class).defaultsTo(new java.io.File(".")).required(); //Need by modlauncher, so lets just eat it
+ OptionSpec<String> mod = optionparser.accepts("mod", "A modid to dump").withRequiredArg().withValuesSeparatedBy(",");
+ OptionSpec<Void> flat = optionparser.accepts("flat", "Do not append modid prefix to output directory when generating for multiple mods");
+ OptionSpec<String> assetIndex = optionparser.accepts("assetIndex").withRequiredArg();
Expand All @@ -21,7 +20,6 @@
- ClientBootstrap.bootstrap();
- DataGenerator datagenerator = new DataGenerator(path, SharedConstants.getCurrentVersion(), true);
+ java.util.Collection<Path> existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).toList();
+ java.util.Set<String> existingMods = new java.util.HashSet<>(optionset.valuesOf(existingMod));
+ java.util.Set<String> mods = new java.util.HashSet<>(optionset.valuesOf(mod));
+ boolean isFlat = mods.isEmpty() || optionset.has(flat);
+ boolean validate = optionset.has(validateSpec);
Expand All @@ -30,7 +28,7 @@
addClientProviders(datagenerator, flag1);
- datagenerator.run();
+ }
+ net.neoforged.neoforge.data.loading.DatagenModLoader.begin(mods, path, java.util.List.of(), existingPacks, existingMods, false, false, validate, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir), () -> {
+ net.neoforged.neoforge.data.loading.DatagenModLoader.begin(mods, path, java.util.List.of(), existingPacks, false, false, validate, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir), () -> {
+ ClientBootstrap.bootstrap();
+ net.neoforged.neoforge.client.ClientHooks.registerSpriteSourceTypes();
+ net.neoforged.neoforge.client.entity.animation.json.AnimationTypeManager.init();
Expand Down
8 changes: 3 additions & 5 deletions patches/net/minecraft/data/Main.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/data/Main.java
+++ b/net/minecraft/data/Main.java
@@ -73,21 +_,34 @@
@@ -73,21 +_,32 @@
OptionSpec<Void> optionspec1 = optionparser.accepts("server", "Include server generators");
OptionSpec<Void> optionspec2 = optionparser.accepts("dev", "Include development tools");
OptionSpec<Void> optionspec3 = optionparser.accepts("reports", "Include data reports");
Expand All @@ -10,7 +10,6 @@
OptionSpec<String> optionspec5 = optionparser.accepts("output", "Output folder").withRequiredArg().defaultsTo("generated");
OptionSpec<String> optionspec6 = optionparser.accepts("input", "Input folder").withRequiredArg();
+ OptionSpec<String> existing = optionparser.accepts("existing", "Existing resource packs that generated resources can reference").withRequiredArg();
+ OptionSpec<String> existingMod = optionparser.accepts("existing-mod", "Existing mods that generated resources can reference the resource packs of").withRequiredArg();
+ OptionSpec<java.io.File> gameDir = optionparser.accepts("gameDir").withRequiredArg().ofType(java.io.File.class).defaultsTo(new java.io.File(".")).required(); //Need by modlauncher, so lets just eat it
+ OptionSpec<String> mod = optionparser.accepts("mod", "A modid to dump").withRequiredArg().withValuesSeparatedBy(",");
+ OptionSpec<Void> flat = optionparser.accepts("flat", "Do not append modid prefix to output directory when generating for multiple mods");
Expand All @@ -24,17 +23,16 @@
boolean flag3 = flag || optionset.has(optionspec3);
Collection<Path> collection = optionset.valuesOf(optionspec6).stream().map(p_129659_ -> Paths.get(p_129659_)).toList();
- DataGenerator datagenerator = new DataGenerator(path, SharedConstants.getCurrentVersion(), true);
+ Collection<Path> existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).toList();
+ java.util.Set<String> existingMods = new java.util.HashSet<>(optionset.valuesOf(existingMod));
+ java.util.Set<String> mods = new java.util.HashSet<>(optionset.valuesOf(mod));
+ boolean isFlat = mods.isEmpty() || optionset.has(flat);
+ boolean validate = optionset.has(validateSpec);
+ DataGenerator datagenerator = new DataGenerator(isFlat ? path : path.resolve("minecraft"), SharedConstants.getCurrentVersion(), true);
+ java.util.Collection<Path> existingPacks = optionset.valuesOf(existing).stream().map(Paths::get).toList();
+ if (mods.contains("minecraft") || mods.isEmpty()) {
addServerProviders(datagenerator, collection, flag1, flag2, flag3);
- datagenerator.run();
+ }
+ net.neoforged.neoforge.data.loading.DatagenModLoader.begin(mods, path, collection, existingPacks, existingMods, flag2, flag3, validate, isFlat, null, null, () -> {},
+ net.neoforged.neoforge.data.loading.DatagenModLoader.begin(mods, path, collection, existingPacks, flag2, flag3, validate, isFlat, null, null, () -> {},
+ net.neoforged.neoforge.data.event.GatherDataEvent.Server::new, datagenerator);
} else {
optionparser.printHelpOn(System.out);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
--- a/net/minecraft/data/advancements/AdvancementProvider.java
+++ b/net/minecraft/data/advancements/AdvancementProvider.java
@@ -16,6 +_,11 @@
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;

+/**
+ * @deprecated NeoForge: Use {@link net.neoforged.neoforge.common.data.AdvancementProvider} instead,
+ * provides ease of access for the {@link net.neoforged.neoforge.common.data.ExistingFileHelper} in the generator
+ */
+@Deprecated
public class AdvancementProvider implements DataProvider {
private final PackOutput.PathProvider pathProvider;
private final List<AdvancementSubProvider> subProviders;
@@ -37,7 +_,7 @@
throw new IllegalStateException("Duplicate advancement " + p_339356_.id());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.level.block.entity.BannerPatterns;

public class BannerPatternTagsProvider extends TagsProvider<BannerPattern> {
+ /** @deprecated Forge: Use the {@linkplain #BannerPatternTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #BannerPatternTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public BannerPatternTagsProvider(PackOutput p_256451_, CompletableFuture<HolderLookup.Provider> p_256420_) {
super(p_256451_, Registries.BANNER_PATTERN, p_256420_);
+ }
+ public BannerPatternTagsProvider(PackOutput p_256451_, CompletableFuture<HolderLookup.Provider> p_256420_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256451_, Registries.BANNER_PATTERN, p_256420_, modId, existingFileHelper);
+ public BannerPatternTagsProvider(PackOutput p_256451_, CompletableFuture<HolderLookup.Provider> p_256420_, String modId) {
+ super(p_256451_, Registries.BANNER_PATTERN, p_256420_, modId);
}

@Override
6 changes: 3 additions & 3 deletions patches/net/minecraft/data/tags/BiomeTagsProvider.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList;

public class BiomeTagsProvider extends TagsProvider<Biome> {
+ /** @deprecated Forge: Use the {@linkplain #BiomeTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #BiomeTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public BiomeTagsProvider(PackOutput p_255800_, CompletableFuture<HolderLookup.Provider> p_256205_) {
super(p_255800_, Registries.BIOME, p_256205_);
+ }
+ public BiomeTagsProvider(PackOutput p_255800_, CompletableFuture<HolderLookup.Provider> p_256205_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_255800_, Registries.BIOME, p_256205_, modId, existingFileHelper);
+ public BiomeTagsProvider(PackOutput p_255800_, CompletableFuture<HolderLookup.Provider> p_256205_, String modId) {
+ super(p_255800_, Registries.BIOME, p_256205_, modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.entity.animal.CatVariant;

public class CatVariantTagsProvider extends TagsProvider<CatVariant> {
+ /** @deprecated Forge: Use the {@linkplain #CatVariantTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #CatVariantTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture<HolderLookup.Provider> p_256090_) {
super(p_256547_, Registries.CAT_VARIANT, p_256090_);
+ }
+ public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture<HolderLookup.Provider> p_256090_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256547_, Registries.CAT_VARIANT, p_256090_, modId, existingFileHelper);
+ public CatVariantTagsProvider(PackOutput p_256547_, CompletableFuture<HolderLookup.Provider> p_256090_, String modId) {
+ super(p_256547_, Registries.CAT_VARIANT, p_256090_, modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.damagesource.DamageTypes;

public class DamageTypeTagsProvider extends TagsProvider<DamageType> {
+ /** @deprecated Forge: Use the {@linkplain #DamageTypeTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #DamageTypeTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public DamageTypeTagsProvider(PackOutput p_270719_, CompletableFuture<HolderLookup.Provider> p_270256_) {
super(p_270719_, Registries.DAMAGE_TYPE, p_270256_);
+ }
+ public DamageTypeTagsProvider(PackOutput p_270719_, CompletableFuture<HolderLookup.Provider> p_270256_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_270719_, Registries.DAMAGE_TYPE, p_270256_, modId, existingFileHelper);
+ public DamageTypeTagsProvider(PackOutput p_270719_, CompletableFuture<HolderLookup.Provider> p_270256_, String modId) {
+ super(p_270719_, Registries.DAMAGE_TYPE, p_270256_, modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import net.minecraft.world.item.enchantment.Enchantment;

public abstract class EnchantmentTagsProvider extends TagsProvider<Enchantment> {
+ /** @deprecated Forge: Use the {@linkplain #EnchantmentTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #EnchantmentTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
public EnchantmentTagsProvider(PackOutput p_341044_, CompletableFuture<HolderLookup.Provider> p_341146_) {
super(p_341044_, Registries.ENCHANTMENT, p_341146_);
+ }
+ public EnchantmentTagsProvider(PackOutput p_341044_, CompletableFuture<HolderLookup.Provider> p_341146_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_341044_, Registries.ENCHANTMENT, p_341146_, modId, existingFileHelper);
+ public EnchantmentTagsProvider(PackOutput p_341044_, CompletableFuture<HolderLookup.Provider> p_341146_, String modId) {
+ super(p_341044_, Registries.ENCHANTMENT, p_341146_, modId);
}

protected void tooltipOrder(HolderLookup.Provider p_341105_, ResourceKey<Enchantment>... p_345255_) {
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import net.minecraft.world.entity.EntityType;

public class EntityTypeTagsProvider extends IntrinsicHolderTagsProvider<EntityType<?>> {
+ /** @deprecated Forge: Use the {@linkplain #EntityTypeTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #EntityTypeTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public EntityTypeTagsProvider(PackOutput p_256095_, CompletableFuture<HolderLookup.Provider> p_256572_) {
- super(p_256095_, Registries.ENTITY_TYPE, p_256572_, p_256665_ -> p_256665_.builtInRegistryHolder().key());
+ this(p_256095_, p_256572_, "vanilla", null);
+ this(p_256095_, p_256572_, "vanilla");
+ }
+ public EntityTypeTagsProvider(PackOutput p_256095_, CompletableFuture<HolderLookup.Provider> p_256572_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256095_, Registries.ENTITY_TYPE, p_256572_, p_256665_ -> p_256665_.builtInRegistryHolder().key(), modId, existingFileHelper);
+ public EntityTypeTagsProvider(PackOutput p_256095_, CompletableFuture<HolderLookup.Provider> p_256572_, String modId) {
+ super(p_256095_, Registries.ENTITY_TYPE, p_256572_, p_256665_ -> p_256665_.builtInRegistryHolder().key(), modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorPresets;

public class FlatLevelGeneratorPresetTagsProvider extends TagsProvider<FlatLevelGeneratorPreset> {
+ /** @deprecated Forge: Use the {@linkplain #FlatLevelGeneratorPresetTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #FlatLevelGeneratorPresetTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public FlatLevelGeneratorPresetTagsProvider(PackOutput p_256604_, CompletableFuture<HolderLookup.Provider> p_255962_) {
super(p_256604_, Registries.FLAT_LEVEL_GENERATOR_PRESET, p_255962_);
+ }
+ public FlatLevelGeneratorPresetTagsProvider(PackOutput p_256604_, CompletableFuture<HolderLookup.Provider> p_255962_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256604_, Registries.FLAT_LEVEL_GENERATOR_PRESET, p_255962_, modId, existingFileHelper);
+ public FlatLevelGeneratorPresetTagsProvider(PackOutput p_256604_, CompletableFuture<HolderLookup.Provider> p_255962_, String modId) {
+ super(p_256604_, Registries.FLAT_LEVEL_GENERATOR_PRESET, p_255962_, modId);
}

@Override
8 changes: 4 additions & 4 deletions patches/net/minecraft/data/tags/FluidTagsProvider.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import net.minecraft.world.level.material.Fluids;

public class FluidTagsProvider extends IntrinsicHolderTagsProvider<Fluid> {
+ /** @deprecated Forge: Use the {@linkplain #FluidTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #FluidTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public FluidTagsProvider(PackOutput p_255941_, CompletableFuture<HolderLookup.Provider> p_256600_) {
- super(p_255941_, Registries.FLUID, p_256600_, p_256474_ -> p_256474_.builtInRegistryHolder().key());
+ this(p_255941_, p_256600_, "vanilla", null);
+ this(p_255941_, p_256600_, "vanilla");
+ }
+ public FluidTagsProvider(PackOutput p_255941_, CompletableFuture<HolderLookup.Provider> p_256600_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_255941_, Registries.FLUID, p_256600_, p_256474_ -> p_256474_.builtInRegistryHolder().key(), modId, existingFileHelper);
+ public FluidTagsProvider(PackOutput p_255941_, CompletableFuture<HolderLookup.Provider> p_256600_, String modId) {
+ super(p_255941_, Registries.FLUID, p_256600_, p_256474_ -> p_256474_.builtInRegistryHolder().key(), modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
GameEvent.UNEQUIP.key()
);

+ /** @deprecated Neo: Use the {@linkplain #GameEventTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Neo: Use the {@linkplain #GameEventTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public GameEventTagsProvider(PackOutput p_256060_, CompletableFuture<HolderLookup.Provider> p_255621_) {
- super(p_256060_, Registries.GAME_EVENT, p_255621_);
+ this(p_256060_, p_255621_, "vanilla", null);
+ this(p_256060_, p_255621_, "vanilla");
+ }
+
+ public GameEventTagsProvider(PackOutput p_256060_, CompletableFuture<HolderLookup.Provider> p_255621_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256060_, Registries.GAME_EVENT, p_255621_, modId, existingFileHelper);
+ public GameEventTagsProvider(PackOutput p_256060_, CompletableFuture<HolderLookup.Provider> p_255621_, String modId) {
+ super(p_256060_, Registries.GAME_EVENT, p_255621_, modId);
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.world.item.Instruments;

public class InstrumentTagsProvider extends TagsProvider<Instrument> {
+ /** @deprecated Forge: Use the {@linkplain #InstrumentTagsProvider(PackOutput, CompletableFuture, String, net.neoforged.neoforge.common.data.ExistingFileHelper) mod id variant} */
+ /** @deprecated Forge: Use the {@linkplain #InstrumentTagsProvider(PackOutput, CompletableFuture, String) mod id variant} */
+ @Deprecated
public InstrumentTagsProvider(PackOutput p_256418_, CompletableFuture<HolderLookup.Provider> p_256038_) {
super(p_256418_, Registries.INSTRUMENT, p_256038_);
+ }
+ public InstrumentTagsProvider(PackOutput p_256418_, CompletableFuture<HolderLookup.Provider> p_256038_, String modId, @org.jetbrains.annotations.Nullable net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) {
+ super(p_256418_, Registries.INSTRUMENT, p_256038_, modId, existingFileHelper);
+ public InstrumentTagsProvider(PackOutput p_256418_, CompletableFuture<HolderLookup.Provider> p_256038_, String modId) {
+ super(p_256418_, Registries.INSTRUMENT, p_256038_, modId);
}

@Override
Loading

0 comments on commit 821e47f

Please sign in to comment.