mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
configurable beard threshold
This commit is contained in:
+16
@@ -35,7 +35,23 @@ public class PreLoadCompatibilityOptions implements ConfigTemplate, Properties {
|
|||||||
@Default
|
@Default
|
||||||
private boolean vanillaBiomes = false;
|
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() {
|
public boolean useVanillaBiomes() {
|
||||||
return vanillaBiomes;
|
return vanillaBiomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBeard() {
|
||||||
|
return beard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getBeardThreshold() {
|
||||||
|
return beardThreshold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -43,8 +43,11 @@ public class BeardGenerator {
|
|||||||
private final int minY;
|
private final int minY;
|
||||||
private final int maxY;
|
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.chunk = chunk;
|
||||||
|
this.threshold = threshold;
|
||||||
ChunkPos chunkPos = chunk.getPos();
|
ChunkPos chunkPos = chunk.getPos();
|
||||||
int i = chunkPos.getStartX();
|
int i = chunkPos.getStartX();
|
||||||
int j = chunkPos.getStartZ();
|
int j = chunkPos.getStartZ();
|
||||||
@@ -93,7 +96,7 @@ public class BeardGenerator {
|
|||||||
for(int z = 0; z < 16; z++) {
|
for(int z = 0; z < 16; z++) {
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
for(int y = maxY; y >= minY; y--) {
|
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
|
chunk.setBlockState(new BlockPos(x, y, z), (BlockState) generator
|
||||||
.getPalette(x + xi, y, z + zi, worldProperties, biomeProvider)
|
.getPalette(x + xi, y, z + zi, worldProperties, biomeProvider)
|
||||||
.get(depth, x + xi, y, z + zi, worldProperties.getSeed()), false);
|
.get(depth, x + xi, y, z + zi, worldProperties.getSeed()), false);
|
||||||
|
|||||||
+6
-4
@@ -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.ProtoWorld;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.stage.Chunkified;
|
import com.dfsek.terra.api.world.chunk.generation.stage.Chunkified;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
|
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.data.Codecs;
|
||||||
import com.dfsek.terra.fabric.mixin.access.StructureAccessorAccessor;
|
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.chunk.Chunk;
|
||||||
import net.minecraft.world.gen.GenerationStep;
|
import net.minecraft.world.gen.GenerationStep;
|
||||||
import net.minecraft.world.gen.StructureAccessor;
|
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.Blender;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
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();
|
ProtoWorld world = (ProtoWorld) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||||
BiomeProvider biomeProvider = pack.getBiomeProvider().caching();
|
BiomeProvider biomeProvider = pack.getBiomeProvider().caching();
|
||||||
delegate.generateChunkData((ProtoChunk) chunk, world, biomeProvider, chunk.getPos().x, chunk.getPos().z);
|
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;
|
return chunk;
|
||||||
}, executor);
|
}, executor);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user