Skip to content

Commit

Permalink
Dev release v1.16.2-1.0.1-dev. Potentially fix for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Young committed Aug 31, 2020
1 parent 335a9ab commit c307047
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.jvmargs = -Xmx3G
# No daemon
org.gradle.daemon = false

modVersion = 1.0
modVersion = 1.0.1-dev

# The modid of the mod
modId = bettercaves
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ private static void lateSetup() {
// These will be used in dimensions where Better Caves is not whitelisted.
List<Supplier<ConfiguredCarver<?>>> defaultAirCarvers = biome.func_242440_e().func_242489_a(GenerationStage.Carving.AIR);
List<Supplier<ConfiguredCarver<?>>> defaultLiquidCarvers = biome.func_242440_e().func_242489_a(GenerationStage.Carving.LIQUID);
BetterCaves.defaultBiomeAirCarvers.put(biome.toString(), defaultAirCarvers);
BetterCaves.defaultBiomeLiquidCarvers.put(biome.toString(), defaultLiquidCarvers);
BetterCaves.defaultBiomeAirCarvers.put(biome.toString(), convertImmutableList(defaultAirCarvers));
BetterCaves.defaultBiomeLiquidCarvers.put(biome.toString(), convertImmutableList(defaultLiquidCarvers));

// Use Access Transformer to make carvers field public so we can replace with empty list
biome.func_242440_e().field_242483_e = Maps.newHashMap();
Expand All @@ -79,9 +79,9 @@ private static void lateSetup() {
while (biomeFeatures.size() <= GenerationStage.Decoration.RAW_GENERATION.ordinal()) {
biomeFeatures.add(Lists.newArrayList());
}
biomeFeatures.get(GenerationStage.Decoration.RAW_GENERATION.ordinal()).add(0,
() -> CONFIGURED_BETTERCAVES_FEATURE
);
List<Supplier<ConfiguredFeature<?, ?>>> rawGenSuppliers = convertImmutableList(biomeFeatures.get(GenerationStage.Decoration.RAW_GENERATION.ordinal()));
rawGenSuppliers.add(0, () -> CONFIGURED_BETTERCAVES_FEATURE);
biomeFeatures.set(GenerationStage.Decoration.RAW_GENERATION.ordinal(), rawGenSuppliers);
}
}

Expand Down Expand Up @@ -126,9 +126,23 @@ public static void configChanged(ModConfig.ModConfigEvent event) {
}
}

/**
* In 1.16.2, many lists were made immutable. Other modders seemingly have confused themselves and made
* mutable lists immutable after processing them. This method serves to help avoid problems arising from
* attempting to modify immutable collections.
*/
private static void convertImmutableFeatures(Biome biome) {
if (biome.func_242440_e().field_242484_f instanceof ImmutableList) {
biome.func_242440_e().field_242484_f = biome.func_242440_e().field_242484_f.stream().map(Lists::newArrayList).collect(Collectors.toList());
}
}

/**
* In 1.16.2, many lists were made immutable. Other modders seemingly have confused themselves and made
* mutable lists immutable after processing them. This method serves to help avoid problems arising from
* attempting to modify immutable collections.
*/
private static <T> List<T> convertImmutableList(List<T> list) {
return new ArrayList<>(list);
}
}

0 comments on commit c307047

Please sign in to comment.