Skip to content

Commit

Permalink
Work around crash while loading flatworld with modded structures. (Mi…
Browse files Browse the repository at this point in the history
…necraftForge#7764)

* Work around crash while loading flatworld with modded structures.

* Maybe fix issue with gradle daemon leaking memory and slowing down CI builds.
  • Loading branch information
gigaherz authored May 13, 2021
1 parent 474b47e commit 6f3da80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ changelog.txt
*.7z
/logs/

gradle.properties
!/mdk/gradle.properties
/projects/forge/rejects/

# Srg2Source causes import bugs on these patches. If you intentionnally change these, remove the ignore.
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
--- a/net/minecraft/world/gen/FlatGenerationSettings.java
+++ b/net/minecraft/world/gen/FlatGenerationSettings.java
@@ -147,8 +_,16 @@
biomegenerationsettings$builder.func_242513_a(GenerationStage.Decoration.LAKES, Features.field_243790_P);
}

+ Map<Structure<?>, StructureFeature<?, ?>> map = new java.util.HashMap<>(field_202247_j);
+ net.minecraft.util.registry.WorldGenRegistries.field_243654_f.func_201756_e().filter(f -> !map.containsKey(f.field_236268_b_)).forEach(f -> map.put(f.field_236268_b_, f));
for(Entry<Structure<?>, StructureSeparationSettings> entry : this.field_236933_f_.func_236195_a_().entrySet()) {
- biomegenerationsettings$builder.func_242516_a(biomegenerationsettings.func_242491_a(field_202247_j.get(entry.getKey())));
+ if (!map.containsKey(entry.getKey())) {
+ field_211404_q.error("FORGE: There's no known StructureFeature for {} when preparing the {} flatworld biome." +
+ " The structure will be skipped and may not spawn." +
+ " Please register your StructureFeatures in the WorldGenRegistries!", entry.getKey().func_143025_a(), biome.getRegistryName());
+ continue;
+ }
+ biomegenerationsettings$builder.func_242516_a(biomegenerationsettings.func_242491_a(map.get(entry.getKey())));
}

boolean flag = (!this.field_202245_D || this.field_242867_d.func_230519_c_(biome).equals(Optional.of(Biomes.field_185440_P))) && this.field_236934_k_;
@@ -174,7 +_,7 @@
}
}
Expand Down

0 comments on commit 6f3da80

Please sign in to comment.