mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
add max slant depth option
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.config.palette;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
@@ -27,13 +28,24 @@ import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
@Value("slant")
|
||||
@Default
|
||||
@Description("The slant palettes to use in this biome.")
|
||||
private @Meta List<@Meta SlantLayer> slant = Collections.emptyList();
|
||||
|
||||
@Value("slant-depth")
|
||||
@Default
|
||||
@Description("The maximum depth at which to apply a slant palette.")
|
||||
private @Meta int slantDepth = Integer.MAX_VALUE;
|
||||
|
||||
@Value("palette")
|
||||
@Description("The palettes to use in this biome.")
|
||||
private @Meta List<@Meta Map<@Meta Palette, @Meta Integer>> palettes;
|
||||
|
||||
@Value("ocean.level")
|
||||
@Description("Sea level in this biome.")
|
||||
private @Meta int seaLevel;
|
||||
|
||||
@Value("ocean.palette")
|
||||
@Description("The palette to use for the ocean in this biome.")
|
||||
private @Meta Palette oceanPalette;
|
||||
|
||||
@Override
|
||||
@@ -54,6 +66,6 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
slantLayers.put(threshold, layer.getPalette());
|
||||
}
|
||||
|
||||
return new PaletteInfo(builder.build(), new SlantHolder(slantLayers, minThreshold), oceanPalette, seaLevel);
|
||||
return new PaletteInfo(builder.build(), new SlantHolder(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ import com.dfsek.terra.api.world.chunk.generation.util.Palette;
|
||||
public record PaletteInfo(PaletteHolder paletteHolder,
|
||||
SlantHolder slantHolder,
|
||||
Palette ocean,
|
||||
int seaLevel) implements Properties {
|
||||
int seaLevel,
|
||||
int maxSlantDepth) implements Properties {
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo).get(paletteLevel, cx, y, cz,
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||
seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
int fdX = FastMath.floorMod(x, 16);
|
||||
int fdZ = FastMath.floorMod(z, 16);
|
||||
|
||||
Palette palette = PaletteUtil.getPalette(fdX, y, fdZ, sampler, paletteInfo);
|
||||
Palette palette = PaletteUtil.getPalette(fdX, y, fdZ, sampler, paletteInfo, 0);
|
||||
double noise = sampler.sample(fdX, y, fdZ);
|
||||
if(noise > 0) {
|
||||
int level = 0;
|
||||
|
||||
@@ -19,9 +19,9 @@ public final class PaletteUtil {
|
||||
*/
|
||||
private static final double DERIVATIVE_DIST = 0.55;
|
||||
|
||||
public static Palette getPalette(int x, int y, int z, Sampler3D sampler, PaletteInfo paletteInfo) {
|
||||
public static Palette getPalette(int x, int y, int z, Sampler3D sampler, PaletteInfo paletteInfo, int depth) {
|
||||
SlantHolder slant = paletteInfo.slantHolder();
|
||||
if(!slant.isEmpty()) {
|
||||
if(!slant.isEmpty() && depth <= paletteInfo.maxSlantDepth()) {
|
||||
double slope = derivative(sampler, x, y, z);
|
||||
if(slope > slant.getMinSlope()) {
|
||||
return slant.getPalette(slope).getPalette(y);
|
||||
|
||||
Reference in New Issue
Block a user