Fixes to make BetterNether DataGen run

This commit is contained in:
Frank 2022-12-03 14:31:36 +01:00
parent 8626560681
commit c75450b6c5
10 changed files with 102 additions and 85 deletions

View file

@ -189,7 +189,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
} }
if (endCenterBiomePicker.isEmpty()) { if (endCenterBiomePicker.isEmpty()) {
BCLib.LOGGER.warning("No Center Island Biomes found. Forcing use of vanilla center."); BCLib.LOGGER.warning("No Center Island Biomes found. Forcing use of vanilla center.");
endCenterBiomePicker.addBiome(BCLBiomeRegistry.THE_END); endCenterBiomePicker.addBiome(BiomeAPI.THE_END);
endCenterBiomePicker.rebuild(); endCenterBiomePicker.rebuild();
if (endCenterBiomePicker.isEmpty()) { if (endCenterBiomePicker.isEmpty()) {
BCLib.LOGGER.error("Unable to force vanilla central Island. Falling back to land Biomes..."); BCLib.LOGGER.error("Unable to force vanilla central Island. Falling back to land Biomes...");

View file

@ -45,12 +45,13 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
public class BCLBiomeBuilder { public class BCLBiomeBuilder {
private static final List<UnboundBCLBiome<?>> undoundBiomes = new LinkedList<>(); static final ConcurrentLinkedQueue<UnboundBCLBiome<?>> UNBOUND_BIOMES = new ConcurrentLinkedQueue<>();
public static int calculateSkyColor(float temperature) { public static int calculateSkyColor(float temperature) {
return OverworldBiomes.calculateSkyColor(temperature); return OverworldBiomes.calculateSkyColor(temperature);
@ -957,12 +958,12 @@ public class BCLBiomeBuilder {
return builder.generationSettings(fixGenerationSettings(genBuilder.build())).build(); return builder.generationSettings(fixGenerationSettings(genBuilder.build())).build();
} }
); );
undoundBiomes.add(unbound); UNBOUND_BIOMES.add(unbound);
return unbound; return unbound;
} }
public static void registerUnbound(BootstapContext<Biome> context) { public static void registerUnbound(BootstapContext<Biome> context) {
undoundBiomes.forEach(u -> u.register(context)); UNBOUND_BIOMES.forEach(u -> u.register(context));
undoundBiomes.clear(); UNBOUND_BIOMES.clear();
} }
} }

View file

@ -1,6 +1,7 @@
package org.betterx.bclib.api.v2.levelgen.biomes; package org.betterx.bclib.api.v2.levelgen.biomes;
import org.betterx.bclib.BCLib; import org.betterx.bclib.BCLib;
import org.betterx.datagen.bclib.worldgen.VanillaBCLBiomesDataProvider;
import org.betterx.worlds.together.WorldsTogether; import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.world.event.WorldBootstrap; import org.betterx.worlds.together.world.event.WorldBootstrap;
@ -43,59 +44,7 @@ public class BCLBiomeRegistry {
* Have {@code Biomes.THE_VOID} as the reference biome. * Have {@code Biomes.THE_VOID} as the reference biome.
**/ **/
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location()); public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
private static boolean didCreate = false;
public static final BCLBiome THE_END = InternalBiomeAPI.wrapBiome(
Biomes.THE_END,
InternalBiomeAPI.OTHER_END_CENTER
);
public static final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.NETHER_WASTES,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome CRIMSON_FOREST_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.CRIMSON_FOREST,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome WARPED_FOREST_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.WARPED_FOREST,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.SOUL_SAND_VALLEY,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome BASALT_DELTAS_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.BASALT_DELTAS,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome END_MIDLANDS = InternalBiomeAPI.wrapBiome(
Biomes.END_MIDLANDS,
0.5F,
InternalBiomeAPI.OTHER_END_LAND
);
public static final BCLBiome END_HIGHLANDS = InternalBiomeAPI.wrapBiome(
Biomes.END_HIGHLANDS,
END_MIDLANDS,
8,
0.5F,
InternalBiomeAPI.OTHER_END_LAND
);
public static final BCLBiome END_BARRENS = InternalBiomeAPI.wrapBiome(
Biomes.END_BARRENS,
InternalBiomeAPI.OTHER_END_BARRENS
);
public static final BCLBiome SMALL_END_ISLANDS = InternalBiomeAPI.wrapBiome(
Biomes.SMALL_END_ISLANDS,
InternalBiomeAPI.OTHER_END_VOID
);
public static boolean isEmptyBiome(ResourceLocation l) { public static boolean isEmptyBiome(ResourceLocation l) {
return l == null || Biomes.THE_VOID.location().equals(l); return l == null || Biomes.THE_VOID.location().equals(l);
@ -201,7 +150,7 @@ public class BCLBiomeRegistry {
if (WorldBootstrap.getLastRegistryAccess() == null) return null; if (WorldBootstrap.getLastRegistryAccess() == null) return null;
return WorldBootstrap.getLastRegistryAccess().registry(BCL_BIOMES_REGISTRY).orElse(null); return WorldBootstrap.getLastRegistryAccess().registry(BCL_BIOMES_REGISTRY).orElse(null);
} }
public static Stream<ResourceKey<BCLBiome>> getAll(BiomeAPI.BiomeType dim) { public static Stream<ResourceKey<BCLBiome>> getAll(BiomeAPI.BiomeType dim) {
Set<ResourceKey<BCLBiome>> result = new HashSet<>(); Set<ResourceKey<BCLBiome>> result = new HashSet<>();
@ -239,4 +188,14 @@ public class BCLBiomeRegistry {
public static void ensureStaticallyLoaded() { public static void ensureStaticallyLoaded() {
} }
public static void prepareForDatagen() {
if (didCreate) return;
didCreate = true;
BUILTIN_BCL_BIOMES = BuiltInRegistries.registerSimple(
BCL_BIOMES_REGISTRY,
VanillaBCLBiomesDataProvider::bootstrap
);
}
} }

View file

@ -29,6 +29,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData; import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkAccess;
@ -56,6 +57,51 @@ import org.jetbrains.annotations.Nullable;
public class BiomeAPI { public class BiomeAPI {
public static final BCLBiome THE_END = InternalBiomeAPI.wrapBiome(
Biomes.THE_END,
InternalBiomeAPI.OTHER_END_CENTER
);
public static final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.NETHER_WASTES,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome CRIMSON_FOREST_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.CRIMSON_FOREST,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome WARPED_FOREST_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.WARPED_FOREST,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome SOUL_SAND_VALLEY_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.SOUL_SAND_VALLEY,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome BASALT_DELTAS_BIOME = InternalBiomeAPI.wrapBiome(
Biomes.BASALT_DELTAS,
InternalBiomeAPI.OTHER_NETHER
);
public static final BCLBiome END_MIDLANDS = InternalBiomeAPI.wrapBiome(
Biomes.END_MIDLANDS,
0.5F,
InternalBiomeAPI.OTHER_END_LAND
);
public static final BCLBiome END_HIGHLANDS = InternalBiomeAPI.wrapBiome(
Biomes.END_HIGHLANDS,
END_MIDLANDS,
8,
0.5F,
InternalBiomeAPI.OTHER_END_LAND
);
public static final BCLBiome END_BARRENS = InternalBiomeAPI.wrapBiome(
Biomes.END_BARRENS,
InternalBiomeAPI.OTHER_END_BARRENS
);
public static final BCLBiome SMALL_END_ISLANDS = InternalBiomeAPI.wrapBiome(
Biomes.SMALL_END_ISLANDS,
InternalBiomeAPI.OTHER_END_VOID
);
/** /**
* Register {@link BCLBiome} instance and its {@link Biome} if necessary. * Register {@link BCLBiome} instance and its {@link Biome} if necessary.
* *

View file

@ -40,6 +40,7 @@ class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim); BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim);
} }
BCLBiomeBuilder.UNBOUND_BIOMES.remove(this);
registered = new BCLBiomeContainer<>(this.biome); registered = new BCLBiomeContainer<>(this.biome);
return registered; return registered;
} }

View file

@ -19,18 +19,25 @@ import java.util.Optional;
public class BCLConfigureFeature<F extends Feature<FC>, FC extends FeatureConfiguration> { public class BCLConfigureFeature<F extends Feature<FC>, FC extends FeatureConfiguration> {
public static class Unregistered<F extends Feature<FC>, FC extends FeatureConfiguration> extends BCLConfigureFeature<F, FC> { public static class Unregistered<F extends Feature<FC>, FC extends FeatureConfiguration> extends BCLConfigureFeature<F, FC> {
private BCLConfigureFeature<F, FC> registered;
Unregistered(ResourceLocation id, Holder<ConfiguredFeature<FC, F>> configuredFeature) { Unregistered(ResourceLocation id, Holder<ConfiguredFeature<FC, F>> configuredFeature) {
super(id, configuredFeature, false); super(id, configuredFeature, false);
registered = null;
} }
@Override @Override
public BCLConfigureFeature<F, FC> register(BootstapContext<ConfiguredFeature<?, ?>> bootstrapContext) { public BCLConfigureFeature<F, FC> register(BootstapContext<ConfiguredFeature<?, ?>> bootstrapContext) {
if (registered != null) return registered;
Holder<ConfiguredFeature<FC, F>> holder = BCLFeatureBuilder.register( Holder<ConfiguredFeature<FC, F>> holder = BCLFeatureBuilder.register(
bootstrapContext, bootstrapContext,
id, id,
configuredFeature.value() configuredFeature.value()
); );
return new BCLConfigureFeature<>(id, holder, true); BCLFeatureBuilder.UNBOUND_FEATURES.remove(this);
registered = new BCLConfigureFeature<>(id, holder, true);
return registered;
} }
} }

View file

@ -19,21 +19,27 @@ import org.jetbrains.annotations.ApiStatus;
public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration> { public class BCLFeature<F extends Feature<FC>, FC extends FeatureConfiguration> {
public static class Unregistered<F extends Feature<FC>, FC extends FeatureConfiguration> extends BCLFeature<F, FC> { public static class Unregistered<F extends Feature<FC>, FC extends FeatureConfiguration> extends BCLFeature<F, FC> {
private BCLFeature<F, FC> registered;
Unregistered( Unregistered(
BCLConfigureFeature<F, FC> configuredFeature, BCLConfigureFeature<F, FC> configuredFeature,
Holder<PlacedFeature> placed, Holder<PlacedFeature> placed,
GenerationStep.Decoration decoration GenerationStep.Decoration decoration
) { ) {
super(configuredFeature, placed, decoration); super(configuredFeature, placed, decoration);
registered = null;
} }
@Override @Override
public BCLFeature<F, FC> register(BootstapContext<PlacedFeature> bootstrapContext) { public BCLFeature<F, FC> register(BootstapContext<PlacedFeature> bootstrapContext) {
if (registered != null) return registered;
Holder<PlacedFeature> holder = BCLPlacedFeatureBuilder.register( Holder<PlacedFeature> holder = BCLPlacedFeatureBuilder.register(
bootstrapContext, bootstrapContext,
getPlacedFeature() getPlacedFeature()
); );
return new BCLFeature<>(configuredFeature, holder, decoration); BCLPlacedFeatureBuilder.UNBOUND_FEATURES.remove(this);
registered = new BCLFeature<>(configuredFeature, holder, decoration);
return registered;
} }
} }

View file

@ -42,6 +42,7 @@ import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -59,7 +60,7 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
B create(ResourceLocation id, Holder<ConfiguredFeature<FC, F>> configuredFeature); B create(ResourceLocation id, Holder<ConfiguredFeature<FC, F>> configuredFeature);
} }
private static List<BCLConfigureFeature.Unregistered<?, ?>> UNBOUND_FEATURES = new LinkedList<>(); static ConcurrentLinkedQueue<BCLConfigureFeature.Unregistered<?, ?>> UNBOUND_FEATURES = new ConcurrentLinkedQueue<>();
/** /**
* Starts a new {@link BCLFeature} builder. * Starts a new {@link BCLFeature} builder.

View file

@ -13,15 +13,15 @@ import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> extends CommonPlacedFeatureBuilder<F, FC, BCLPlacedFeatureBuilder<F, FC>> { public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> extends CommonPlacedFeatureBuilder<F, FC, BCLPlacedFeatureBuilder<F, FC>> {
private final ResourceLocation featureID; private final ResourceLocation featureID;
private GenerationStep.Decoration decoration = GenerationStep.Decoration.VEGETAL_DECORATION; private GenerationStep.Decoration decoration = GenerationStep.Decoration.VEGETAL_DECORATION;
private final BCLConfigureFeature<F, FC> cFeature; private final BCLConfigureFeature<F, FC> cFeature;
private static final List<BCLFeature.Unregistered> UNBOUND_FEATURES = new LinkedList<>(); static final ConcurrentLinkedQueue<BCLFeature.Unregistered> UNBOUND_FEATURES = new ConcurrentLinkedQueue<>();
private BCLPlacedFeatureBuilder( private BCLPlacedFeatureBuilder(
ResourceLocation featureID, ResourceLocation featureID,

View file

@ -2,19 +2,15 @@ package org.betterx.datagen.bclib.worldgen;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry; import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
public class VanillaBCLBiomesDataProvider { public class VanillaBCLBiomesDataProvider {
private static boolean didBootstrap = false; private static boolean didBootstrap = false;
public static void create() { public static void create() {
BCLBiomeRegistry.BUILTIN_BCL_BIOMES = BuiltInRegistries.registerSimple( BCLBiomeRegistry.prepareForDatagen();
BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
VanillaBCLBiomesDataProvider::bootstrap
);
bootstrap(BCLBiomeRegistry.BUILTIN_BCL_BIOMES); bootstrap(BCLBiomeRegistry.BUILTIN_BCL_BIOMES);
} }
@ -23,35 +19,35 @@ public class VanillaBCLBiomesDataProvider {
didBootstrap = true; didBootstrap = true;
Registry.register(reg, BCLBiomeRegistry.SMALL_END_ISLANDS.getBCLBiomeKey(), BCLBiomeRegistry.SMALL_END_ISLANDS); Registry.register(reg, BiomeAPI.SMALL_END_ISLANDS.getBCLBiomeKey(), BiomeAPI.SMALL_END_ISLANDS);
Registry.register(reg, BCLBiomeRegistry.END_BARRENS.getBCLBiomeKey(), BCLBiomeRegistry.END_BARRENS); Registry.register(reg, BiomeAPI.END_BARRENS.getBCLBiomeKey(), BiomeAPI.END_BARRENS);
Registry.register(reg, BCLBiomeRegistry.END_HIGHLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_HIGHLANDS); Registry.register(reg, BiomeAPI.END_HIGHLANDS.getBCLBiomeKey(), BiomeAPI.END_HIGHLANDS);
Registry.register(reg, BCLBiomeRegistry.END_MIDLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_MIDLANDS); Registry.register(reg, BiomeAPI.END_MIDLANDS.getBCLBiomeKey(), BiomeAPI.END_MIDLANDS);
Registry.register(reg, BCLBiomeRegistry.THE_END.getBCLBiomeKey(), BCLBiomeRegistry.THE_END); Registry.register(reg, BiomeAPI.THE_END.getBCLBiomeKey(), BiomeAPI.THE_END);
Registry.register( Registry.register(
reg, reg,
BCLBiomeRegistry.BASALT_DELTAS_BIOME.getBCLBiomeKey(), BiomeAPI.BASALT_DELTAS_BIOME.getBCLBiomeKey(),
BCLBiomeRegistry.BASALT_DELTAS_BIOME BiomeAPI.BASALT_DELTAS_BIOME
); );
Registry.register( Registry.register(
reg, reg,
BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(), BiomeAPI.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME BiomeAPI.SOUL_SAND_VALLEY_BIOME
); );
Registry.register( Registry.register(
reg, reg,
BCLBiomeRegistry.WARPED_FOREST_BIOME.getBCLBiomeKey(), BiomeAPI.WARPED_FOREST_BIOME.getBCLBiomeKey(),
BCLBiomeRegistry.WARPED_FOREST_BIOME BiomeAPI.WARPED_FOREST_BIOME
); );
Registry.register( Registry.register(
reg, reg,
BCLBiomeRegistry.CRIMSON_FOREST_BIOME.getBCLBiomeKey(), BiomeAPI.CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
BCLBiomeRegistry.CRIMSON_FOREST_BIOME BiomeAPI.CRIMSON_FOREST_BIOME
); );
Registry.register( Registry.register(
reg, reg,
BCLBiomeRegistry.NETHER_WASTES_BIOME.getBCLBiomeKey(), BiomeAPI.NETHER_WASTES_BIOME.getBCLBiomeKey(),
BCLBiomeRegistry.NETHER_WASTES_BIOME BiomeAPI.NETHER_WASTES_BIOME
); );
return Registry.register(reg, BCLBiomeRegistry.EMPTY_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.EMPTY_BIOME); return Registry.register(reg, BCLBiomeRegistry.EMPTY_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.EMPTY_BIOME);
} }