Skip to content

Commit

Permalink
[1.21] Fix data generator merge issue (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexModder authored Jul 2, 2024
1 parent 650d3a0 commit 6adc156
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion patches/net/minecraft/data/DataGenerator.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
stopwatch1.start();
hashcache.applyUpdate(hashcache.generateUpdate(p_254418_, p_253750_::run).join());
stopwatch1.stop();
@@ -56,6 +_,34 @@
@@ -56,6 +_,51 @@
public DataGenerator.PackGenerator getBuiltinDatapack(boolean p_253826_, String p_254134_) {
Path path = this.vanillaPackOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve("minecraft").resolve("datapacks").resolve(p_254134_);
return new DataGenerator.PackGenerator(p_253826_, p_254134_, new PackOutput(path));
+ }
+
+ public PackGenerator getBuiltinDatapack(boolean run, String namespace, String path) {
+ var packPath = vanillaPackOutput.getOutputFolder(PackOutput.Target.DATA_PACK).resolve(namespace).resolve("datapacks").resolve(path);
+ return new PackGenerator(run, namespace + '_' + path, new PackOutput(packPath));
+ }
+
+ public Map<String, DataProvider> getProvidersView() {
+ return this.providersView;
+ }
Expand All @@ -48,6 +53,18 @@
+ DataGenerator.this.providersToRun.put(id, provider);
+
+ return provider;
+ }
+
+ public void merge(DataGenerator other) {
+ other.providersToRun.forEach((id, provider) -> {
+ if(!allProviderIds.add(id))
+ throw new IllegalStateException("Duplicate provider: " + id);
+
+ providersToRun.put(id, provider);
+ });
+
+ other.providersToRun.clear();
+ other.allProviderIds.clear();
}

static {
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void runAll() {
paths.values().forEach(lst -> {
DataGenerator parent = lst.get(0);
for (int x = 1; x < lst.size(); x++)
lst.get(x).getProvidersView().forEach((name, provider) -> parent.addProvider(true, provider));
parent.merge(lst.get(x));
try {
parent.run();
} catch (IOException ex) {
Expand Down

0 comments on commit 6adc156

Please sign in to comment.