Skip to content

Commit

Permalink
Don't try to add replacement or sub biomes to a finalized list.
Browse files Browse the repository at this point in the history
- Work around bclib adding FAPI biomes after requesting ours
  • Loading branch information
gniftygnome committed Apr 8, 2024
1 parent fa126da commit 98b9541
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public void addPlacement(RegistryKey<Biome> biome, MultiNoiseUtil.NoiseHypercube
}

public void addReplacement(RegistryKey<Biome> target, RegistryKey<Biome> biome, double rate) {
if (biomesInjected) {
if (biomesInjected || (replacementRequests.containsKey(target) && replacementRequests.get(target).finalized)) {
Biolith.LOGGER.error("Biolith's BiomePlacement.addReplacement() called too late for biome: {}", biome.getValue());
} else {
replacementRequests.computeIfAbsent(target, ReplacementRequestSet::new).addRequest(biome, rate);
}
}

public void addSubBiome(RegistryKey<Biome> target, RegistryKey<Biome> biome, SubBiomeMatcher matcher) {
if (biomesInjected) {
if (biomesInjected || (subBiomeRequests.containsKey(target) && subBiomeRequests.get(target).finalized)) {
Biolith.LOGGER.error("Biolith's BiomePlacement.addSubBiome() called too late for biome: {}", biome.getValue());
} else {
subBiomeRequests.computeIfAbsent(target, SubBiomeRequestSet::new).addRequest(biome, matcher);
Expand Down Expand Up @@ -176,6 +176,7 @@ ReplacementRequest complete(RegistryEntryLookup<Biome> biomeEntryGetter, double
}

protected class ReplacementRequestSet {
private boolean finalized = false;
RegistryKey<Biome> target;
List<ReplacementRequest> requests = new ArrayList<>(8);

Expand Down Expand Up @@ -248,6 +249,7 @@ void complete(RegistryEntryLookup<Biome> biomeEntryGetter) {

// Store the finalized immutable request list.
requests = List.copyOf(requests);
finalized = true;
}
}

Expand Down Expand Up @@ -278,6 +280,7 @@ SubBiomeRequest complete(RegistryEntryLookup<Biome> biomeEntryGetter) {
}

protected class SubBiomeRequestSet {
private boolean finalized = false;
RegistryKey<Biome> target;
List<SubBiomeRequest> requests = new ArrayList<>(8);

Expand Down Expand Up @@ -316,6 +319,7 @@ void complete(RegistryEntryLookup<Biome> biomeEntryGetter) {
.map(request -> request.complete(biomeEntryGetter))
.sorted(Comparator.comparing(request -> request.biome.getValue()))
.toList();
finalized = true;
}
}
}

0 comments on commit 98b9541

Please sign in to comment.