Skip to content

Commit 3b22167

Browse files
committed
Don't handle vanilla exception during recursive calls of placed feature indexer.
- Fix soft lock of vanilla feature indexer (resolves #34)
1 parent dc8f454 commit 3b22167

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

common/src/main/java/com/terraformersmc/biolith/impl/mixin/MixinPlacedFeatureIndexer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,36 @@
88
import net.minecraft.world.gen.feature.PlacedFeature;
99
import net.minecraft.world.gen.feature.util.PlacedFeatureIndexer;
1010
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.Unique;
1112

1213
import java.util.List;
1314
import java.util.function.Function;
1415

1516
@Mixin(PlacedFeatureIndexer.class)
1617
public class MixinPlacedFeatureIndexer {
18+
@Unique
19+
private static final ThreadLocal<Boolean> BIOLITH_RECURSION = ThreadLocal.withInitial(() -> false);
20+
1721
@WrapMethod(method = "collectIndexedFeatures")
1822
private static <T> List<PlacedFeatureIndexer.IndexedFeatures> biolith$wrapFeatureIndexer(List<T> biomes, Function<T, List<RegistryEntryList<PlacedFeature>>> biomesToPlacedFeaturesList, boolean listInvolvedBiomesOnFailure, Operation<List<PlacedFeatureIndexer.IndexedFeatures>> original) {
1923
List<PlacedFeatureIndexer.IndexedFeatures> features;
2024

2125
if (Biolith.getConfigManager().getGeneralConfig().forceResilientFeatureIndexer()) {
2226
Biolith.LOGGER.info("Using Biolith's resilient feature indexer (force_resilient_feature_indexer = true).");
2327
features = ResilientPlacedFeatureIndexer.collectIndexedFeatures(biomes, biomesToPlacedFeaturesList);
28+
} else if (BIOLITH_RECURSION.get()) {
29+
// The original is recursive; don't catch its exceptions when it's calling itself.
30+
features = original.call(biomes, biomesToPlacedFeaturesList, listInvolvedBiomesOnFailure);
2431
} else {
32+
BIOLITH_RECURSION.set(true);
2533
try {
2634
features = original.call(biomes, biomesToPlacedFeaturesList, listInvolvedBiomesOnFailure);
2735
} catch (IllegalStateException e) {
2836
Biolith.LOGGER.warn(e.getMessage());
2937
Biolith.LOGGER.warn("Vanilla feature indexer failed; retrying with Biolith's resilient feature indexer...");
3038
features = ResilientPlacedFeatureIndexer.collectIndexedFeatures(biomes, biomesToPlacedFeaturesList);
3139
}
40+
BIOLITH_RECURSION.set(false);
3241
}
3342

3443
return features;

0 commit comments

Comments
 (0)