mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-14 04:41:13 +00:00
completely redo biome loading
This commit is contained in:
@@ -2,7 +2,7 @@ package com.dfsek.terra.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
||||
import com.dfsek.terra.api.util.seeded.StageSeeded;
|
||||
import com.dfsek.terra.biome.pipeline.source.BiomeSource;
|
||||
import com.dfsek.terra.biome.pipeline.stages.Stage;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BiomePipeline {
|
||||
|
||||
public static final class BiomePipelineBuilder {
|
||||
private final int init;
|
||||
List<SeededBuilder<Stage>> stages = new GlueList<>();
|
||||
List<StageSeeded> stages = new GlueList<>();
|
||||
private int expand;
|
||||
|
||||
public BiomePipelineBuilder(int init) {
|
||||
@@ -60,7 +60,7 @@ public class BiomePipeline {
|
||||
return new BiomePipeline(source, stagesBuilt, expand, init);
|
||||
}
|
||||
|
||||
public BiomePipelineBuilder addStage(SeededBuilder<Stage> stage) {
|
||||
public BiomePipelineBuilder addStage(StageSeeded stage) {
|
||||
stages.add(stage);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -23,4 +23,8 @@ public interface BiomeProvider {
|
||||
interface BiomeProviderBuilder {
|
||||
BiomeProvider build(long seed);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
IMAGE, PIPELINE, SINGLE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.dfsek.terra.biome.provider;
|
||||
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.terra.api.core.TerraPlugin;
|
||||
import com.dfsek.terra.api.math.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
import com.dfsek.terra.biome.TerraBiome;
|
||||
import com.dfsek.terra.biome.pipeline.BiomeHolder;
|
||||
import com.dfsek.terra.biome.pipeline.BiomePipeline;
|
||||
@@ -17,12 +15,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class StandardBiomeProvider implements BiomeProvider {
|
||||
private final LoadingCache<Vector2, BiomeHolder> holderCache;
|
||||
private final BiomePipeline pipeline;
|
||||
private int resolution = 1;
|
||||
private final int resolution;
|
||||
private final NoiseSampler mutator;
|
||||
private final double noiseAmp;
|
||||
private final int seed;
|
||||
|
||||
protected StandardBiomeProvider(BiomePipeline pipeline, TerraPlugin main, NoiseSampler mutator, double noiseAmp, int seed) {
|
||||
public StandardBiomeProvider(BiomePipeline pipeline, TerraPlugin main, int resolution, NoiseSampler mutator, double noiseAmp, int seed) {
|
||||
this.resolution = resolution;
|
||||
this.mutator = mutator;
|
||||
this.noiseAmp = noiseAmp;
|
||||
this.seed = seed;
|
||||
@@ -53,52 +52,4 @@ public class StandardBiomeProvider implements BiomeProvider {
|
||||
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
||||
return holderCache.getUnchecked(new Vector2(fdX, fdZ)).getBiome(x - fdX * pipeline.getSize(), z - fdZ * pipeline.getSize());
|
||||
}
|
||||
|
||||
public int getResolution() {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
public void setResolution(int resolution) {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
public interface ExceptionalFunction<I, O> {
|
||||
O apply(I in) throws ConfigException;
|
||||
}
|
||||
|
||||
public static final class StandardBiomeProviderBuilder implements BiomeProviderBuilder {
|
||||
private final ExceptionalFunction<Long, BiomePipeline> pipelineBuilder;
|
||||
private final TerraPlugin main;
|
||||
private int resolution = 1;
|
||||
private double noiseAmp = 2;
|
||||
private NoiseSeeded builder;
|
||||
|
||||
public StandardBiomeProviderBuilder(ExceptionalFunction<Long, BiomePipeline> pipelineBuilder, TerraPlugin main) {
|
||||
this.pipelineBuilder = pipelineBuilder;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void setResolution(int resolution) {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
public void setBlender(NoiseSeeded builder) {
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
public void setNoiseAmp(double noiseAmp) {
|
||||
this.noiseAmp = noiseAmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardBiomeProvider build(long seed) {
|
||||
try {
|
||||
StandardBiomeProvider provider = new StandardBiomeProvider(pipelineBuilder.apply(seed), main, builder.apply(seed), noiseAmp, (int) seed);
|
||||
provider.setResolution(resolution);
|
||||
return provider;
|
||||
} catch(ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user