Refactored BiomeRegistry and BiomeBuilder

This commit is contained in:
Frank 2022-12-03 13:06:36 +01:00
parent 78c1df618a
commit 0204c5fb73
7 changed files with 200 additions and 192 deletions

View file

@ -17,6 +17,7 @@ import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BiomeDefaultFeatures; import net.minecraft.data.worldgen.BiomeDefaultFeatures;
import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.data.worldgen.biome.OverworldBiomes;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.Music; import net.minecraft.sounds.Music;
@ -49,6 +50,17 @@ 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<>();
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 @FunctionalInterface
public interface BiomeSupplier<T> extends BiFunction<ResourceKey<Biome>, BCLBiomeSettings, T> { public interface BiomeSupplier<T> extends BiFunction<ResourceKey<Biome>, BCLBiomeSettings, T> {
@ -916,7 +928,7 @@ public class BCLBiomeBuilder {
//res.setSurface(surfaceRule); //res.setSurface(surfaceRule);
//carvers.forEach(cfg -> BiomeAPI.addBiomeCarver(biome, cfg.second, cfg.first)); //carvers.forEach(cfg -> BiomeAPI.addBiomeCarver(biome, cfg.second, cfg.first));
return new UnboundBCLBiome<>( final UnboundBCLBiome<T> unbound = new UnboundBCLBiome<>(
res, res,
parent, parent,
ctx -> { ctx -> {
@ -925,5 +937,12 @@ public class BCLBiomeBuilder {
return builder.generationSettings(fixGenerationSettings(genBuilder.build())).build(); 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();
} }
} }

View file

@ -16,6 +16,8 @@ import net.minecraft.util.KeyDispatchDataCodec;
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.Biomes;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable; 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 EMPTY_BIOME = new BCLBiome(Biomes.THE_VOID.location());
public static final BCLBiome THE_END = new BCLBiome(Biomes.THE_END.location(), InternalBiomeAPI.OTHER_END_CENTER); public static final BCLBiome THE_END = InternalBiomeAPI.wrapBiome(
// InternalBiomeAPI.wrapNativeBiome( Biomes.THE_END,
// Biomes.THE_END, InternalBiomeAPI.OTHER_END_CENTER
// 0.5F, );
// 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);
@ -98,19 +146,46 @@ public class BCLBiomeRegistry {
} }
public static boolean hasBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) { 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 true;
} }
return BUILTIN_BCL_BIOMES.containsKey(key.location()); return BUILTIN_BCL_BIOMES.containsKey(loc);
} }
public static BCLBiome getBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) { public static BCLBiome getBiome(ResourceKey<Biome> key, Registry<BCLBiome> bclBiomes) {
if (bclBiomes != null && bclBiomes.containsKey(key.location())) { return getBiome(key.location(), bclBiomes);
return bclBiomes.get(key.location()); }
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) { 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()); return Registry.register(registry, BCLib.makeID("biome"), BCLBiome.KEY_CODEC.codec());
} }
public static BCLBiome get(ResourceLocation loc) { public static Registry<BCLBiome> registryOrNull() {
return get(WorldBootstrap.getLastRegistryAccess(), loc); if (WorldBootstrap.getLastRegistryAccess() == null) return null;
} return WorldBootstrap.getLastRegistryAccess().registry(BCL_BIOMES_REGISTRY).orElse(null);
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 Stream<ResourceKey<BCLBiome>> getAll(BiomeAPI.BiomeType dim) { 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) { if (BUILTIN_BCL_BIOMES != null) {
return getBclBiomesRegistry(access) BUILTIN_BCL_BIOMES
.entrySet() .entrySet()
.stream() .stream()
.filter(e -> e.getValue().getIntendedType().is(dim)) .filter(e -> e.getValue().getIntendedType().is(dim))
.map(e -> e.getKey()); .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) { private static Registry<BCLBiome> getBclBiomesRegistry(@Nullable RegistryAccess access) {

View file

@ -398,12 +398,11 @@ public class BiomeAPI {
public static BCLBiome getRenderBiome(Biome biome) { public static BCLBiome getRenderBiome(Biome biome) {
BCLBiome endBiome = InternalBiomeAPI.CLIENT.get(biome); BCLBiome endBiome = InternalBiomeAPI.CLIENT.get(biome);
if (endBiome == null) { if (endBiome == null) {
var reg = BCLBiomeRegistry.registryOrNull();
ResourceLocation id = WorldBootstrap.getLastRegistryAccessOrElseBuiltin() ResourceLocation id = WorldBootstrap.getLastRegistryAccessOrElseBuiltin()
.registryOrThrow(Registries.BIOME) .registryOrThrow(Registries.BIOME)
.getKey(biome); .getKey(biome);
endBiome = id == null endBiome = BCLBiomeRegistry.getBiomeOrEmpty(id, reg);
? BCLBiomeRegistry.EMPTY_BIOME
: BCLBiomeRegistry.getOrElseEmpty(id);
InternalBiomeAPI.CLIENT.put(biome, endBiome); InternalBiomeAPI.CLIENT.put(biome, endBiome);
} }
return endBiome; return endBiome;
@ -463,40 +462,6 @@ public class BiomeAPI {
.orElse(null); .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}. * Get {@link BCLBiome} from given {@link ResourceLocation}.
@ -505,8 +470,7 @@ public class BiomeAPI {
* @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}. * @return {@link BCLBiome} or {@code BiomeAPI.EMPTY_BIOME}.
*/ */
public static BCLBiome getBiome(ResourceLocation biomeID) { public static BCLBiome getBiome(ResourceLocation biomeID) {
if (biomeID == null) return null; return BCLBiomeRegistry.getBiomeOrEmpty(biomeID, BCLBiomeRegistry.registryOrNull());
return BCLBiomeRegistry.getOrElseEmpty(biomeID);
} }
/** /**
@ -529,49 +493,23 @@ public class BiomeAPI {
return getBiome(BiomeAPI.getBiomeID(biome)); 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) { public static Holder<Biome> getFromRegistry(ResourceLocation biomeID) {
if (InternalBiomeAPI.biomeRegistry != null) if (InternalBiomeAPI.biomeRegistry != null)
return InternalBiomeAPI.biomeRegistry.getHolder(ResourceKey.create(Registries.BIOME, biomeID)) return InternalBiomeAPI.biomeRegistry.getHolder(ResourceKey.create(Registries.BIOME, biomeID))
.orElseThrow(); .orElseThrow();
return getFromBuiltinRegistry(biomeID);
}
@Nullable if (WorldBootstrap.getLastRegistryAccess() != null) {
public static Holder<Biome> getFromRegistry(ResourceKey<Biome> key) { var reg = WorldBootstrap.getLastRegistryAccess().registryOrThrow(Registries.BIOME);
if (InternalBiomeAPI.biomeRegistry != null) if (reg.containsKey(biomeID)) {
return InternalBiomeAPI.biomeRegistry.getHolder(key).orElseThrow(); return reg.getHolderOrThrow(ResourceKey.create(Registries.BIOME, biomeID));
return getFromBuiltinRegistry(key); }
} }
@Nullable
public static Holder<Biome> getFromBuiltinRegistry(ResourceLocation biomeID) {
return null; 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) { public static boolean wasRegisteredAs(ResourceLocation biomeID, BiomeType dim) {
if (BCLBiomeRegistry.isEmptyBiome(biomeID)) if (BCLBiomeRegistry.isEmptyBiome(biomeID)) return false;
return false; final BCLBiome res = BCLBiomeRegistry.getBiomeOrEmpty(biomeID, BCLBiomeRegistry.registryOrNull());
final BCLBiome res = BCLBiomeRegistry.getOrElseEmpty(biomeID);
if (res == null) return false; if (res == null) return false;
return res.getIntendedType().is(dim); return res.getIntendedType().is(dim);
} }

View file

@ -187,7 +187,6 @@ public class InternalBiomeAPI {
private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet(); private static final Set<ResourceLocation> BIOMES_TO_SORT = Sets.newHashSet();
/** /**
* Register {@link BCLBiome} wrapper for {@link Biome}. * 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). * 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 * @param biomeKey The source biome to wrap
* @return {@link BCLBiome} * @return {@link BCLBiome}
*/ */
public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) { public static BCLBiome wrapBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) {
return wrapNativeBiome(biomeKey, -1, type); return wrapBiome(biomeKey, -1, type);
} }
/** /**
@ -207,15 +206,15 @@ public class InternalBiomeAPI {
* @param genChance generation chance. If &lt;0 the default genChance is used * @param genChance generation chance. If &lt;0 the default genChance is used
* @return {@link BCLBiome} * @return {@link BCLBiome}
*/ */
public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, float genChance, BiomeAPI.BiomeType type) { public static BCLBiome wrapBiome(ResourceKey<Biome> biomeKey, float genChance, BiomeAPI.BiomeType type) {
return wrapNativeBiome( return wrapBiome(
biomeKey, biomeKey,
genChance < 0 ? null : VanillaBiomeSettings.createVanilla().setGenChance(genChance).build(), genChance < 0 ? null : VanillaBiomeSettings.createVanilla().setGenChance(genChance).build(),
type type
); );
} }
public static BCLBiome wrapNativeBiome( public static BCLBiome wrapBiome(
ResourceKey<Biome> biomeKey, ResourceKey<Biome> biomeKey,
BCLBiome edgeBiome, BCLBiome edgeBiome,
int edgeBiomeSize, int edgeBiomeSize,
@ -226,30 +225,53 @@ public class InternalBiomeAPI {
if (genChance >= 0) settings.setGenChance(genChance); if (genChance >= 0) settings.setGenChance(genChance);
settings.setEdge(edgeBiome); settings.setEdge(edgeBiome);
settings.setEdgeSize(edgeBiomeSize); 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}. * 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). * 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 biomeKey The source biome to wrap
* @param setings the {@link VanillaBiomeSettings} to use
* @return {@link BCLBiome} * @return {@link BCLBiome}
*/ */
private static BCLBiome wrapNativeBiome( public static BCLBiome wrapNativeBiome(ResourceKey<Biome> biomeKey, BiomeAPI.BiomeType type) {
ResourceKey<Biome> biomeKey, final Registry<BCLBiome> reg = BCLBiomeRegistry.registryOrNull();
VanillaBiomeSettings setings, if (!BCLBiomeRegistry.hasBiome(biomeKey, reg)) {
BiomeAPI.BiomeType type BCLBiome bclBiome = wrapBiome(biomeKey, type);
) { BCLBiomeRegistry.register(bclBiome);
BCLBiome bclBiome = BiomeAPI.getBiome(biomeKey.location()); registerBuiltinBiome(bclBiome);
if (BCLBiomeRegistry.isEmptyBiome(bclBiome)) { return bclBiome;
bclBiome = new BCLBiome(biomeKey, setings); } else {
bclBiome._setIntendedType(type); return BCLBiomeRegistry.getBiome(biomeKey, reg);
} }
registerBuiltinBiome(bclBiome);
return bclBiome;
} }
static { static {

View file

@ -8,6 +8,7 @@ import java.util.Objects;
class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> { class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
private final BCLBiome parentBiome; private final BCLBiome parentBiome;
private final BCLBiomeBuilder.BuildCompletion supplier; private final BCLBiomeBuilder.BuildCompletion supplier;
private BCLBiomeContainer<T> registered;
UnboundBCLBiome(T biome, BCLBiome parentBiome, BCLBiomeBuilder.BuildCompletion supplier) { UnboundBCLBiome(T biome, BCLBiome parentBiome, BCLBiomeBuilder.BuildCompletion supplier) {
super(biome); super(biome);
@ -18,6 +19,7 @@ class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
@Override @Override
public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext, BiomeAPI.BiomeType dim) { public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext, BiomeAPI.BiomeType dim) {
if (registered != null) return registered;
if (dim == null) dim = BiomeAPI.BiomeType.NONE; if (dim == null) dim = BiomeAPI.BiomeType.NONE;
biome._setBiomeToRegister(this.supplier.apply(bootstrapContext)); biome._setBiomeToRegister(this.supplier.apply(bootstrapContext));
@ -38,7 +40,8 @@ class UnboundBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim); BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim);
} }
return new BCLBiomeContainer<>(this.biome); registered = new BCLBiomeContainer<>(this.biome);
return registered;
} }
@Override @Override

View file

@ -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.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.InternalBiomeAPI;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.biome.Biomes;
public class VanillaBCLBiomesDataProvider { public class VanillaBCLBiomesDataProvider {
private static boolean didBootstrap = false; private static boolean didBootstrap = false;
@ -23,82 +21,37 @@ public class VanillaBCLBiomesDataProvider {
public static BCLBiome bootstrap(Registry<BCLBiome> reg) { public static BCLBiome bootstrap(Registry<BCLBiome> reg) {
if (didBootstrap) return BCLBiomeRegistry.EMPTY_BIOME; if (didBootstrap) return BCLBiomeRegistry.EMPTY_BIOME;
didBootstrap = true; 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( Registry.register(reg, BCLBiomeRegistry.SMALL_END_ISLANDS.getBCLBiomeKey(), BCLBiomeRegistry.SMALL_END_ISLANDS);
Biomes.END_MIDLANDS, Registry.register(reg, BCLBiomeRegistry.END_BARRENS.getBCLBiomeKey(), BCLBiomeRegistry.END_BARRENS);
0.5F, Registry.register(reg, BCLBiomeRegistry.END_HIGHLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_HIGHLANDS);
InternalBiomeAPI.OTHER_END_LAND Registry.register(reg, BCLBiomeRegistry.END_MIDLANDS.getBCLBiomeKey(), BCLBiomeRegistry.END_MIDLANDS);
);
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.THE_END.getBCLBiomeKey(), BCLBiomeRegistry.THE_END); Registry.register(reg, BCLBiomeRegistry.THE_END.getBCLBiomeKey(), BCLBiomeRegistry.THE_END);
Registry.register( Registry.register(
reg, reg,
BASALT_DELTAS_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.BASALT_DELTAS_BIOME.getBCLBiomeKey(),
BASALT_DELTAS_BIOME BCLBiomeRegistry.BASALT_DELTAS_BIOME
); );
Registry.register( Registry.register(
reg, reg,
SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME.getBCLBiomeKey(),
SOUL_SAND_VALLEY_BIOME BCLBiomeRegistry.SOUL_SAND_VALLEY_BIOME
); );
Registry.register( Registry.register(
reg, reg,
WARPED_FOREST_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.WARPED_FOREST_BIOME.getBCLBiomeKey(),
WARPED_FOREST_BIOME BCLBiomeRegistry.WARPED_FOREST_BIOME
); );
Registry.register( Registry.register(
reg, reg,
CRIMSON_FOREST_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.CRIMSON_FOREST_BIOME.getBCLBiomeKey(),
CRIMSON_FOREST_BIOME BCLBiomeRegistry.CRIMSON_FOREST_BIOME
); );
Registry.register( Registry.register(
reg, reg,
NETHER_WASTES_BIOME.getBCLBiomeKey(), BCLBiomeRegistry.NETHER_WASTES_BIOME.getBCLBiomeKey(),
NETHER_WASTES_BIOME BCLBiomeRegistry.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);
} }

View file

@ -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 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/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/tags/TagEntry elementOrTag ()Lnet/minecraft/util/ExtraCodecs$TagOrElementLocation;
accessible method net/minecraft/data/worldgen/biome/OverworldBiomes calculateSkyColor (F)I
#Fields #Fields
accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map; accessible field net/minecraft/world/entity/ai/village/poi/PoiTypes TYPE_BY_STATE Ljava/util/Map;