From 9d832391e446cf256f219dda83d706d6bf149669 Mon Sep 17 00:00:00 2001 From: dfsek Date: Tue, 21 Dec 2021 01:13:48 -0700 Subject: [PATCH] dont use world as cache parameter --- .../math/samplers/SamplerProvider.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/math/samplers/SamplerProvider.java b/common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/math/samplers/SamplerProvider.java index 94625f520..710356a75 100644 --- a/common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/math/samplers/SamplerProvider.java +++ b/common/addons/chunk-generator-noise-3d/src/main/java/com/dfsek/terra/addons/chunkgenerator/generation/math/samplers/SamplerProvider.java @@ -31,19 +31,15 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider; public class SamplerProvider { - private final LoadingCache, Sampler3D> cache; + private final LoadingCache cache; public SamplerProvider(Platform platform, BiomeProvider provider, int elevationSmooth) { cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache()) .build(new CacheLoader<>() { @Override - public Sampler3D load(@NotNull Pair pair) { - long key = pair.getLeft(); - int cx = (int) (key >> 32); - int cz = (int) key; - World world = pair.getRight(); - return new Sampler3D(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight(), provider, + public Sampler3D load(@NotNull WorldContext context) { + return new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider, elevationSmooth); } }); @@ -56,7 +52,9 @@ public class SamplerProvider { } public Sampler3D getChunk(int cx, int cz, World world) { - long key = MathUtil.squash(cx, cz); - return cache.getUnchecked(Pair.of(key, world)); + return cache.getUnchecked(new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight())); + } + + private record WorldContext(int cx, int cz, long seed, int minHeight, int maxHeight) { } }