mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
rename SamplerProviderImpl to SamplerProvider
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.PaletteUtil;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProviderImpl;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -38,14 +38,14 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final Platform platform;
|
||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||
|
||||
private final SamplerProviderImpl samplerCache;
|
||||
private final SamplerProvider samplerCache;
|
||||
|
||||
private final BlockState air;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack c, Platform platform, int elevationBlend) {
|
||||
this.platform = platform;
|
||||
this.air = platform.getWorldHandle().air();
|
||||
this.samplerCache = new SamplerProviderImpl(platform, c.getBiomeProvider(), elevationBlend);
|
||||
this.samplerCache = new SamplerProvider(platform, c.getBiomeProvider(), elevationBlend);
|
||||
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
} else return air;
|
||||
}
|
||||
|
||||
public SamplerProviderImpl samplerProvider() {
|
||||
public SamplerProvider samplerProvider() {
|
||||
return samplerCache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class SamplerProviderImpl {
|
||||
public class SamplerProvider {
|
||||
private final LoadingCache<Pair<Long, World>, Sampler> cache;
|
||||
|
||||
|
||||
|
||||
public SamplerProviderImpl(Platform platform, BiomeProvider provider, int elevationSmooth) {
|
||||
public SamplerProvider(Platform platform, BiomeProvider provider, int elevationSmooth) {
|
||||
cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache())
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
@@ -14,7 +14,7 @@ import net.jafama.FastMath;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.generators.NoiseChunkGenerator3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProviderImpl;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
@@ -71,7 +71,7 @@ public class CheckFunction implements Function<String> {
|
||||
private String apply(Vector3 vector, WritableWorld world) {
|
||||
int y = vector.getBlockY();
|
||||
if(y >= world.getMaxHeight() || y < 0) return "AIR";
|
||||
SamplerProviderImpl cache = ((NoiseChunkGenerator3D) world.getGenerator()).samplerProvider();
|
||||
SamplerProvider cache = ((NoiseChunkGenerator3D) world.getGenerator()).samplerProvider();
|
||||
double comp = sample(vector.getX(), vector.getY(), vector.getZ(), cache, world);
|
||||
|
||||
if(comp > 0) return "LAND"; // If noise val is greater than zero, location will always be land.
|
||||
@@ -84,7 +84,7 @@ public class CheckFunction implements Function<String> {
|
||||
//return "OCEAN"; // Below sea level
|
||||
}
|
||||
|
||||
private double sample(double x, double y, double z, SamplerProviderImpl cache, World world) {
|
||||
private double sample(double x, double y, double z, SamplerProvider cache, World world) {
|
||||
int cx = FastMath.floorDiv((int) x, 16);
|
||||
int cz = FastMath.floorDiv((int) z, 16);
|
||||
return cache.getChunk(cx, cz, world).sample(x - (cx << 4), y, z - (cz << 4));
|
||||
|
||||
Reference in New Issue
Block a user