mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 22:01:07 +00:00
redo biome blending
This commit is contained in:
@@ -2,18 +2,15 @@ package com.dfsek.terra.config.base;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ValidationException;
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class ConfigPackTemplate implements ValidatedConfigTemplate {
|
||||
public class ConfigPackTemplate implements ConfigTemplate {
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
@@ -36,10 +33,6 @@ public class ConfigPackTemplate implements ValidatedConfigTemplate {
|
||||
@Default
|
||||
private double blendAmp = 4.0D;
|
||||
|
||||
@Value("blend.terrain.base")
|
||||
@Default
|
||||
private int baseBlend = 4;
|
||||
|
||||
@Value("structures.locatable")
|
||||
@Default
|
||||
private Map<String, String> locatable = new HashMap<>();
|
||||
@@ -167,9 +160,6 @@ public class ConfigPackTemplate implements ValidatedConfigTemplate {
|
||||
return erodeOctaves;
|
||||
}
|
||||
|
||||
public int getBaseBlend() {
|
||||
return baseBlend;
|
||||
}
|
||||
|
||||
public int getElevationBlend() {
|
||||
return elevationBlend;
|
||||
@@ -178,12 +168,4 @@ public class ConfigPackTemplate implements ValidatedConfigTemplate {
|
||||
public Map<String, String> getLocatable() {
|
||||
return locatable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
if(!MathUtil.equals(FastMath.log(baseBlend) / FastMath.log(2d), FastMath.round(FastMath.log(baseBlend) / FastMath.log(2d)))) {
|
||||
throw new ValidationException("Biome base blend value \"" + baseBlend + "\" is not a power of 2.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,13 +36,19 @@ public class GeneratorBuilder {
|
||||
|
||||
private double elevationWeight;
|
||||
|
||||
private int blendDistance;
|
||||
|
||||
|
||||
public WorldGenerator build(long seed) {
|
||||
synchronized(gens) {
|
||||
return gens.computeIfAbsent(seed, k -> new WorldGenerator(seed, noiseEquation, elevationEquation, varScope, noiseBuilderMap, palettes, slantPalettes, interpolateElevation, noise2d, base, biomeNoise.build((int) seed), elevationWeight));
|
||||
return gens.computeIfAbsent(seed, k -> new WorldGenerator(seed, noiseEquation, elevationEquation, varScope, noiseBuilderMap, palettes, slantPalettes, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance));
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlendDistance(int blendDistance) {
|
||||
this.blendDistance = blendDistance;
|
||||
}
|
||||
|
||||
public void setBiomeNoise(NoiseBuilder biomeNoise) {
|
||||
this.biomeNoise = biomeNoise;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, TerraBiome> {
|
||||
generatorBuilder.setBase(template.getNoise2dBase());
|
||||
generatorBuilder.setElevationWeight(template.getElevationWeight());
|
||||
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
|
||||
generatorBuilder.setBlendDistance(template.getBlendDistance());
|
||||
|
||||
|
||||
return new UserDefinedBiome(template.getVanilla(), generatorBuilder, template);
|
||||
|
||||
@@ -70,6 +70,11 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Abstractable
|
||||
private NoiseBuilder biomeNoise = new NoiseBuilder();
|
||||
|
||||
@Value("blend.distance")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int blendDistance = 3;
|
||||
|
||||
@Value("erode")
|
||||
@Abstractable
|
||||
@Default
|
||||
@@ -165,6 +170,10 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
return color;
|
||||
}
|
||||
|
||||
public int getBlendDistance() {
|
||||
return blendDistance;
|
||||
}
|
||||
|
||||
public boolean interpolateElevation() {
|
||||
return interpolateElevation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user