rename SamplerProviderImpl to SamplerProvider

This commit is contained in:
dfsek
2021-12-04 19:04:42 -07:00
parent 672cf59972
commit f08f79f754
3 changed files with 9 additions and 9 deletions
@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.dfsek.terra.addons.chunkgenerator.generation.math.PaletteUtil; 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.addons.chunkgenerator.palette.PaletteInfo;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
@@ -38,14 +38,14 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
private final Platform platform; private final Platform platform;
private final List<GenerationStage> generationStages = new ArrayList<>(); private final List<GenerationStage> generationStages = new ArrayList<>();
private final SamplerProviderImpl samplerCache; private final SamplerProvider samplerCache;
private final BlockState air; private final BlockState air;
public NoiseChunkGenerator3D(ConfigPack c, Platform platform, int elevationBlend) { public NoiseChunkGenerator3D(ConfigPack c, Platform platform, int elevationBlend) {
this.platform = platform; this.platform = platform;
this.air = platform.getWorldHandle().air(); 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))); c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
} }
@@ -129,7 +129,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
} else return air; } else return air;
} }
public SamplerProviderImpl samplerProvider() { public SamplerProvider samplerProvider() {
return samplerCache; return samplerCache;
} }
} }
@@ -31,12 +31,12 @@ import com.dfsek.terra.api.util.generic.pair.Pair;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider; import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public class SamplerProviderImpl { public class SamplerProvider {
private final LoadingCache<Pair<Long, World>, Sampler> cache; 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()) cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache())
.build(new CacheLoader<>() { .build(new CacheLoader<>() {
@Override @Override
@@ -14,7 +14,7 @@ import net.jafama.FastMath;
import java.util.Map; import java.util.Map;
import com.dfsek.terra.addons.chunkgenerator.generation.generators.NoiseChunkGenerator3D; 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.ImplementationArguments;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable; import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function; 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) { private String apply(Vector3 vector, WritableWorld world) {
int y = vector.getBlockY(); int y = vector.getBlockY();
if(y >= world.getMaxHeight() || y < 0) return "AIR"; 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); 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. 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 //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 cx = FastMath.floorDiv((int) x, 16);
int cz = FastMath.floorDiv((int) z, 16); int cz = FastMath.floorDiv((int) z, 16);
return cache.getChunk(cx, cz, world).sample(x - (cx << 4), y, z - (cz << 4)); return cache.getChunk(cx, cz, world).sample(x - (cx << 4), y, z - (cz << 4));