Started Feature Migration in BN
This commit is contained in:
parent
2168787ac2
commit
abe18ae923
9 changed files with 142 additions and 34 deletions
|
@ -40,7 +40,12 @@ public class BCLCommonFeatures {
|
|||
int density,
|
||||
boolean allHeight) {
|
||||
if (allHeight) {
|
||||
return BCLFeatureBuilder.start(id, feature).countLayers(density).squarePlacement().onlyInBiome().build();
|
||||
return BCLFeatureBuilder
|
||||
.start(id, feature)
|
||||
.countLayers(density)
|
||||
.squarePlacement()
|
||||
.onlyInBiome()
|
||||
.buildAndRegister();
|
||||
} else {
|
||||
return BCLFeatureBuilder
|
||||
.start(id, feature)
|
||||
|
@ -48,7 +53,7 @@ public class BCLCommonFeatures {
|
|||
.squarePlacement()
|
||||
.heightmap()
|
||||
.onlyInBiome()
|
||||
.build();
|
||||
.buildAndRegister();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +68,7 @@ public class BCLCommonFeatures {
|
|||
public static BCLFeature makeChunkFeature(ResourceLocation id,
|
||||
Decoration decoration,
|
||||
Feature<NoneFeatureConfiguration> feature) {
|
||||
return BCLFeatureBuilder.start(id, feature).decoration(decoration).count(1).onlyInBiome().build();
|
||||
return BCLFeatureBuilder.start(id, feature).decoration(decoration).count(1).onlyInBiome().buildAndRegister();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +89,7 @@ public class BCLCommonFeatures {
|
|||
.oncePerChunks(chance)
|
||||
.squarePlacement()
|
||||
.onlyInBiome()
|
||||
.build();
|
||||
.buildAndRegister();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +110,7 @@ public class BCLCommonFeatures {
|
|||
.count(count)
|
||||
.squarePlacement()
|
||||
.onlyInBiome()
|
||||
.build();
|
||||
.buildAndRegister();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +145,7 @@ public class BCLCommonFeatures {
|
|||
|
||||
builder.modifier(placement).squarePlacement().onlyInBiome();
|
||||
|
||||
return builder.build(new OreConfiguration(
|
||||
return builder.buildAndRegister(new OreConfiguration(
|
||||
new BlockMatchTest(hostBlock),
|
||||
blockOre.defaultBlockState(),
|
||||
veinSize,
|
||||
|
|
|
@ -132,17 +132,33 @@ public class BCLFeatureBuilder<FC extends FeatureConfiguration, F extends Featur
|
|||
return modifier(InSquarePlacement.spread());
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder distanceToTopAndBottom10() {
|
||||
return modifier(PlacementUtils.RANGE_10_10);
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder distanceToTopAndBottom4() {
|
||||
return modifier(PlacementUtils.RANGE_4_4);
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder heightmap() {
|
||||
return modifier(PlacementUtils.HEIGHTMAP);
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder heightmapTopSolid() {
|
||||
return modifier(PlacementUtils.HEIGHTMAP_TOP_SOLID);
|
||||
}
|
||||
|
||||
public BCLFeatureBuilder heightmapWorldSurface() {
|
||||
return modifier(PlacementUtils.HEIGHTMAP_WORLD_SURFACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new {@link BCLFeature} instance. Features will be registered during this process.
|
||||
*
|
||||
* @param configuration any {@link FeatureConfiguration} for provided {@link Feature}.
|
||||
* @return created {@link BCLFeature} instance.
|
||||
*/
|
||||
public BCLFeature build(FC configuration) {
|
||||
public BCLFeature buildAndRegister(FC configuration) {
|
||||
PlacementModifier[] modifiers = modifications.toArray(new PlacementModifier[modifications.size()]);
|
||||
return new BCLFeature(featureID, feature, decoration, configuration, modifiers);
|
||||
}
|
||||
|
@ -153,7 +169,17 @@ public class BCLFeatureBuilder<FC extends FeatureConfiguration, F extends Featur
|
|||
*
|
||||
* @return created {@link BCLFeature} instance.
|
||||
*/
|
||||
public BCLFeature buildAndRegister() {
|
||||
return buildAndRegister((FC) FeatureConfiguration.NONE);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public BCLFeature build(FC configuration) {
|
||||
return buildAndRegister(configuration);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public BCLFeature build() {
|
||||
return build((FC) FeatureConfiguration.NONE);
|
||||
return buildAndRegister();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.RandomState;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
@ -116,4 +118,14 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
public String toString() {
|
||||
return "BCLib - Chunk Generator (" + Integer.toHexString(hashCode()) + ")";
|
||||
}
|
||||
|
||||
public static RandomState createRandomState(ServerLevel level, ChunkGenerator generator) {
|
||||
if (generator instanceof NoiseBasedChunkGenerator noiseBasedChunkGenerator) {
|
||||
return RandomState.create(noiseBasedChunkGenerator.generatorSettings().value(),
|
||||
level.registryAccess().registryOrThrow(Registry.NOISE_REGISTRY),
|
||||
level.getSeed());
|
||||
} else {
|
||||
return RandomState.create(level.registryAccess(), NoiseGeneratorSettings.OVERWORLD, level.getSeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue