mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
improve biome mutation noise functions
This commit is contained in:
parent
1863ba29fc
commit
4aebb83b0c
@ -18,14 +18,14 @@ public class StandardBiomeProvider implements BiomeProvider {
|
|||||||
private final LoadingCache<Vector2, BiomeHolder> holderCache;
|
private final LoadingCache<Vector2, BiomeHolder> holderCache;
|
||||||
private final BiomePipeline pipeline;
|
private final BiomePipeline pipeline;
|
||||||
private int resolution = 1;
|
private int resolution = 1;
|
||||||
private final NoiseSampler xSampler;
|
private final NoiseSampler mutator;
|
||||||
private final NoiseSampler zSampler;
|
private final double noiseAmp;
|
||||||
private final int noiseAmp;
|
private final int seed;
|
||||||
|
|
||||||
protected StandardBiomeProvider(BiomePipeline pipeline, TerraPlugin main, NoiseSampler xSampler, NoiseSampler zSampler, int noiseAmp) {
|
protected StandardBiomeProvider(BiomePipeline pipeline, TerraPlugin main, NoiseSampler mutator, double noiseAmp, int seed) {
|
||||||
this.xSampler = xSampler;
|
this.mutator = mutator;
|
||||||
this.zSampler = zSampler;
|
|
||||||
this.noiseAmp = noiseAmp;
|
this.noiseAmp = noiseAmp;
|
||||||
|
this.seed = seed;
|
||||||
holderCache = CacheBuilder.newBuilder()
|
holderCache = CacheBuilder.newBuilder()
|
||||||
.maximumSize(main == null ? 32 : main.getTerraConfig().getProviderCache())
|
.maximumSize(main == null ? 32 : main.getTerraConfig().getProviderCache())
|
||||||
.build(
|
.build(
|
||||||
@ -41,8 +41,14 @@ public class StandardBiomeProvider implements BiomeProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TerraBiome getBiome(int x, int z) {
|
public TerraBiome getBiome(int x, int z) {
|
||||||
x = FastMath.floorToInt(FastMath.floorDiv(x, resolution) + xSampler.getNoise(x, z) * noiseAmp);
|
x += mutator.getNoiseSeeded(seed, x, z) * noiseAmp;
|
||||||
z = FastMath.floorToInt(FastMath.floorDiv(z, resolution) + zSampler.getNoise(x, z) * noiseAmp);
|
z += mutator.getNoiseSeeded(1 + seed, x, z) * noiseAmp;
|
||||||
|
|
||||||
|
|
||||||
|
x = FastMath.floorToInt(FastMath.floorDiv(x, resolution));
|
||||||
|
|
||||||
|
z = FastMath.floorToInt(FastMath.floorDiv(z, resolution));
|
||||||
|
|
||||||
int fdX = FastMath.floorDiv(x, pipeline.getSize());
|
int fdX = FastMath.floorDiv(x, pipeline.getSize());
|
||||||
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
||||||
return holderCache.getUnchecked(new Vector2(fdX, fdZ)).getBiome(x - fdX * pipeline.getSize(), z - fdZ * pipeline.getSize());
|
return holderCache.getUnchecked(new Vector2(fdX, fdZ)).getBiome(x - fdX * pipeline.getSize(), z - fdZ * pipeline.getSize());
|
||||||
@ -64,7 +70,7 @@ public class StandardBiomeProvider implements BiomeProvider {
|
|||||||
private final ExceptionalFunction<Long, BiomePipeline> pipelineBuilder;
|
private final ExceptionalFunction<Long, BiomePipeline> pipelineBuilder;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private int resolution = 1;
|
private int resolution = 1;
|
||||||
private int noiseAmp = 2;
|
private double noiseAmp = 2;
|
||||||
private NoiseSeeded builder;
|
private NoiseSeeded builder;
|
||||||
|
|
||||||
public StandardBiomeProviderBuilder(ExceptionalFunction<Long, BiomePipeline> pipelineBuilder, TerraPlugin main) {
|
public StandardBiomeProviderBuilder(ExceptionalFunction<Long, BiomePipeline> pipelineBuilder, TerraPlugin main) {
|
||||||
@ -80,14 +86,14 @@ public class StandardBiomeProvider implements BiomeProvider {
|
|||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoiseAmp(int noiseAmp) {
|
public void setNoiseAmp(double noiseAmp) {
|
||||||
this.noiseAmp = noiseAmp;
|
this.noiseAmp = noiseAmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StandardBiomeProvider build(long seed) {
|
public StandardBiomeProvider build(long seed) {
|
||||||
try {
|
try {
|
||||||
StandardBiomeProvider provider = new StandardBiomeProvider(pipelineBuilder.apply(seed), main, builder.apply(seed), builder.apply((seed + 1)), noiseAmp);
|
StandardBiomeProvider provider = new StandardBiomeProvider(pipelineBuilder.apply(seed), main, builder.apply(seed), noiseAmp, (int) seed);
|
||||||
provider.setResolution(resolution);
|
provider.setResolution(resolution);
|
||||||
return provider;
|
return provider;
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
|
@ -69,7 +69,7 @@ public class BiomeProviderBuilderLoader implements TypeLoader<BiomeProvider.Biom
|
|||||||
builder.setResolution(resolution);
|
builder.setResolution(resolution);
|
||||||
if(map.containsKey("blend")) {
|
if(map.containsKey("blend")) {
|
||||||
Map<String, Object> blend = (Map<String, Object>) map.get("blend");
|
Map<String, Object> blend = (Map<String, Object>) map.get("blend");
|
||||||
if(blend.containsKey("amplitude")) builder.setNoiseAmp(Integer.parseInt(blend.get("amplitude").toString()));
|
if(blend.containsKey("amplitude")) builder.setNoiseAmp(Double.parseDouble(blend.get("amplitude").toString()));
|
||||||
if(blend.containsKey("noise"))
|
if(blend.containsKey("noise"))
|
||||||
builder.setBlender(loader.loadClass(NoiseSeeded.class, blend.get("noise")));
|
builder.setBlender(loader.loadClass(NoiseSeeded.class, blend.get("noise")));
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,8 @@ val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
|||||||
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
||||||
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
||||||
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
||||||
maxHeapSize = "3G"
|
maxHeapSize = "2G"
|
||||||
minHeapSize = "3G"
|
minHeapSize = "2G"
|
||||||
//args = listOf("nogui")
|
//args = listOf("nogui")
|
||||||
workingDir = file("${testDir}/")
|
workingDir = file("${testDir}/")
|
||||||
classpath = files("${testDir}/paper.jar")
|
classpath = files("${testDir}/paper.jar")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user