Refactored BiomeRegistry and BiomeBuilder
This commit is contained in:
parent
78c1df618a
commit
0204c5fb73
7 changed files with 200 additions and 192 deletions
|
@ -17,6 +17,7 @@ import net.minecraft.core.particles.ParticleOptions;
|
|||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BiomeDefaultFeatures;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.data.worldgen.biome.OverworldBiomes;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.Music;
|
||||
|
@ -49,6 +50,17 @@ import java.util.function.Consumer;
|
|||
import java.util.function.Function;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
private static final List<UnboundBCLBiome<?>> undoundBiomes = new LinkedList<>();
|
||||
|
||||
public static int calculateSkyColor(float temperature) {
|
||||
return OverworldBiomes.calculateSkyColor(temperature);
|
||||
}
|
||||
|
||||
public static int DEFAULT_NETHER_WATER_COLOR = 0x3F76E4;
|
||||
public static int DEFAULT_NETHER_WATER_FOG_COLOR = 0x050533;
|
||||
public static float DEFAULT_NETHER_TEMPERATURE = 2.0f;
|
||||
public static float DEFAULT_NETHER_WETNESS = 0.0f;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BiomeSupplier<T> extends BiFunction<ResourceKey<Biome>, BCLBiomeSettings, T> {
|
||||
|
@ -916,7 +928,7 @@ public class BCLBiomeBuilder {
|
|||
//res.setSurface(surfaceRule);
|
||||
|
||||
//carvers.forEach(cfg -> BiomeAPI.addBiomeCarver(biome, cfg.second, cfg.first));
|
||||
return new UnboundBCLBiome<>(
|
||||
final UnboundBCLBiome<T> unbound = new UnboundBCLBiome<>(
|
||||
res,
|
||||
parent,
|
||||
ctx -> {
|
||||
|
@ -925,5 +937,12 @@ public class BCLBiomeBuilder {
|
|||
return builder.generationSettings(fixGenerationSettings(genBuilder.build())).build();
|
||||
}
|
||||
);
|
||||
undoundBiomes.add(unbound);
|
||||
return unbound;
|
||||
}
|
||||
|
||||
public static void registerUnbound(BootstapContext<Biome> context) {
|
||||
undoundBiomes.forEach(u -> u.register(context));
|
||||
undoundBiomes.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import net.minecraft.util.KeyDispatchDataCodec;
|
|||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -42,12 +44,58 @@ public class BCLBiomeRegistry {
|
|||
**/
|
||||
public static final BCLBiome EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
|
||||
|
||||
public static final BCLBiome THE_END = new BCLBiome(Biomes.THE_END.location(), InternalBiomeAPI.OTHER_END_CENTER);
|
||||
// InternalBiomeAPI.wrapNativeBiome(
|
||||
// Biomes.THE_END,
|
||||
// 0.5F,
|
||||
// InternalBiomeAPI.OTHER_END_CENTER
|
||||
// );
|
||||
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) {
|
||||
return l == null || Biomes.THE_VOID.location().equals(l);
|
||||
|
@ -98,19 +146,46 @@ public class BCLBiomeRegistry {
|
|||
}
|
||||
|
||||
public static boolean hasBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
if (bclBiomes != null && bclBiomes.containsKey(key.location())) {
|
||||
return hasBiome(key.location(), bclBiomes);
|
||||
}
|
||||
|
||||
public static boolean hasBiome(ResourceLocation loc, Registry<BCLBiome> bclBiomes) {
|
||||
if (loc == null) return false;
|
||||
if (bclBiomes != null && bclBiomes.containsKey(loc)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return BUILTIN_BCL_BIOMES.containsKey(key.location());
|
||||
return BUILTIN_BCL_BIOMES.containsKey(loc);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
if (bclBiomes != null && bclBiomes.containsKey(key.location())) {
|
||||
return bclBiomes.get(key.location());
|
||||
return getBiome(key.location(), bclBiomes);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiome(ResourceLocation loc, Registry<BCLBiome> bclBiomes) {
|
||||
if (bclBiomes != null && bclBiomes.containsKey(loc)) {
|
||||
return bclBiomes.get(loc);
|
||||
}
|
||||
|
||||
return BUILTIN_BCL_BIOMES.get(key.location());
|
||||
return BUILTIN_BCL_BIOMES.get(loc);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiomeOrNull(ResourceLocation loc, Registry<BCLBiome> bclBiomes) {
|
||||
if (!hasBiome(loc, bclBiomes)) return null;
|
||||
return getBiome(loc, bclBiomes);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiomeOrNull(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
return getBiomeOrNull(key.location(), bclBiomes);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiomeOrEmpty(ResourceLocation loc, Registry<BCLBiome> bclBiomes) {
|
||||
if (!hasBiome(loc, bclBiomes)) return EMPTY_BIOME;
|
||||
return getBiome(loc, bclBiomes);
|
||||
}
|
||||
|
||||
public static BCLBiome getBiomeOrEmpty(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
|
||||
return getBiomeOrEmpty(key.location(), bclBiomes);
|
||||
}
|
||||
|
||||
private static <T> ResourceKey<Registry<T>> createRegistryKey(ResourceLocation location) {
|
||||
|
@ -122,36 +197,33 @@ public class BCLBiomeRegistry {
|
|||
return Registry.register(registry, BCLib.makeID("biome"), BCLBiome.KEY_CODEC.codec());
|
||||
}
|
||||
|
||||
public static BCLBiome get(ResourceLocation loc) {
|
||||
return get(WorldBootstrap.getLastRegistryAccess(), loc);
|
||||
}
|
||||
|
||||
public static BCLBiome get(@Nullable RegistryAccess access, ResourceLocation loc) {
|
||||
var reg = getBclBiomesRegistry(access);
|
||||
if (reg == null) return null;
|
||||
return reg.get(loc);
|
||||
}
|
||||
|
||||
public static BCLBiome getOrElseEmpty(ResourceLocation loc) {
|
||||
return getOrElseEmpty(WorldBootstrap.getLastRegistryAccess(), loc);
|
||||
}
|
||||
|
||||
public static @Nullable BCLBiome getOrElseEmpty(@Nullable RegistryAccess access, ResourceLocation loc) {
|
||||
BCLBiome res = access == null ? null : get(access, loc);
|
||||
//if (res == null) return EMPTY_BIOME;
|
||||
return res;
|
||||
public static Registry<BCLBiome> registryOrNull() {
|
||||
if (WorldBootstrap.getLastRegistryAccess() == null) return null;
|
||||
return WorldBootstrap.getLastRegistryAccess().registry(BCL_BIOMES_REGISTRY).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
public static Stream<ResourceKey<BCLBiome>> getAll(BiomeAPI.BiomeType dim) {
|
||||
return getAll(WorldBootstrap.getLastRegistryAccessOrElseBuiltin(), dim);
|
||||
}
|
||||
Set<ResourceKey<BCLBiome>> result = new HashSet<>();
|
||||
final Registry<BCLBiome> reg = registryOrNull();
|
||||
if (reg != null) {
|
||||
reg.entrySet()
|
||||
.stream()
|
||||
.filter(e -> e.getValue().getIntendedType().is(dim))
|
||||
.map(e -> e.getKey())
|
||||
.forEach(k -> result.add(k));
|
||||
}
|
||||
|
||||
public static Stream<ResourceKey<BCLBiome>> getAll(RegistryAccess access, BiomeAPI.BiomeType dim) {
|
||||
return getBclBiomesRegistry(access)
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> e.getValue().getIntendedType().is(dim))
|
||||
.map(e -> e.getKey());
|
||||
if (BUILTIN_BCL_BIOMES != null) {
|
||||
BUILTIN_BCL_BIOMES
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(e -> e.getValue().getIntendedType().is(dim))
|
||||
.map(e -> e.getKey())
|
||||
.filter(k -> !result.contains(k))
|
||||
.forEach(k -> result.add(k));
|
||||
}
|
||||
return result.stream();
|
||||
}
|
||||
|
||||
private static Registry<BCLBiome> getBclBiomesRegistry(@Nullable RegistryAccess access) {
|
||||
|
|
|
@ -398,12 +398,11 @@ public class BiomeAPI {
|
|||
public static BCLBiome getRenderBiome(Biome biome) {
|
||||
BCLBiome endBiome = InternalBiomeAPI.CLIENT.get(biome);
|
||||
if (endBiome == null) {
|
||||
var reg = BCLBiomeRegistry.registryOrNull();
|
||||
ResourceLocation id = WorldBootstrap.getLastRegistryAccessOrElseBuiltin()
|
||||
.registryOrThrow(Registries.BIOME)
|
||||
.getKey(biome);
|
||||
endBiome = id == null
|
||||
? BCLBiomeRegistry.EMPTY_BIOME
|
||||
: BCLBiomeRegistry.getOrElseEmpty(id);
|
||||
endBiome = BCLBiomeRegistry.getBiomeOrEmpty(id, reg);
|
||||
InternalBiomeAPI.CLIENT.put(biome, endBiome);
|
||||
}
|
||||
return endBiome;
|
||||
|
@ -463,40 +462,6 @@ public class BiomeAPI {
|
|||
.orElse(null);
|
||||
}
|
||||
|
||||
public static ResourceKey getBiomeKey(Holder<Biome> biome) {
|
||||
return biome.unwrapKey().orElse(null);
|
||||
}
|
||||
|
||||
public static ResourceKey getBiomeKeyOrThrow(Holder<Biome> biome) {
|
||||
return biome.unwrapKey().orElseThrow();
|
||||
}
|
||||
|
||||
public static Holder<Biome> getBiomeHolder(BCLBiome biome) {
|
||||
return getBiomeHolder(biome.getBiomeKey());
|
||||
}
|
||||
|
||||
public static Holder<Biome> getBiomeHolder(Biome biome) {
|
||||
Optional<ResourceKey<Biome>> key = Optional.empty();
|
||||
if (InternalBiomeAPI.biomeRegistry != null) {
|
||||
key = InternalBiomeAPI.biomeRegistry.getResourceKey(biome);
|
||||
} else {
|
||||
ResourceKey<Biome> kkey = getBiomeKey(biome);
|
||||
key = kkey == null ? Optional.empty() : Optional.of(kkey);
|
||||
}
|
||||
|
||||
return getBiomeHolder(key.orElseThrow());
|
||||
}
|
||||
|
||||
public static Holder<Biome> getBiomeHolder(ResourceKey<Biome> biomeKey) {
|
||||
if (InternalBiomeAPI.biomeRegistry != null) {
|
||||
return InternalBiomeAPI.biomeRegistry.getHolderOrThrow(biomeKey);
|
||||
}
|
||||
return null;//InternalBiomeAPI.BUILTIN_BIOMES.get(biomeKey).orElse(null);
|
||||
}
|
||||
|
||||
public static Holder<Biome> getBiomeHolder(ResourceLocation biome) {
|
||||
return getBiomeHolder(ResourceKey.create(Registries.BIOME, biome));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get {@link BCLBiome} from given {@link ResourceLocation}.
|
||||
|
@ -505,8 +470,7 @@ public class BiomeAPI {
|
|||
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
|
||||
*/
|
||||
public static BCLBiome getBiome(ResourceLocation biomeID) {
|
||||
if (biomeID == null) return null;
|
||||
return BCLBiomeRegistry.getOrElseEmpty(biomeID);
|
||||
return BCLBiomeRegistry.getBiomeOrEmpty(biomeID, BCLBiomeRegistry.registryOrNull());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,49 +493,23 @@ public class BiomeAPI {
|
|||
return getBiome(BiomeAPI.getBiomeID(biome));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if biome with {@link ResourceLocation} exists in API registry.
|
||||
*
|
||||
* @param biomeID - biome {@link ResourceLocation}.
|
||||
* @return {@code true} if biome exists in API registry and {@code false} if not.
|
||||
*/
|
||||
public static boolean hasBiome(ResourceLocation biomeID) {
|
||||
return BCLBiomeRegistry.get(biomeID) != null;
|
||||
}
|
||||
|
||||
public static Holder<Biome> getFromRegistry(ResourceLocation biomeID) {
|
||||
if (InternalBiomeAPI.biomeRegistry != null)
|
||||
return InternalBiomeAPI.biomeRegistry.getHolder(ResourceKey.create(Registries.BIOME, biomeID))
|
||||
.orElseThrow();
|
||||
return getFromBuiltinRegistry(biomeID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Holder<Biome> getFromRegistry(ResourceKey<Biome> key) {
|
||||
if (InternalBiomeAPI.biomeRegistry != null)
|
||||
return InternalBiomeAPI.biomeRegistry.getHolder(key).orElseThrow();
|
||||
return getFromBuiltinRegistry(key);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Holder<Biome> getFromBuiltinRegistry(ResourceLocation biomeID) {
|
||||
if (WorldBootstrap.getLastRegistryAccess() != null) {
|
||||
var reg = WorldBootstrap.getLastRegistryAccess().registryOrThrow(Registries.BIOME);
|
||||
if (reg.containsKey(biomeID)) {
|
||||
return reg.getHolderOrThrow(ResourceKey.create(Registries.BIOME, biomeID));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Holder<Biome> getFromBuiltinRegistry(ResourceKey<Biome> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDatapackBiome(ResourceLocation biomeID) {
|
||||
return getFromBuiltinRegistry(biomeID) == null;
|
||||
}
|
||||
|
||||
public static boolean wasRegisteredAs(ResourceLocation biomeID, BiomeType dim) {
|
||||
if (BCLBiomeRegistry.isEmptyBiome(biomeID))
|
||||
return false;
|
||||
final BCLBiome res = BCLBiomeRegistry.getOrElseEmpty(biomeID);
|
||||
if (BCLBiomeRegistry.isEmptyBiome(biomeID)) return false;
|
||||
final BCLBiome res = BCLBiomeRegistry.getBiomeOrEmpty(biomeID, BCLBiomeRegistry.registryOrNull());
|
||||
if (res == null) return false;
|
||||
return res.getIntendedType().is(dim);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,6 @@ public class InternalBiomeAPI {
|
|||
|
||||
private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet();
|
||||
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
||||
|
@ -195,8 +194,8 @@ public class InternalBiomeAPI {
|
|||
* @param biomeKey The source biome to wrap
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) {
|
||||
return wrapNativeBiome(biomeKey, -1, type);
|
||||
public static BCLBiome wrapBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) {
|
||||
return wrapBiome(biomeKey, -1, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,15 +206,15 @@ public class InternalBiomeAPI {
|
|||
* @param genChance generation chance. If <0 the default genChance is used
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, float genChance, BiomeAPI.BiomeType type) {
|
||||
return wrapNativeBiome(
|
||||
public static BCLBiome wrapBiome(ResourceKey<Biome> biomeKey, float genChance, BiomeAPI.BiomeType type) {
|
||||
return wrapBiome(
|
||||
biomeKey,
|
||||
genChance < 0 ? null : VanillaBiomeSettings.createVanilla().setGenChance(genChance).build(),
|
||||
type
|
||||
);
|
||||
}
|
||||
|
||||
public static BCLBiome wrapNativeBiome(
|
||||
public static BCLBiome wrapBiome(
|
||||
ResourceKey<Biome> biomeKey,
|
||||
BCLBiome edgeBiome,
|
||||
int edgeBiomeSize,
|
||||
|
@ -226,30 +225,53 @@ public class InternalBiomeAPI {
|
|||
if (genChance >= 0) settings.setGenChance(genChance);
|
||||
settings.setEdge(edgeBiome);
|
||||
settings.setEdgeSize(edgeBiomeSize);
|
||||
return wrapNativeBiome(biomeKey, settings.build(), type);
|
||||
return wrapBiome(biomeKey, settings.build(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a wrapper for a vanilla {@link Biome}.
|
||||
*
|
||||
* @param biomeKey The source biome to wrap
|
||||
* @param setings the {@link VanillaBiomeSettings} to use
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
private static BCLBiome wrapBiome(
|
||||
ResourceKey<Biome> biomeKey,
|
||||
VanillaBiomeSettings setings,
|
||||
BiomeAPI.BiomeType type
|
||||
) {
|
||||
final Registry<BCLBiome> reg = BCLBiomeRegistry.registryOrNull();
|
||||
if (BCLBiomeRegistry.hasBiome(biomeKey, reg)) {
|
||||
return BCLBiomeRegistry.getBiome(biomeKey, reg);
|
||||
}
|
||||
|
||||
BCLBiome bclBiome = new BCLBiome(biomeKey, setings);
|
||||
bclBiome._setIntendedType(type);
|
||||
|
||||
registerBuiltinBiome(bclBiome);
|
||||
return bclBiome;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} wrapper for {@link Biome}.
|
||||
* After that biome will be added to BCLib End Biome Generator and into Fabric Biome API as a land biome (will generate only on islands).
|
||||
*
|
||||
* @param biomeKey The source biome to wrap
|
||||
* @param setings the {@link VanillaBiomeSettings} to use
|
||||
* @return {@link BCLBiome}
|
||||
*/
|
||||
private static BCLBiome wrapNativeBiome(
|
||||
ResourceKey<Biome> biomeKey,
|
||||
VanillaBiomeSettings setings,
|
||||
BiomeAPI.BiomeType type
|
||||
) {
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(biomeKey.location());
|
||||
if (BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
bclBiome = new BCLBiome(biomeKey, setings);
|
||||
bclBiome._setIntendedType(type);
|
||||
public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) {
|
||||
final Registry<BCLBiome> reg = BCLBiomeRegistry.registryOrNull();
|
||||
if (!BCLBiomeRegistry.hasBiome(biomeKey, reg)) {
|
||||
BCLBiome bclBiome = wrapBiome(biomeKey, type);
|
||||
BCLBiomeRegistry.register(bclBiome);
|
||||
registerBuiltinBiome(bclBiome);
|
||||
return bclBiome;
|
||||
} else {
|
||||
return BCLBiomeRegistry.getBiome(biomeKey, reg);
|
||||
}
|
||||
|
||||
registerBuiltinBiome(bclBiome);
|
||||
return bclBiome;
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Objects;
|
|||
class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
|
||||
private final BCLBiome parentBiome;
|
||||
private final BCLBiomeBuilder.BuildCompletion supplier;
|
||||
private BCLBiomeContainer<T> registered;
|
||||
|
||||
UnboundBCLBiome(T biome, BCLBiome parentBiome, BCLBiomeBuilder.BuildCompletion supplier) {
|
||||
super(biome);
|
||||
|
@ -18,6 +19,7 @@ class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
|
|||
|
||||
@Override
|
||||
public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext, BiomeAPI.BiomeType dim) {
|
||||
if (registered != null) return registered;
|
||||
if (dim == null) dim = BiomeAPI.BiomeType.NONE;
|
||||
|
||||
biome._setBiomeToRegister(this.supplier.apply(bootstrapContext));
|
||||
|
@ -38,7 +40,8 @@ class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
|
|||
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim);
|
||||
}
|
||||
|
||||
return new BCLBiomeContainer<>(this.biome);
|
||||
registered = new BCLBiomeContainer<>(this.biome);
|
||||
return registered;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,11 +2,9 @@ package org.betterx.datagen.bclib.worldgen;
|
|||
|
||||
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.InternalBiomeAPI;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
|
||||
public class VanillaBCLBiomesDataProvider {
|
||||
private static boolean didBootstrap = false;
|
||||
|
@ -23,82 +21,37 @@ public class VanillaBCLBiomesDataProvider {
|
|||
public static BCLBiome bootstrap(Registry<BCLBiome> reg) {
|
||||
if (didBootstrap) return BCLBiomeRegistry.EMPTY_BIOME;
|
||||
didBootstrap = true;
|
||||
|
||||
final BCLBiome NETHER_WASTES_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.NETHER_WASTES,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome CRIMSON_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.CRIMSON_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome WARPED_FOREST_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.WARPED_FOREST,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome SOUL_SAND_VALLEY_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SOUL_SAND_VALLEY,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
final BCLBiome BASALT_DELTAS_BIOME = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.BASALT_DELTAS,
|
||||
InternalBiomeAPI.OTHER_NETHER
|
||||
);
|
||||
|
||||
|
||||
final BCLBiome END_MIDLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_MIDLANDS,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
final BCLBiome END_HIGHLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_HIGHLANDS,
|
||||
END_MIDLANDS,
|
||||
8,
|
||||
0.5F,
|
||||
InternalBiomeAPI.OTHER_END_LAND
|
||||
);
|
||||
|
||||
|
||||
final BCLBiome END_BARRENS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.END_BARRENS,
|
||||
InternalBiomeAPI.OTHER_END_BARRENS
|
||||
);
|
||||
|
||||
final BCLBiome SMALL_END_ISLANDS = InternalBiomeAPI.wrapNativeBiome(
|
||||
Biomes.SMALL_END_ISLANDS,
|
||||
InternalBiomeAPI.OTHER_END_VOID
|
||||
);
|
||||
Registry.register(reg, SMALL_END_ISLANDS.getBCLBiomeKey(), SMALL_END_ISLANDS);
|
||||
Registry.register(reg, END_BARRENS.getBCLBiomeKey(), END_BARRENS);
|
||||
Registry.register(reg, END_HIGHLANDS.getBCLBiomeKey(), END_HIGHLANDS);
|
||||
Registry.register(reg, END_MIDLANDS.getBCLBiomeKey(), END_MIDLANDS);
|
||||
Registry.register(reg, BCLBiomeRegistry.SMALL_END_ISLANDS.getBCLBiomeKey(), BCLBiomeRegistry.SMALL_END_ISLANDS);
|
||||
Registry.register(reg, BCLBiomeRegistry.END_BARRENS.getBCLBiomeKey(), BCLBiomeRegistry.END_BARRENS);
|
||||
Registry.register(reg, BCLBiomeRegistry.END_HIGHLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_HIGHLANDS);
|
||||
Registry.register(reg, BCLBiomeRegistry.END_MIDLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_MIDLANDS);
|
||||
Registry.register(reg, BCLBiomeRegistry.THE_END.getBCLBiomeKey(), BCLBiomeRegistry.THE_END);
|
||||
Registry.register(
|
||||
reg,
|
||||
BASALT_DELTAS_BIOME.getBCLBiomeKey(),
|
||||
BASALT_DELTAS_BIOME
|
||||
BCLBiomeRegistry.BASALT_DELTAS_BIOME.getBCLBiomeKey(),
|
||||
BCLBiomeRegistry.BASALT_DELTAS_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
|
||||
SOUL_SAND_VALLEY_BIOME
|
||||
BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
|
||||
BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
WARPED_FOREST_BIOME.getBCLBiomeKey(),
|
||||
WARPED_FOREST_BIOME
|
||||
BCLBiomeRegistry.WARPED_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BCLBiomeRegistry.WARPED_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
|
||||
CRIMSON_FOREST_BIOME
|
||||
BCLBiomeRegistry.CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
|
||||
BCLBiomeRegistry.CRIMSON_FOREST_BIOME
|
||||
);
|
||||
Registry.register(
|
||||
reg,
|
||||
NETHER_WASTES_BIOME.getBCLBiomeKey(),
|
||||
NETHER_WASTES_BIOME
|
||||
BCLBiomeRegistry.NETHER_WASTES_BIOME.getBCLBiomeKey(),
|
||||
BCLBiomeRegistry.NETHER_WASTES_BIOME
|
||||
);
|
||||
return Registry.register(reg, BCLBiomeRegistry.EMPTY_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.EMPTY_BIOME);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ accessible method net/minecraft/world/level/levelgen/NoiseRouterData nether (Lne
|
|||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData noNewCaves (Lnet/minecraft/core/HolderGetter;Lnet/minecraft/core/HolderGetter;Lnet/minecraft/world/level/levelgen/DensityFunction;)Lnet/minecraft/world/level/levelgen/NoiseRouter;
|
||||
accessible method net/minecraft/world/level/levelgen/NoiseRouterData slideNetherLike (Lnet/minecraft/core/HolderGetter;II)Lnet/minecraft/world/level/levelgen/DensityFunction;
|
||||
accessible method net/minecraft/tags/TagEntry elementOrTag ()Lnet/minecraft/util/ExtraCodecs$TagOrElementLocation;
|
||||
accessible method net/minecraft/data/worldgen/biome/OverworldBiomes calculateSkyColor (F)I
|
||||
|
||||
#Fields
|
||||
accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map;
|
Loading…
Reference in a new issue