[Changes] Adapted BCLBiomeBuilder
for DataGen pass
This commit is contained in:
parent
271c974929
commit
2aa445d9e0
8 changed files with 173 additions and 209 deletions
|
@ -145,7 +145,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
final BCLBiome bclBiome;
|
||||
if (!BiomeAPI.hasBiome(biomeID)) {
|
||||
bclBiome = new BCLBiome(biomeID, biome.value(), BiomeAPI.BiomeType.END_LAND);
|
||||
bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.END_LAND);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
} else {
|
||||
bclBiome = BiomeAPI.getBiome(biomeID);
|
||||
|
|
|
@ -108,7 +108,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
return;
|
||||
}
|
||||
if (!BiomeAPI.hasBiome(biomeID)) {
|
||||
BCLBiome bclBiome = new BCLBiome(biomeID, biome.value(), BiomeAPI.BiomeType.NETHER);
|
||||
BCLBiome bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.NETHER);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
biomePicker.addBiome(bclBiome);
|
||||
} else {
|
||||
|
|
|
@ -153,7 +153,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
private final Map<String, Object> customData = Maps.newHashMap();
|
||||
private final ResourceLocation biomeID;
|
||||
private final ResourceKey<Biome> biomeKey;
|
||||
final Biome biomeToRegister;
|
||||
|
||||
protected final List<Climate.ParameterPoint> parameterPoints = Lists.newArrayList();
|
||||
|
||||
|
@ -174,7 +173,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
Optional<String> intendedType
|
||||
) {
|
||||
super(terrainHeight, fogDensity, genChance, edgeSize, vertical, edge.map(BiomeAPI::getBiome).orElse(null));
|
||||
biomeToRegister = null;
|
||||
this.biomeID = biomeID;
|
||||
this.biomeKey = ResourceKey.create(Registries.BIOME, biomeID);
|
||||
this.biomeParent = biomeParent.orElse(null);
|
||||
|
@ -200,42 +198,17 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
this(ResourceKey.create(Registries.BIOME, biomeID), null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
||||
* Create wrapper for existing biome.
|
||||
*
|
||||
* @param biomeToRegister {@link Biome} to wrap.
|
||||
* @param settings The Settings for this Biome or {@code null} if you want to apply default settings
|
||||
* @param biomeID Teh ResoureLocation for this Biome
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
BCLBiome(Biome biomeToRegister, VanillaBiomeSettings settings) {
|
||||
this(BiomeAPI.getBiomeID(biomeToRegister), biomeToRegister, settings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create wrapper for existing biome using biome instance from {@link BuiltinRegistries}.
|
||||
*
|
||||
* @param biomeToRegister {@link Biome} to wrap.
|
||||
* @param biomeID Teh ResoureLocation for this Biome
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public BCLBiome(ResourceLocation biomeID, Biome biomeToRegister, BiomeAPI.BiomeType type) {
|
||||
this(biomeID, biomeToRegister, (BCLBiomeSettings) null);
|
||||
public BCLBiome(ResourceLocation biomeID, BiomeAPI.BiomeType type) {
|
||||
this(ResourceKey.create(Registries.BIOME, biomeID), (BCLBiomeSettings) null);
|
||||
setIntendedType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Biome
|
||||
*
|
||||
* @param biomeID {@link ResourceLocation} biome ID.
|
||||
* @param biomeToRegister {@link Biome} to wrap.
|
||||
* @param defaults The Settings for this Biome or null if you want to apply the defaults
|
||||
*/
|
||||
protected BCLBiome(ResourceLocation biomeID, Biome biomeToRegister, BCLBiomeSettings defaults) {
|
||||
this(ResourceKey.create(Registries.BIOME, biomeID), biomeToRegister, defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Biome
|
||||
*
|
||||
|
@ -243,18 +216,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
* @param defaults The Settings for this Biome or null if you want to apply the defaults
|
||||
*/
|
||||
protected BCLBiome(ResourceKey<Biome> biomeKey, BCLBiomeSettings defaults) {
|
||||
this(biomeKey, null, defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Biome
|
||||
*
|
||||
* @param biomeKey {@link ResourceKey<Biome>} of the wrapped Biome
|
||||
* @param biomeToRegister The biome you want to use when this instance gets registered through the {@link BiomeAPI}
|
||||
* @param defaults The Settings for this Biome or null if you want to apply the defaults
|
||||
*/
|
||||
protected BCLBiome(ResourceKey<Biome> biomeKey, Biome biomeToRegister, BCLBiomeSettings defaults) {
|
||||
this.biomeToRegister = biomeToRegister;
|
||||
this.biomeID = biomeKey.location();
|
||||
this.biomeKey = biomeKey;
|
||||
|
||||
|
@ -354,15 +315,6 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
return subbiomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for a random sub-biome from all existing sub-biomes. Will return biome itself if there are no sub-biomes.
|
||||
*
|
||||
* @param random {@link Random}.
|
||||
* @return {@link BCLBiome}.
|
||||
*/
|
||||
// public BCLBiome getSubBiome(WorldgenRandom random) {
|
||||
// return getSubBiomes().get(random);
|
||||
// }
|
||||
public void forEachSubBiome(BiConsumer<BCLBiome, Float> consumer) {
|
||||
final WeightedList<BCLBiome> subbiomes = getSubBiomes();
|
||||
for (int i = 0; i < subbiomes.size(); i++)
|
||||
|
@ -477,4 +429,22 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
|
|||
boolean allowFabricRegistration() {
|
||||
return !isEdgeBiome();
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
private Biome biomeToRegister;
|
||||
|
||||
@ApiStatus.Internal
|
||||
void _setBiomeToRegister(Biome b) {
|
||||
this.biomeToRegister = b;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
Biome _getBiomeToRegister() {
|
||||
return this.biomeToRegister;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
boolean _hasBiomeToRegister() {
|
||||
return this.biomeToRegister != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.betterx.bclib.entity.BCLEntityWrapper;
|
|||
import org.betterx.bclib.mixin.common.BiomeGenerationSettingsAccessor;
|
||||
import org.betterx.bclib.util.CollectionsUtil;
|
||||
import org.betterx.bclib.util.Pair;
|
||||
import org.betterx.bclib.util.TriFunction;
|
||||
import org.betterx.ui.ColorUtil;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
@ -45,97 +44,89 @@ import com.google.common.collect.Lists;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
public record Context(BootstapContext<Biome> bootstrapContext) {
|
||||
public BCLBiomeBuilder start(ResourceLocation biomeID) {
|
||||
return BCLBiomeBuilder.start(this, biomeID);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class PreparedBiome<T extends BCLBiome> {
|
||||
private final T biome;
|
||||
private final Context context;
|
||||
public static class UnregisteredBCLBiome<T extends BCLBiome> extends BCLBiomeContainer<T> {
|
||||
private final BCLBiome parentBiome;
|
||||
private final BuildCompletion supplier;
|
||||
|
||||
private PreparedBiome(T biome, Context context) {
|
||||
this.biome = biome;
|
||||
this.context = context;
|
||||
private UnregisteredBCLBiome(T biome, BCLBiome parentBiome, BuildCompletion supplier) {
|
||||
super(biome);
|
||||
this.parentBiome = parentBiome;
|
||||
this.supplier = supplier;
|
||||
}
|
||||
|
||||
public T registerEndLandBiome() {
|
||||
BiomeAPI.registerEndLandBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
|
||||
@Override
|
||||
public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext, BiomeAPI.BiomeType dim) {
|
||||
if (dim == null) dim = BiomeAPI.BiomeType.NONE;
|
||||
|
||||
biome._setBiomeToRegister(this.supplier.apply(bootstrapContext));
|
||||
|
||||
if (dim.is(BiomeAPI.BiomeType.END_LAND)) {
|
||||
BiomeAPI.registerEndLandBiome(bootstrapContext, biome);
|
||||
} else if (dim.is(BiomeAPI.BiomeType.END_VOID)) {
|
||||
BiomeAPI.registerEndVoidBiome(bootstrapContext, biome);
|
||||
} else if (dim.is(BiomeAPI.BiomeType.END_BARRENS)) {
|
||||
BiomeAPI.registerEndBarrensBiome(bootstrapContext, parentBiome, biome);
|
||||
} else if (dim.is(BiomeAPI.BiomeType.END_CENTER)) {
|
||||
BiomeAPI.registerEndCenterBiome(bootstrapContext, biome);
|
||||
} else if (dim.is(BiomeAPI.BiomeType.NETHER)) {
|
||||
BiomeAPI.registerNetherBiome(bootstrapContext, biome);
|
||||
} else if (hasParent()) {
|
||||
BiomeAPI.registerSubBiome(bootstrapContext, parentBiome, biome, dim);
|
||||
} else {
|
||||
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(bootstrapContext, biome, dim);
|
||||
}
|
||||
|
||||
return new BCLBiomeContainer<>(this.biome);
|
||||
}
|
||||
|
||||
public T registerEndVoidBiome() {
|
||||
BiomeAPI.registerEndVoidBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerEndBarrensBiome(BCLBiome highlandBiome) {
|
||||
BiomeAPI.registerEndBarrensBiome(context.bootstrapContext, highlandBiome, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerEndCenterBiome() {
|
||||
BiomeAPI.registerEndCenterBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerNetherBiome() {
|
||||
BiomeAPI.registerNetherBiome(context.bootstrapContext, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerSubBiome(BCLBiome parent) {
|
||||
BiomeAPI.registerSubBiome(context.bootstrapContext, parent, biome);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T registerSubBiome(BCLBiome parent, BiomeAPI.BiomeType dim) {
|
||||
BiomeAPI.registerSubBiome(context.bootstrapContext, parent, biome, dim);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public T register(BiomeAPI.BiomeType dim) {
|
||||
BiomeAPI.registerBuiltinBiomeAndOverrideIntendedDimension(context.bootstrapContext, biome, dim);
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
public BCLBiome biome() {
|
||||
public T biome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
public Context context() {
|
||||
return context;
|
||||
public boolean hasParent() {
|
||||
return parentBiome != null;
|
||||
}
|
||||
|
||||
public BCLBiome parentBiome() {
|
||||
return parentBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
PreparedBiome that = (PreparedBiome) obj;
|
||||
return Objects.equals(this.biome, that.biome) &&
|
||||
Objects.equals(this.context, that.context);
|
||||
UnregisteredBCLBiome<?> that = (UnregisteredBCLBiome<?>) obj;
|
||||
return Objects.equals(this.biome, that.biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(biome, context);
|
||||
return Objects.hash(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Registry[" +
|
||||
"biome=" + biome + ", " +
|
||||
"context=" + context + ']';
|
||||
return "UnregisteredBiome[" + "biome=" + biome + ']';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BiomeSupplier<T> extends TriFunction<ResourceLocation, Biome, BCLBiomeSettings, T> {
|
||||
public interface BiomeSupplier<T> extends BiFunction<ResourceKey<Biome>, BCLBiomeSettings, T> {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface FeatureSupplier extends Consumer<BiomeGenerationSettings.Builder> {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface BuildCompletion extends Function<BootstapContext<Biome>, Biome> {
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +136,7 @@ public class BCLBiomeBuilder {
|
|||
-0.012
|
||||
);
|
||||
|
||||
private final List<FeatureSupplier> featureSupliers = new LinkedList<>();
|
||||
private final List<Pair<GenerationStep.Carving, Holder<? extends ConfiguredWorldCarver<?>>>> carvers = new ArrayList<>(
|
||||
1);
|
||||
private BiomeGenerationSettings.Builder generationSettings;
|
||||
|
@ -153,7 +145,7 @@ public class BCLBiomeBuilder {
|
|||
private SurfaceRules.RuleSource surfaceRule;
|
||||
private Precipitation precipitation;
|
||||
private ResourceLocation biomeID;
|
||||
private Context builderContext;
|
||||
|
||||
|
||||
private final Set<TagKey<Biome>> tags = Sets.newHashSet();
|
||||
|
||||
|
@ -166,6 +158,7 @@ public class BCLBiomeBuilder {
|
|||
private float height;
|
||||
private int edgeSize;
|
||||
private BCLBiome edge;
|
||||
private BCLBiome parent;
|
||||
private boolean vertical;
|
||||
|
||||
private BiomeAPI.BiomeType biomeType;
|
||||
|
@ -177,8 +170,7 @@ public class BCLBiomeBuilder {
|
|||
* @param biomeID {@link ResourceLocation} biome identifier.
|
||||
* @return prepared {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
private static BCLBiomeBuilder start(
|
||||
Context ctx,
|
||||
public static BCLBiomeBuilder start(
|
||||
ResourceLocation biomeID
|
||||
) {
|
||||
INSTANCE.biomeID = biomeID;
|
||||
|
@ -194,11 +186,12 @@ public class BCLBiomeBuilder {
|
|||
INSTANCE.height = 0.1F;
|
||||
INSTANCE.vertical = false;
|
||||
INSTANCE.edge = null;
|
||||
INSTANCE.parent = null;
|
||||
INSTANCE.carvers.clear();
|
||||
INSTANCE.parameters.clear();
|
||||
INSTANCE.tags.clear();
|
||||
INSTANCE.biomeType = null;
|
||||
INSTANCE.builderContext = ctx;
|
||||
INSTANCE.featureSupliers.clear();
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -207,6 +200,11 @@ public class BCLBiomeBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public BCLBiomeBuilder setParent(BCLBiome parent) {
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type for this Biome. If the type was set, the Biome can be registered.
|
||||
*
|
||||
|
@ -612,7 +610,12 @@ public class BCLBiomeBuilder {
|
|||
* @param soundPositionOffset offset in sound.
|
||||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder mood(Holder<SoundEvent> mood, int tickDelay, int blockSearchExtent, float soundPositionOffset) {
|
||||
public BCLBiomeBuilder mood(
|
||||
Holder<SoundEvent> mood,
|
||||
int tickDelay,
|
||||
int blockSearchExtent,
|
||||
float soundPositionOffset
|
||||
) {
|
||||
getEffects().ambientMoodSound(new AmbientMoodSettings(mood, tickDelay, blockSearchExtent, soundPositionOffset));
|
||||
return this;
|
||||
}
|
||||
|
@ -657,7 +660,7 @@ public class BCLBiomeBuilder {
|
|||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder feature(Decoration decoration, Holder<PlacedFeature> feature) {
|
||||
getGeneration().addFeature(decoration, feature);
|
||||
featureSupliers.add(gen -> gen.addFeature(decoration, feature));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -686,7 +689,7 @@ public class BCLBiomeBuilder {
|
|||
* @return same {@link BCLBiomeBuilder} instance.
|
||||
*/
|
||||
public BCLBiomeBuilder feature(Consumer<BiomeGenerationSettings.Builder> featureAdd) {
|
||||
featureAdd.accept(getGeneration());
|
||||
featureSupliers.add(gen -> featureAdd.accept(gen));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -927,12 +930,12 @@ public class BCLBiomeBuilder {
|
|||
*
|
||||
* @return new or same {@link BiomeGenerationSettings.Builder} instance.
|
||||
*/
|
||||
private BiomeGenerationSettings.Builder getGeneration() {
|
||||
private BiomeGenerationSettings.Builder getGeneration(BootstapContext<Biome> bootstrapContext) {
|
||||
|
||||
if (generationSettings == null) {
|
||||
generationSettings = new BiomeGenerationSettings.Builder(
|
||||
builderContext.bootstrapContext.lookup(Registries.PLACED_FEATURE),
|
||||
builderContext.bootstrapContext.lookup(Registries.CONFIGURED_CARVER)
|
||||
bootstrapContext.lookup(Registries.PLACED_FEATURE),
|
||||
bootstrapContext.lookup(Registries.CONFIGURED_CARVER)
|
||||
);
|
||||
}
|
||||
return generationSettings;
|
||||
|
@ -943,7 +946,7 @@ public class BCLBiomeBuilder {
|
|||
*
|
||||
* @return created {@link BCLBiome} instance.
|
||||
*/
|
||||
public PreparedBiome<BCLBiome> build() {
|
||||
public UnregisteredBCLBiome<BCLBiome> build() {
|
||||
return build(BCLBiome::new);
|
||||
}
|
||||
|
||||
|
@ -954,17 +957,7 @@ public class BCLBiomeBuilder {
|
|||
* @param biomeConstructor {@link BiomeSupplier} biome constructor.
|
||||
* @return created {@link BCLBiome} instance.
|
||||
*/
|
||||
public <T extends BCLBiome> PreparedBiome<T> build(BiomeSupplier<T> biomeConstructor) {
|
||||
BiomeBuilder builder = new BiomeBuilder()
|
||||
.precipitation(precipitation)
|
||||
.temperature(temperature)
|
||||
.downfall(downfall);
|
||||
|
||||
builder.mobSpawnSettings(getSpawns().build());
|
||||
builder.specialEffects(getEffects().build());
|
||||
|
||||
builder.generationSettings(fixGenerationSettings(getGeneration().build()));
|
||||
|
||||
public <T extends BCLBiome> UnregisteredBCLBiome<T> build(BiomeSupplier<T> biomeConstructor) {
|
||||
BCLBiomeSettings settings = BCLBiomeSettings.createBCL()
|
||||
.setTerrainHeight(height)
|
||||
.setFogDensity(fogDensity)
|
||||
|
@ -973,20 +966,30 @@ public class BCLBiomeBuilder {
|
|||
.setEdge(edge)
|
||||
.setVertical(vertical)
|
||||
.build();
|
||||
|
||||
final Biome biome = builder.build();
|
||||
final T res = biomeConstructor.apply(biomeID, biome, settings);
|
||||
final T res = biomeConstructor.apply(ResourceKey.create(Registries.BIOME, biomeID), settings);
|
||||
tags.forEach(tagKey -> TagManager.BIOMES.add(tagKey, res.getBiomeKey()));
|
||||
|
||||
//res.addBiomeTags(tags);
|
||||
//res.setSurface(surfaceRule);
|
||||
SurfaceRuleRegistry.registerRule(biomeID, surfaceRule, biomeID);
|
||||
res.addClimateParameters(parameters);
|
||||
if (biomeType != null)
|
||||
res._setIntendedType(biomeType);
|
||||
|
||||
BiomeBuilder builder = new BiomeBuilder()
|
||||
.precipitation(precipitation)
|
||||
.temperature(temperature)
|
||||
.downfall(downfall);
|
||||
|
||||
builder.mobSpawnSettings(getSpawns().build());
|
||||
builder.specialEffects(getEffects().build());
|
||||
|
||||
//res.addBiomeTags(tags);
|
||||
//res.setSurface(surfaceRule);
|
||||
|
||||
//carvers.forEach(cfg -> BiomeAPI.addBiomeCarver(biome, cfg.second, cfg.first));
|
||||
return new PreparedBiome<>(res, builderContext);
|
||||
return new UnregisteredBCLBiome<>(
|
||||
res,
|
||||
parent,
|
||||
ctx -> builder.generationSettings(fixGenerationSettings(getGeneration(ctx).build())).build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.betterx.bclib.api.v2.levelgen.biomes;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
|
||||
public class BCLBiomeContainer<T extends BCLBiome> {
|
||||
protected final T biome;
|
||||
|
||||
BCLBiomeContainer(T biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
public T biome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext) {
|
||||
return register(bootstrapContext, biome.getIntendedType());
|
||||
}
|
||||
|
||||
public BCLBiomeContainer<T> register(BootstapContext<Biome> bootstrapContext, BiomeAPI.BiomeType dim) {
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -291,10 +291,10 @@ public class BiomeAPI {
|
|||
static BCLBiome registerBiome(BootstapContext<Biome> bootstrapContext, BCLBiome bclbiome) {
|
||||
HolderGetter<Biome> registryOrNull = bootstrapContext.lookup(Registries.BIOME);
|
||||
if (registryOrNull != null
|
||||
&& bclbiome.biomeToRegister != null
|
||||
&& bclbiome._hasBiomeToRegister()
|
||||
//TODO: 1.19.3 this was a ResourceLocation lookup, is this a valid test?
|
||||
&& registryOrNull.get(bclbiome.getBiomeKey()).map(v -> v.isBound()).orElse(false) == false) {
|
||||
bootstrapContext.register(bclbiome.getBiomeKey(), bclbiome.biomeToRegister);
|
||||
bootstrapContext.register(bclbiome.getBiomeKey(), bclbiome._getBiomeToRegister());
|
||||
|
||||
BCLBiomeRegistry.register(null, bclbiome);
|
||||
}
|
||||
|
@ -330,21 +330,6 @@ public class BiomeAPI {
|
|||
);
|
||||
}
|
||||
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
Biome subBiome,
|
||||
float genChance
|
||||
) {
|
||||
return registerSubBiome(
|
||||
bootstrapContext,
|
||||
parent,
|
||||
subBiome,
|
||||
genChance,
|
||||
parent.getIntendedType()
|
||||
);
|
||||
}
|
||||
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
|
@ -357,17 +342,6 @@ public class BiomeAPI {
|
|||
return subBiome;
|
||||
}
|
||||
|
||||
static BCLBiome registerSubBiome(
|
||||
BootstapContext<Biome> bootstrapContext,
|
||||
BCLBiome parent,
|
||||
Biome biome,
|
||||
float genChance,
|
||||
BiomeType dim
|
||||
) {
|
||||
BCLBiome subBiome = new BCLBiome(biome, VanillaBiomeSettings.createVanilla().setGenChance(genChance).build());
|
||||
return registerSubBiome(bootstrapContext, parent, subBiome, dim);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register {@link BCLBiome} instance and its {@link Biome} if necessary.
|
||||
* 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).
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
BCLib.LOGGER.info("Datagen buildRegistry");
|
||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, TestConfiguredFeatures::bootstrap);
|
||||
registryBuilder.add(Registries.PLACED_FEATURE, TestPlacedFeatures::bootstrap);
|
||||
//registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
|
||||
registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
|
||||
registryBuilder.add(Registries.NOISE_SETTINGS, NoiseDatagen::bootstrap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,46 +3,35 @@ package org.betterx.bclib.datagen;
|
|||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeContainer;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
public class TestBiomes {
|
||||
static BCLBiomeContainer<BCLBiome> THE_YELLOW = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.feature(TestPlacedFeatures.YELLOW_PLACED)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.endLandBiome()
|
||||
.build();
|
||||
|
||||
public static void bootstrap(BootstapContext<Biome> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap Biomes");
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
HolderGetter<PlacedFeature> holderGetter = bootstrapContext.lookup(Registries.PLACED_FEATURE);
|
||||
Holder.Reference<PlacedFeature> reference = holderGetter.getOrThrow(ResourceKey.create(
|
||||
Registries.PLACED_FEATURE,
|
||||
BCLib.makeID("yellow_feature")
|
||||
));
|
||||
BCLib.LOGGER.info("REF Biome:" + reference);
|
||||
BCLBiomeContainer<BCLBiome> theYellow = THE_YELLOW
|
||||
.register(bootstrapContext);
|
||||
|
||||
BCLBiomeBuilder.Context biomeBuilder = new BCLBiomeBuilder.Context(bootstrapContext);
|
||||
BCLBiome theYellow = biomeBuilder
|
||||
.start(BCLib.makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.feature(GenerationStep.Decoration.VEGETAL_DECORATION, reference)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.build()
|
||||
.registerEndLandBiome();
|
||||
|
||||
BCLBiome theBlue = biomeBuilder
|
||||
BCLBiome theBlue = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
|
@ -53,10 +42,11 @@ public class TestBiomes {
|
|||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.endLandBiome()
|
||||
.build()
|
||||
.registerEndLandBiome();
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome theGray = biomeBuilder
|
||||
BCLBiome theGray = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
|
@ -67,10 +57,11 @@ public class TestBiomes {
|
|||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.endVoidBiome()
|
||||
.build()
|
||||
.registerEndVoidBiome();
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome theOrange = biomeBuilder
|
||||
BCLBiome theOrange = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
|
@ -81,10 +72,11 @@ public class TestBiomes {
|
|||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.netherBiome()
|
||||
.build()
|
||||
.registerNetherBiome();
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome thePurple = biomeBuilder
|
||||
BCLBiome thePurple = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
|
@ -95,8 +87,9 @@ public class TestBiomes {
|
|||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.netherBiome()
|
||||
.build()
|
||||
.registerNetherBiome();
|
||||
.register(bootstrapContext).biome();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue