Skip to content

Commit aaea930

Browse files
authored
Merge pull request #4
1.4.1: Fix stronghold cache
2 parents b8bd975 + 22e7ec2 commit aaea930

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx2G
22
org.gradle.parallel = true
33
org.gradle.caching = true
44

5-
mod_version = 1.4.0
5+
mod_version = 1.4.1
66
target_version = 1.16.1
77
archives_name = chunkcacher
88
maven_group = me.char321

src/main/java/me/char321/chunkcacher/mixin/ChunkGeneratorMixin.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import me.char321.chunkcacher.WorldCache;
44
import net.minecraft.util.math.ChunkPos;
55
import net.minecraft.world.gen.chunk.ChunkGenerator;
6+
import net.minecraft.world.gen.chunk.StructuresConfig;
67
import org.spongepowered.asm.mixin.Final;
78
import org.spongepowered.asm.mixin.Mixin;
89
import org.spongepowered.asm.mixin.Shadow;
@@ -17,18 +18,26 @@
1718
@Mixin(ChunkGenerator.class)
1819
public class ChunkGeneratorMixin {
1920

20-
@Shadow @Final private List<ChunkPos> strongholdPositions;
21+
@Shadow
22+
@Final
23+
private List<ChunkPos> strongholdPositions;
24+
25+
@Shadow
26+
@Final
27+
private StructuresConfig structuresConfig;
2128

2229
@Inject(method = "generateStrongholdPositions", at = @At("HEAD"))
2330
private void applyCachedStrongholds(CallbackInfo ci) {
24-
if (WorldCache.shouldCache() && WorldCache.strongholdCache != null && this.strongholdPositions.isEmpty()) {
31+
// this.structuresConfig.getStronghold() == StructuresConfig.DEFAULT_STRONGHOLD works for vanilla world generation because only the overworld will use DEFAULT_STRONGHOLD,
32+
// but it may fail with datapacks, mods or 20w14∞ adding new dimensions
33+
if (WorldCache.shouldCache() && this.structuresConfig.getStronghold() == StructuresConfig.DEFAULT_STRONGHOLD && WorldCache.strongholdCache != null && this.strongholdPositions.isEmpty()) {
2534
this.strongholdPositions.addAll(WorldCache.strongholdCache);
2635
}
2736
}
2837

2938
@Inject(method = "generateStrongholdPositions", at = @At("TAIL"))
3039
private void cacheStrongholds(CallbackInfo ci) {
31-
if (WorldCache.shouldCache() && WorldCache.strongholdCache == null) {
40+
if (WorldCache.shouldCache() && this.structuresConfig.getStronghold() == StructuresConfig.DEFAULT_STRONGHOLD && WorldCache.strongholdCache == null) {
3241
WorldCache.strongholdCache = Collections.unmodifiableList(new ArrayList<>(this.strongholdPositions));
3342
}
3443
}

0 commit comments

Comments
 (0)