diff --git a/src/main/java/com/volmit/iris/engine/IrisComplex.java b/src/main/java/com/volmit/iris/engine/IrisComplex.java
index 9706bd379..93a79d6ec 100644
--- a/src/main/java/com/volmit/iris/engine/IrisComplex.java
+++ b/src/main/java/com/volmit/iris/engine/IrisComplex.java
@@ -171,7 +171,8 @@ public class IrisComplex implements DataProvider {
Interpolated.of(a -> 0D, a -> focus.getInferredType())) :
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
- .convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND).cache2D(engine, cacheSize);
+ .convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
+ .cache2D(engine, cacheSize);
baseBiomeStream = focus != null ? ProceduralStream.of((x, z) -> focus,
Interpolated.of(a -> 0D, a -> focus)) :
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
@@ -179,16 +180,9 @@ public class IrisComplex implements DataProvider {
heightStream = ProceduralStream.of((x, z) -> {
IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z);
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
- }, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D(engine, cacheSize, true);
+ }, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D(engine, cacheSize);
roundedHeighteightStream = heightStream.round();
slopeStream = heightStream.slope(3).cache2D(engine, cacheSize);
- trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
- b -> focus))
- .cache2D(engine, cacheSize) : heightStream
- .convertAware2D((h, x, z) ->
- fixBiomeType(h, baseBiomeStream.get(x, z),
- regionStream.get(x, z), x, z, fluidHeight))
- .cache2D(engine, cacheSize);
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
b -> focus))
.cache2D(engine, cacheSize) : heightStream
@@ -197,7 +191,7 @@ public class IrisComplex implements DataProvider {
regionStream.get(x, z), x, z, fluidHeight))
.cache2D(engine, cacheSize);
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D(engine, cacheSize);
- heightFluidStream = heightStream.max(fluidHeight).cache2D(engine, cacheSize, true);
+ heightFluidStream = heightStream.max(fluidHeight).cache2D(engine, cacheSize);
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
terrainSurfaceDecoration = trueBiomeStream
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D(engine, cacheSize);
diff --git a/src/main/java/com/volmit/iris/engine/IrisEngine.java b/src/main/java/com/volmit/iris/engine/IrisEngine.java
index aef072a23..0000487c9 100644
--- a/src/main/java/com/volmit/iris/engine/IrisEngine.java
+++ b/src/main/java/com/volmit/iris/engine/IrisEngine.java
@@ -462,17 +462,6 @@ public class IrisEngine implements Engine {
mode.generate(x, z, blocks, vbiomes, multicore);
}
- if(!multicore)
- {
- for(int i = 0; i < 16; i++)
- {
- for(int j = 0; j < 16; j++)
- {
- blocks.set(i, 255, j, B.get("GLASS"));
- }
- }
- }
-
getMantle().getMantle().flag(x>>4, z>>4, MantleFlag.REAL, true);
getMetrics().getTotal().put(p.getMilliseconds());
generated.incrementAndGet();
diff --git a/src/main/java/com/volmit/iris/util/data/ChunkCache.java b/src/main/java/com/volmit/iris/util/data/ChunkCache.java
new file mode 100644
index 000000000..6b0be1d26
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/data/ChunkCache.java
@@ -0,0 +1,53 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.volmit.iris.util.data;
+
+import com.volmit.iris.util.function.Function2;
+
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+
+public class ChunkCache {
+ private final AtomicReferenceArray cache;
+
+ public ChunkCache() {
+ cache = new AtomicReferenceArray<>(256);
+ }
+
+ public T compute(int x, int z, Function2 function)
+ {
+ T t = get(x&15, z&15);
+
+ if(t == null)
+ {
+ t = function.apply(x, z);
+ set(x&15, z&15, t);
+ }
+
+ return t;
+ }
+
+ private void set(int x, int z, T t) {
+ cache.set(x * 16 + z, t);
+ }
+
+ private T get(int x, int z) {
+ return cache.get(x * 16 + z);
+ }
+}
diff --git a/src/main/java/com/volmit/iris/util/data/ComplexCache.java b/src/main/java/com/volmit/iris/util/data/ComplexCache.java
new file mode 100644
index 000000000..2d4db1958
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/data/ComplexCache.java
@@ -0,0 +1,46 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.volmit.iris.util.data;
+
+import com.volmit.iris.engine.data.cache.Cache;
+import com.volmit.iris.util.collection.KMap;
+
+public class ComplexCache {
+ private KMap> chunks;
+
+ public ComplexCache()
+ {
+ chunks = new KMap<>();
+ }
+
+ public boolean has(int x, int z)
+ {
+ return chunks.containsKey(Cache.key(x, z));
+ }
+
+ public void invalidate(int x, int z)
+ {
+ chunks.remove(Cache.key(x, z));
+ }
+
+ public ChunkCache chunk(int x, int z)
+ {
+ return chunks.computeIfAbsent(Cache.key(x, z), (f) -> new ChunkCache<>());
+ }
+}
diff --git a/src/main/java/com/volmit/iris/util/data/Heafty.java b/src/main/java/com/volmit/iris/util/data/Heafty.java
new file mode 100644
index 000000000..f0995987b
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/data/Heafty.java
@@ -0,0 +1,24 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.volmit.iris.util.data;
+
+@FunctionalInterface
+public interface Heafty {
+ int getHeaft();
+}
diff --git a/src/main/java/com/volmit/iris/util/data/KCache.java b/src/main/java/com/volmit/iris/util/data/KCache.java
index d8276288d..cecef8303 100644
--- a/src/main/java/com/volmit/iris/util/data/KCache.java
+++ b/src/main/java/com/volmit/iris/util/data/KCache.java
@@ -21,18 +21,29 @@ package com.volmit.iris.util.data;
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
+import com.volmit.iris.Iris;
import com.volmit.iris.engine.framework.MeteredCache;
+import com.volmit.iris.util.format.Form;
+import com.volmit.iris.util.scheduling.J;
+import java.util.concurrent.TimeUnit;
import java.util.function.Function;
public class KCache implements MeteredCache {
- private long max;
+ private final long max;
private CacheLoader loader;
private LoadingCache cache;
+ private final boolean fastDump;
public KCache(CacheLoader loader, long max)
+ {
+ this(loader, max, false);
+ }
+
+ public KCache(CacheLoader loader, long max, boolean fastDump)
{
this.max = max;
+ this.fastDump = fastDump;
this.loader = loader;
this.cache = create(loader);
}
@@ -41,6 +52,9 @@ public class KCache implements MeteredCache {
return Caffeine
.newBuilder()
.maximumSize(max)
+ .initialCapacity((int) (max))
+ .softValues()
+ .expireAfterAccess(5, TimeUnit.MINUTES)
.build((k) -> loader == null ? null : loader.load(k));
}
@@ -57,9 +71,7 @@ public class KCache implements MeteredCache {
public void invalidate()
{
- LoadingCache,?> c = cache;
- cache = create(loader);
- c.invalidateAll();
+ cache.invalidateAll();
}
public V get(K k)
diff --git a/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java b/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java
index e2de6093a..082417576 100644
--- a/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java
+++ b/src/main/java/com/volmit/iris/util/stream/ProceduralStream.java
@@ -24,6 +24,7 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.IRare;
import com.volmit.iris.engine.object.IrisStyledRange;
import com.volmit.iris.util.collection.KList;
+import com.volmit.iris.util.data.ComplexCache;
import com.volmit.iris.util.function.Function2;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.function.Function4;
@@ -288,12 +289,8 @@ public interface ProceduralStream extends ProceduralLayer, Interpolated {
return new To3DStream(this);
}
- default ProceduralStream cache2D(Engine engine, int maxSize) {
- return cache2D(engine, maxSize, false);
- }
-
- default ProceduralStream cache2D(Engine engine, int maxSize, boolean weak) {
- return new CachedStream2D(engine, this, maxSize, weak);
+ default ProceduralStream cache2D(Engine engine, int size) {
+ return new CachedStream2D(engine, this, size);
}
default ProceduralStream cache3D(Engine engine, int maxSize) {
diff --git a/src/main/java/com/volmit/iris/util/stream/utility/CachedStream2D.java b/src/main/java/com/volmit/iris/util/stream/utility/CachedStream2D.java
index fa6f4e2fd..16d7b380b 100644
--- a/src/main/java/com/volmit/iris/util/stream/utility/CachedStream2D.java
+++ b/src/main/java/com/volmit/iris/util/stream/utility/CachedStream2D.java
@@ -27,6 +27,7 @@ import com.volmit.iris.core.service.PreservationSVC;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.MeteredCache;
+import com.volmit.iris.util.data.ComplexCache;
import com.volmit.iris.util.data.KCache;
import com.volmit.iris.util.stream.BasicStream;
import com.volmit.iris.util.stream.ProceduralStream;
@@ -36,7 +37,7 @@ public class CachedStream2D extends BasicStream implements ProceduralStrea
private final KCache cache;
private final Engine engine;
- public CachedStream2D(Engine engine, ProceduralStream stream, int size, boolean weak) {
+ public CachedStream2D(Engine engine, ProceduralStream stream, int size) {
super();
this.stream = stream;
this.engine = engine;