Stop blowing up the VM when looking for biomes

This commit is contained in:
Daniel Mills committed 2021-07-16 05:00:00 -04:00
1 parent e5cc9a3cbf
commit 9c376183e0
5 files changed
+52 -20

No files matched your search

@@ -19,6 +19,7 @@
package com.volmit.iris.engine.stream.utility;
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.stream.BasicStream;
import com.volmit.iris.engine.stream.ProceduralStream;
@@ -49,6 +50,11 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
@Override
public T get(double x, double z) {
if(IrisComplex.cacheLock.get())
{
return stream.get((int) x, (int) z);
}
return cache.compute(Cache.key((int) x, (int) z), (k, v) -> v != null ? v : stream.get((int) x, (int) z));
}