configurable beard threshold

This commit is contained in:
dfsek
2022-01-04 08:24:32 -07:00
parent 3fd5aaf56c
commit 42c407698d
3 changed files with 27 additions and 6 deletions

View File

@@ -35,7 +35,23 @@ public class PreLoadCompatibilityOptions implements ConfigTemplate, Properties {
@Default
private boolean vanillaBiomes = false;
@Value("fabric.beard.enable")
@Default
private boolean beard = true;
@Value("fabric.beard.threshold")
@Default
private double beardThreshold = 0.5;
public boolean useVanillaBiomes() {
return vanillaBiomes;
}
public boolean isBeard() {
return beard;
}
public double getBeardThreshold() {
return beardThreshold;
}
}

View File

@@ -43,8 +43,11 @@ public class BeardGenerator {
private final int minY;
private final int maxY;
public BeardGenerator(StructureAccessor structureAccessor, Chunk chunk) {
private final double threshold;
public BeardGenerator(StructureAccessor structureAccessor, Chunk chunk, double threshold) {
this.chunk = chunk;
this.threshold = threshold;
ChunkPos chunkPos = chunk.getPos();
int i = chunkPos.getStartX();
int j = chunkPos.getStartZ();
@@ -93,7 +96,7 @@ public class BeardGenerator {
for(int z = 0; z < 16; z++) {
int depth = 0;
for(int y = maxY; y >= minY; y--) {
if(calculateNoise(x + xi, y, z + zi) > 0.5) {
if(calculateNoise(x + xi, y, z + zi) > threshold) {
chunk.setBlockState(new BlockPos(x, y, z), (BlockState) generator
.getPalette(x + xi, y, z + zi, worldProperties, biomeProvider)
.get(depth, x + xi, y, z + zi, worldProperties.getSeed()), false);

View File

@@ -24,6 +24,7 @@ import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
import com.dfsek.terra.api.world.chunk.generation.stage.Chunkified;
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
import com.dfsek.terra.fabric.config.PreLoadCompatibilityOptions;
import com.dfsek.terra.fabric.data.Codecs;
import com.dfsek.terra.fabric.mixin.access.StructureAccessorAccessor;
@@ -43,7 +44,6 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.StructureWeightSampler;
import net.minecraft.world.gen.chunk.Blender;
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
import net.minecraft.world.gen.chunk.StructuresConfig;
@@ -159,9 +159,11 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
BiomeProvider biomeProvider = pack.getBiomeProvider().caching();
delegate.generateChunkData((ProtoChunk) chunk, world, biomeProvider, chunk.getPos().x, chunk.getPos().z);
new BeardGenerator(structureAccessor, chunk).generate(delegate, world, biomeProvider);
PreLoadCompatibilityOptions compatibilityOptions = pack.getContext().get(PreLoadCompatibilityOptions.class);
if(compatibilityOptions.isBeard()) {
new BeardGenerator(structureAccessor, chunk, compatibilityOptions.getBeardThreshold()).generate(delegate, world, biomeProvider);
}
return chunk;
}, executor);
}