mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-14 04:41:13 +00:00
replace dumb caches with guava caches
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.biome.pipeline.BiomeHolder;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BiomeCache {
|
||||
LoadingCache<Vector2, BiomeHolder> cache;
|
||||
|
||||
public BiomeCache() {
|
||||
cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1024)
|
||||
.build(
|
||||
new CacheLoader<Vector2, BiomeHolder>() {
|
||||
@Override
|
||||
public BiomeHolder load(@NotNull Vector2 key) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -50,11 +50,7 @@ public class StandardBiomeProvider implements BiomeProvider {
|
||||
|
||||
@Override
|
||||
public TerraBiome getBiome(int x, int z) {
|
||||
try {
|
||||
return biomeCache.get(new Vector2(x, z));
|
||||
} catch(ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return biomeCache.getUnchecked(new Vector2(x, z));
|
||||
}
|
||||
|
||||
public int getResolution() {
|
||||
|
||||
Reference in New Issue
Block a user