mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 06:41:08 +00:00
+2
-2
@@ -298,7 +298,7 @@ def registerCustomOutputTask(name, path) {
|
|||||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||||
into(file(path))
|
into(file(path))
|
||||||
rename { String fileName ->
|
rename { String fileName ->
|
||||||
fileName.replace("Iris-" + version + ".jar", "Iris- "+ version +".jar")
|
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ def registerCustomOutputTaskUnix(name, path) {
|
|||||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||||
into(file(path))
|
into(file(path))
|
||||||
rename { String fileName ->
|
rename { String fileName ->
|
||||||
fileName.replace("Iris-" + version + ".jar", "Iris- "+ version +".jar")
|
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import com.volmit.iris.util.collection.KMap;
|
|||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -467,4 +469,38 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
|||||||
public boolean isClosed() {
|
public boolean isClosed() {
|
||||||
return closed;
|
return closed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void savePrefetch(Engine engine) {
|
||||||
|
BurstExecutor b = MultiBurst.burst.burst(loaders.size());
|
||||||
|
|
||||||
|
for(ResourceLoader<?> i : loaders.values()) {
|
||||||
|
b.queue(() -> {
|
||||||
|
try {
|
||||||
|
i.saveFirstAccess(engine);
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
b.complete();
|
||||||
|
Iris.info("Saved Prefetch Cache to speed up future world startups");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadPrefetch(Engine engine) {
|
||||||
|
BurstExecutor b = MultiBurst.burst.burst(loaders.size());
|
||||||
|
|
||||||
|
for(ResourceLoader<?> i : loaders.values()) {
|
||||||
|
b.queue(() -> {
|
||||||
|
try {
|
||||||
|
i.loadFirstAccess(engine);
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
b.complete();
|
||||||
|
Iris.info("Loaded Prefetch Cache to reduce generation disk use.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -23,32 +23,51 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.project.SchemaBuilder;
|
import com.volmit.iris.core.project.SchemaBuilder;
|
||||||
import com.volmit.iris.core.service.PreservationSVC;
|
import com.volmit.iris.core.service.PreservationSVC;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.data.KCache;
|
import com.volmit.iris.util.data.KCache;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import com.volmit.iris.util.io.CustomOutputStream;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.json.JSONArray;
|
import com.volmit.iris.util.json.JSONArray;
|
||||||
import com.volmit.iris.util.json.JSONObject;
|
import com.volmit.iris.util.json.JSONObject;
|
||||||
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
||||||
public static final AtomicDouble tlt = new AtomicDouble(0);
|
public static final AtomicDouble tlt = new AtomicDouble(0);
|
||||||
private static final int CACHE_SIZE = 100000;
|
private static final int CACHE_SIZE = 100000;
|
||||||
|
protected KSet<String> firstAccess;
|
||||||
protected File root;
|
protected File root;
|
||||||
protected String folderName;
|
protected String folderName;
|
||||||
protected String resourceTypeName;
|
protected String resourceTypeName;
|
||||||
@@ -63,6 +82,7 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
|
|
||||||
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
public ResourceLoader(File root, IrisData manager, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
firstAccess = new KSet<>();
|
||||||
folderCache = new AtomicReference<>();
|
folderCache = new AtomicReference<>();
|
||||||
sec = new ChronoLatch(5000);
|
sec = new ChronoLatch(5000);
|
||||||
loads = new AtomicInteger();
|
loads = new AtomicInteger();
|
||||||
@@ -221,6 +241,24 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KList<T> loadAllParallel(KList<String> s) {
|
||||||
|
KList<T> m = new KList<>();
|
||||||
|
BurstExecutor burst = MultiBurst.burst.burst(s.size());
|
||||||
|
|
||||||
|
for(String i : s) {
|
||||||
|
burst.queue(() -> {
|
||||||
|
T t = load(i);
|
||||||
|
|
||||||
|
if(t != null) {
|
||||||
|
m.add(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
burst.complete();
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
public KList<T> loadAll(KList<String> s, Consumer<T> postLoad) {
|
public KList<T> loadAll(KList<String> s, Consumer<T> postLoad) {
|
||||||
KList<T> m = new KList<>();
|
KList<T> m = new KList<>();
|
||||||
|
|
||||||
@@ -282,12 +320,52 @@ public class ResourceLoader<T extends IrisRegistrant> implements MeteredCache {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstAccess.add(name);
|
||||||
return loadCache.get(name);
|
return loadCache.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadFirstAccess(Engine engine) throws IOException
|
||||||
|
{
|
||||||
|
String id = "DIM" + Math.abs(engine.getSeedManager().getSeed() + engine.getDimension().getVersion() + engine.getDimension().getLoadKey().hashCode());
|
||||||
|
File file = Iris.instance.getDataFile("prefetch/" + id + "/" + Math.abs(getFolderName().hashCode()) + ".ipfch");
|
||||||
|
|
||||||
|
if(!file.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInputStream fin = new FileInputStream(file);
|
||||||
|
GZIPInputStream gzi = new GZIPInputStream(fin);
|
||||||
|
DataInputStream din = new DataInputStream(gzi);
|
||||||
|
int m = din.readInt();
|
||||||
|
KList<String> s = new KList<>();
|
||||||
|
|
||||||
|
for(int i = 0; i < m; i++) {
|
||||||
|
s.add(din.readUTF());
|
||||||
|
}
|
||||||
|
|
||||||
|
din.close();
|
||||||
|
file.deleteOnExit();
|
||||||
|
Iris.info("Loading " + s.size() + " prefetch " + getFolderName());
|
||||||
|
loadAllParallel(s);
|
||||||
|
}
|
||||||
|
public void saveFirstAccess(Engine engine) throws IOException {
|
||||||
|
String id = "DIM" + Math.abs(engine.getSeedManager().getSeed() + engine.getDimension().getVersion() + engine.getDimension().getLoadKey().hashCode());
|
||||||
|
File file = Iris.instance.getDataFile("prefetch/" + id + "/" + Math.abs(getFolderName().hashCode()) + ".ipfch");
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
GZIPOutputStream gzo = new CustomOutputStream(fos, 9);
|
||||||
|
DataOutputStream dos = new DataOutputStream(gzo);
|
||||||
|
dos.writeInt(firstAccess.size());
|
||||||
|
|
||||||
|
for(String i : firstAccess) {
|
||||||
|
dos.writeUTF(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
dos.flush();
|
||||||
|
dos.close();
|
||||||
|
}
|
||||||
|
|
||||||
public KList<File> getFolders() {
|
public KList<File> getFolders() {
|
||||||
|
|
||||||
|
|
||||||
synchronized(folderCache) {
|
synchronized(folderCache) {
|
||||||
if(folderCache.get() == null) {
|
if(folderCache.get() == null) {
|
||||||
KList<File> fc = new KList<>();
|
KList<File> fc = new KList<>();
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.volmit.iris.engine.object.IrisRegion;
|
|||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.data.DataProvider;
|
import com.volmit.iris.util.data.DataProvider;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
@@ -132,28 +133,32 @@ public class IrisComplex implements DataProvider {
|
|||||||
.cache2D("regionStream", engine, cacheSize).waste("Region Stream");
|
.cache2D("regionStream", engine, cacheSize).waste("Region Stream");
|
||||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i),
|
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i),
|
||||||
String.valueOf(i * 38445).hashCode() * 3245556666L)).waste("Region ID Stream");
|
String.valueOf(i * 38445).hashCode() * 3245556666L)).waste("Region ID Stream");
|
||||||
caveBiomeStream = regionStream.convert((r)
|
caveBiomeStream = regionStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
|
||||||
|
.convert((r)
|
||||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
||||||
.zoom(r.getCaveBiomeZoom())
|
.zoom(r.getCaveBiomeZoom())
|
||||||
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
|
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
|
||||||
.onNull(emptyBiome)
|
.onNull(emptyBiome)
|
||||||
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize).waste("Cave Biome Stream");
|
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize).waste("Cave Biome Stream");
|
||||||
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
||||||
landBiomeStream = regionStream.convert((r)
|
landBiomeStream = regionStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
|
||||||
|
.convert((r)
|
||||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
||||||
.zoom(r.getLandBiomeZoom())
|
.zoom(r.getLandBiomeZoom())
|
||||||
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
|
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
|
||||||
).convertAware2D(ProceduralStream::get)
|
).convertAware2D(ProceduralStream::get)
|
||||||
.cache2D("landBiomeStream", engine, cacheSize).waste("Land Biome Stream");
|
.cache2D("landBiomeStream", engine, cacheSize).waste("Land Biome Stream");
|
||||||
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
||||||
seaBiomeStream = regionStream.convert((r)
|
seaBiomeStream = regionStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
|
||||||
|
.convert((r)
|
||||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
||||||
.zoom(r.getSeaBiomeZoom())
|
.zoom(r.getSeaBiomeZoom())
|
||||||
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
|
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
|
||||||
).convertAware2D(ProceduralStream::get)
|
).convertAware2D(ProceduralStream::get)
|
||||||
.cache2D("seaBiomeStream", engine, cacheSize).waste("Sea Biome Stream");
|
.cache2D("seaBiomeStream", engine, cacheSize).waste("Sea Biome Stream");
|
||||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||||
shoreBiomeStream = regionStream.convert((r)
|
shoreBiomeStream = regionStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getRegion().get(x, z))
|
||||||
|
.convert((r)
|
||||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
||||||
.zoom(r.getShoreBiomeZoom())
|
.zoom(r.getShoreBiomeZoom())
|
||||||
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
|
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
|
||||||
@@ -173,34 +178,39 @@ public class IrisComplex implements DataProvider {
|
|||||||
heightStream = ProceduralStream.of((x, z) -> {
|
heightStream = ProceduralStream.of((x, z) -> {
|
||||||
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
||||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
||||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize).waste("Height Stream");
|
}, Interpolated.DOUBLE).cache2D("heightStream", engine, cacheSize).waste("Height Stream");
|
||||||
roundedHeighteightStream = heightStream.round().waste("Rounded Height Stream");
|
roundedHeighteightStream = heightStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
|
||||||
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize).waste("Slope Stream");
|
.round().waste("Rounded Height Stream");
|
||||||
|
slopeStream = heightStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
|
||||||
|
.slope(3).cache2D("slopeStream", engine, cacheSize).waste("Slope Stream");
|
||||||
trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D,
|
trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D,
|
||||||
b -> focusBiome))
|
b -> focusBiome))
|
||||||
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
||||||
.convertAware2D((h, x, z) ->
|
.convertAware2D((h, x, z) ->
|
||||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||||
regionStream.get(x, z), x, z, fluidHeight))
|
regionStream.contextInjecting((c,xx,zz)-> IrisContext.getOr(engine).getChunkContext().getRegion().get(xx, zz)).get(x, z), x, z, fluidHeight))
|
||||||
.cache2D("trueBiomeStream", engine, cacheSize).waste("True Biome Stream");
|
.cache2D("trueBiomeStream", engine, cacheSize).waste("True Biome Stream");
|
||||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize).waste("True Biome Derivative Stream");
|
trueBiomeDerivativeStream = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize).waste("Height Fluid Stream");
|
.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize).waste("True Biome Derivative Stream");
|
||||||
|
heightFluidStream = heightStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getHeight().get(x, z))
|
||||||
|
.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize).waste("Height Fluid Stream");
|
||||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height).waste("Max Height Stream");
|
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height).waste("Max Height Stream");
|
||||||
terrainSurfaceDecoration = trueBiomeStream
|
terrainSurfaceDecoration = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize).waste("Surface Decoration Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize).waste("Surface Decoration Stream");
|
||||||
terrainCeilingDecoration = trueBiomeStream
|
terrainCeilingDecoration = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize).waste("Ceiling Decoration Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize).waste("Ceiling Decoration Stream");
|
||||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
terrainCaveSurfaceDecoration = caveBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getCave().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize).waste("Cave Surface Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize).waste("Cave Surface Stream");
|
||||||
terrainCaveCeilingDecoration = caveBiomeStream
|
terrainCaveCeilingDecoration = caveBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getCave().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize).waste("Cave Ceiling Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize).waste("Cave Ceiling Stream");
|
||||||
shoreSurfaceDecoration = trueBiomeStream
|
shoreSurfaceDecoration = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize).waste("Shore Surface Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize).waste("Shore Surface Stream");
|
||||||
seaSurfaceDecoration = trueBiomeStream
|
seaSurfaceDecoration = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize).waste("Sea Surface Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize).waste("Sea Surface Stream");
|
||||||
seaFloorDecoration = trueBiomeStream
|
seaFloorDecoration = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize).waste("Sea Floor Stream");
|
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize).waste("Sea Floor Stream");
|
||||||
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
baseBiomeIDStream = trueBiomeStream.contextInjecting((c,x,z)-> IrisContext.getOr(engine).getChunkContext().getBiome().get(x, z))
|
||||||
|
.convertAware2D((b, x, z) -> {
|
||||||
UUID d = regionIDStream.get(x, z);
|
UUID d = regionIDStream.get(x, z);
|
||||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||||
d.hashCode());
|
d.hashCode());
|
||||||
@@ -318,7 +328,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});;
|
||||||
|
|
||||||
double d = 0;
|
double d = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -129,8 +129,9 @@ public class IrisEngine implements Engine {
|
|||||||
context = new IrisContext(this);
|
context = new IrisContext(this);
|
||||||
cleaning = new AtomicBoolean(false);
|
cleaning = new AtomicBoolean(false);
|
||||||
context.touch();
|
context.touch();
|
||||||
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getDimension().getDimensionHeight() + " height) Seed: " + getSeedManager().getSeed());
|
|
||||||
getData().setEngine(this);
|
getData().setEngine(this);
|
||||||
|
getData().loadPrefetch(this);
|
||||||
|
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getDimension().getDimensionHeight() + " height) Seed: " + getSeedManager().getSeed());
|
||||||
minHeight = 0;
|
minHeight = 0;
|
||||||
failing = false;
|
failing = false;
|
||||||
closed = false;
|
closed = false;
|
||||||
@@ -146,6 +147,7 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tickRandomPlayer() {
|
private void tickRandomPlayer() {
|
||||||
|
recycle();
|
||||||
if(perSecondBudLatch.flip()) {
|
if(perSecondBudLatch.flip()) {
|
||||||
buds.set(bud.get());
|
buds.set(bud.get());
|
||||||
bud.set(0);
|
bud.set(0);
|
||||||
@@ -454,7 +456,10 @@ public class IrisEngine implements Engine {
|
|||||||
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
generated.incrementAndGet();
|
generated.incrementAndGet();
|
||||||
recycle();
|
|
||||||
|
if(generated.get() == 661) {
|
||||||
|
J.a(() -> getData().savePrefetch(this));
|
||||||
|
}
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
fail("Failed to generate " + x + ", " + z, e);
|
fail("Failed to generate " + x + ", " + z, e);
|
||||||
|
|||||||
@@ -78,14 +78,11 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
|||||||
@Override
|
@Override
|
||||||
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore, ChunkContext context) {
|
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore, ChunkContext context) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
BurstExecutor burst = burst().burst(PaperLib.isPaper() && multicore);
|
|
||||||
|
|
||||||
for(int xf = 0; xf < h.getWidth(); xf++) {
|
for(int xf = 0; xf < h.getWidth(); xf++) {
|
||||||
int finalXf = xf;
|
|
||||||
burst.queue(() -> {
|
|
||||||
IrisBiome ib;
|
IrisBiome ib;
|
||||||
for(int zf = 0; zf < h.getDepth(); zf++) {
|
for(int zf = 0; zf < h.getDepth(); zf++) {
|
||||||
ib = context.getBiome().get(finalXf, zf);
|
ib = context.getBiome().get(xf, zf);
|
||||||
int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData()));
|
int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData()));
|
||||||
if(ib.isCustom()) {
|
if(ib.isCustom()) {
|
||||||
try {
|
try {
|
||||||
@@ -97,13 +94,13 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < maxHeight; i++) {
|
for(int i = 0; i < maxHeight; i++) {
|
||||||
injectBiome(h, finalXf, i, zf, biomeBase);
|
injectBiome(h, xf, i, zf, biomeBase);
|
||||||
}
|
}
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
Biome v = ib.getSkyBiome(rng, x, 0, z);
|
Biome v = ib.getSkyBiome(rng, x, 0, z);
|
||||||
for(int i = 0; i < maxHeight; i++) {
|
for(int i = 0; i < maxHeight; i++) {
|
||||||
h.set(finalXf, i, zf, v);
|
h.set(xf, i, zf, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -111,17 +108,15 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
|||||||
|
|
||||||
if(v != null) {
|
if(v != null) {
|
||||||
for(int i = 0; i < maxHeight; i++) {
|
for(int i = 0; i < maxHeight; i++) {
|
||||||
h.set(finalXf, i, zf, v);
|
h.set(xf, i, zf, v);
|
||||||
}
|
}
|
||||||
} else if(cl.flip()) {
|
} else if(cl.flip()) {
|
||||||
Iris.error("No biome provided for " + ib.getLoadKey());
|
Iris.error("No biome provided for " + ib.getLoadKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
burst.complete();
|
|
||||||
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
|
getEngine().getMetrics().getBiome().put(p.getMilliseconds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,10 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
BurstExecutor burst = burst().burst(multicore);
|
|
||||||
|
|
||||||
for(int i = 0; i < output.getWidth(); i++) {
|
for(int i = 0; i < output.getWidth(); i++) {
|
||||||
int finalI = i;
|
|
||||||
burst.queue(() -> {
|
|
||||||
int height;
|
int height;
|
||||||
int realX = Math.round(x + finalI);
|
int realX = Math.round(x + i);
|
||||||
int realZ;
|
int realZ;
|
||||||
IrisBiome biome, cave;
|
IrisBiome biome, cave;
|
||||||
for(int j = 0; j < output.getDepth(); j++) {
|
for(int j = 0; j < output.getDepth(); j++) {
|
||||||
@@ -87,42 +84,42 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
int emptyFor = 0;
|
int emptyFor = 0;
|
||||||
int lastSolid = 0;
|
int lastSolid = 0;
|
||||||
realZ = Math.round(z + j);
|
realZ = Math.round(z + j);
|
||||||
height = (int) Math.round(context.getHeight().get(finalI, j));
|
height = (int) Math.round(context.getHeight().get(i, j));
|
||||||
biome = context.getBiome().get(finalI, j);
|
biome = context.getBiome().get(i, j);
|
||||||
cave = shouldRay ? context.getCave().get(finalI, j) : null;
|
cave = shouldRay ? context.getCave().get(i, j) : null;
|
||||||
|
|
||||||
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(height < getDimension().getFluidHeight()) {
|
if(height < getDimension().getFluidHeight()) {
|
||||||
getSeaSurfaceDecorator().decorate(finalI, j,
|
getSeaSurfaceDecorator().decorate(i, j,
|
||||||
realX, Math.round(finalI + 1), Math.round(x + finalI - 1),
|
realX, Math.round(i + 1), Math.round(x + i - 1),
|
||||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||||
output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
|
output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
|
||||||
getSeaFloorDecorator().decorate(finalI, j,
|
getSeaFloorDecorator().decorate(i, j,
|
||||||
realX, realZ, output, biome, height + 1,
|
realX, realZ, output, biome, height + 1,
|
||||||
getDimension().getFluidHeight() + 1);
|
getDimension().getFluidHeight() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(height == getDimension().getFluidHeight()) {
|
if(height == getDimension().getFluidHeight()) {
|
||||||
getShoreLineDecorator().decorate(finalI, j,
|
getShoreLineDecorator().decorate(i, j,
|
||||||
realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1),
|
realX, Math.round(x + i + 1), Math.round(x + i - 1),
|
||||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||||
output, biome, height, getEngine().getHeight());
|
output, biome, height, getEngine().getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
||||||
|
|
||||||
|
|
||||||
if(cave != null && cave.getDecorators().isNotEmpty()) {
|
if(cave != null && cave.getDecorators().isNotEmpty()) {
|
||||||
for(int k = height; k > 0; k--) {
|
for(int k = height; k > 0; k--) {
|
||||||
solid = PREDICATE_SOLID.test(output.get(finalI, k, j));
|
solid = PREDICATE_SOLID.test(output.get(i, k, j));
|
||||||
|
|
||||||
if(solid) {
|
if(solid) {
|
||||||
if(emptyFor > 0) {
|
if(emptyFor > 0) {
|
||||||
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, cave, k, lastSolid);
|
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid);
|
||||||
getCeilingDecorator().decorate(finalI, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||||
emptyFor = 0;
|
emptyFor = 0;
|
||||||
}
|
}
|
||||||
lastSolid = k;
|
lastSolid = k;
|
||||||
@@ -132,10 +129,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
burst.complete();
|
|
||||||
getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
|
getEngine().getMetrics().getDecoration().put(p.getMilliseconds());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.volmit.iris.util.context.ChunkContext;
|
|||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -54,14 +53,10 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
|
||||||
BurstExecutor e = burst().burst(multicore);
|
|
||||||
for(int xf = 0; xf < h.getWidth(); xf++) {
|
for(int xf = 0; xf < h.getWidth(); xf++) {
|
||||||
int finalXf = xf;
|
terrainSliver(x, z, xf, h, context);
|
||||||
e.queue(() -> terrainSliver(x, z, finalXf, h, context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.complete();
|
|
||||||
|
|
||||||
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
getEngine().getMetrics().getTerrain().put(p.getMilliseconds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,9 +146,6 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(BlockBreakEvent e) {
|
public void on(BlockBreakEvent e) {
|
||||||
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||||
|
|
||||||
WasteDetector.printAll();
|
|
||||||
|
|
||||||
onBlockBreak(e);
|
onBlockBreak(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,16 +73,11 @@ public interface EngineMode extends Staged {
|
|||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) {
|
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) {
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
|
||||||
PrecisionStopwatch p2 = PrecisionStopwatch.start();
|
|
||||||
ChunkContext ctx = new ChunkContext(x, z, getComplex());
|
ChunkContext ctx = new ChunkContext(x, z, getComplex());
|
||||||
IrisContext.getOr(getEngine()).setChunkContext(ctx);
|
IrisContext.getOr(getEngine()).setChunkContext(ctx);
|
||||||
r.put(p.getMilliseconds());
|
|
||||||
|
|
||||||
for(EngineStage i : getStages()) {
|
for(EngineStage i : getStages()) {
|
||||||
i.generate(x, z, blocks, biomes, multicore, ctx);
|
i.generate(x, z, blocks, biomes, multicore, ctx);
|
||||||
}
|
}
|
||||||
r2.put(p2.getMilliseconds());
|
|
||||||
// Iris.warn(Form.duration(r.getAverage(), 2) + " Prep: TOTAL: " + C.RED + Form.duration(r2.getAverage(), 2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||||
IrisRegion region = context.getRegion().get(8, 8);
|
int xxx = 8 + (x << 4);
|
||||||
IrisBiome biome = context.getBiome().get(8, 8);
|
int zzz = 8 + (z << 4);
|
||||||
|
IrisRegion region =getComplex().getRegionStream().get(xxx, zzz);
|
||||||
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
carve(writer, rng, x, z, region, biome);
|
carve(writer, rng, x, z, region, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -38,8 +38,10 @@ public class MantleFluidBodyComponent extends IrisMantleComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
RNG rng = new RNG(Cache.key(x, z) + seed() + 405666);
|
RNG rng = new RNG(Cache.key(x, z) + seed() + 405666);
|
||||||
IrisRegion region = context.getRegion().get(8, 8);
|
int xxx = 8 + (x << 4);
|
||||||
IrisBiome biome = context.getBiome().get(8, 8);
|
int zzz = 8 + (z << 4);
|
||||||
|
IrisRegion region =getComplex().getRegionStream().get(xxx, zzz);
|
||||||
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
generate(writer, rng, x, z, region, biome);
|
generate(writer, rng, x, z, region, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,10 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z));
|
RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z));
|
||||||
IrisRegion region = context.getRegion().get(8, 8);
|
int xxx = 8 + (x << 4);
|
||||||
IrisBiome biome = context.getBiome().get(8, 8);
|
int zzz = 8 + (z << 4);
|
||||||
|
IrisRegion region =getComplex().getRegionStream().get(xxx, zzz);
|
||||||
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
generateJigsaw(writer, rng, x, z, biome, region);
|
generateJigsaw(writer, rng, x, z, biome, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
|||||||
@Override
|
@Override
|
||||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||||
IrisRegion region = context.getRegion().get(8, 8);
|
int xxx = 8 + (x << 4);
|
||||||
IrisBiome biome = context.getBiome().get(8, 8);
|
int zzz = 8 + (z << 4);
|
||||||
|
IrisRegion region =getComplex().getRegionStream().get(xxx, zzz);
|
||||||
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
placeObjects(writer, rng, x, z, biome, region);
|
placeObjects(writer, rng, x, z, biome, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
|||||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineMode;
|
import com.volmit.iris.engine.framework.EngineMode;
|
||||||
|
import com.volmit.iris.engine.framework.EngineStage;
|
||||||
import com.volmit.iris.engine.framework.IrisEngineMode;
|
import com.volmit.iris.engine.framework.IrisEngineMode;
|
||||||
import com.volmit.iris.engine.modifier.IrisCarveModifier;
|
import com.volmit.iris.engine.modifier.IrisCarveModifier;
|
||||||
import com.volmit.iris.engine.modifier.IrisDepositModifier;
|
import com.volmit.iris.engine.modifier.IrisDepositModifier;
|
||||||
@@ -40,17 +41,31 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
|||||||
var post = new IrisPostModifier(getEngine());
|
var post = new IrisPostModifier(getEngine());
|
||||||
var deposit = new IrisDepositModifier(getEngine());
|
var deposit = new IrisDepositModifier(getEngine());
|
||||||
var perfection = new IrisPerfectionModifier(getEngine());
|
var perfection = new IrisPerfectionModifier(getEngine());
|
||||||
|
EngineStage sBiome = (x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c);
|
||||||
|
EngineStage sGenMatter = (x, z, k, p, m, c) -> generateMatter(x >> 4, z >> 4, m, c);
|
||||||
|
EngineStage sTerrain = (x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c);
|
||||||
|
EngineStage sDecorant = (x, z, k, p, m, c) -> decorant.actuate(x, z, k, m, c);
|
||||||
|
EngineStage sCave = (x, z, k, p, m, c) -> cave.modify(x >> 4, z >> 4, k, m, c);
|
||||||
|
EngineStage sDeposit = (x, z, k, p, m, c) -> deposit.modify(x, z, k, m,c);
|
||||||
|
EngineStage sPost = (x, z, k, p, m, c) -> post.modify(x, z, k, m, c);
|
||||||
|
EngineStage sInsertMatter = (x, z, K, p, m, c) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m);
|
||||||
|
EngineStage sPerfection = (x, z, k, p, m, c) -> perfection.modify(x, z, k, m, c);
|
||||||
|
|
||||||
registerStage((x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c));
|
|
||||||
registerStage(burst(
|
registerStage(burst(
|
||||||
(x, z, k, p, m, c) -> generateMatter(x >> 4, z >> 4, m, c),
|
sBiome,
|
||||||
(x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c)
|
sGenMatter,
|
||||||
|
sTerrain
|
||||||
));
|
));
|
||||||
registerStage((x, z, k, p, m, c) -> cave.modify(x >> 4, z >> 4, k, m, c));
|
registerStage(burst(
|
||||||
registerStage((x, z, k, p, m, c) -> deposit.modify(x, z, k, m,c));
|
sCave,
|
||||||
registerStage((x, z, k, p, m, c) -> decorant.actuate(x, z, k, m, c));
|
sPost
|
||||||
registerStage((x, z, k, p, m, c) -> post.modify(x, z, k, m, c));
|
));
|
||||||
registerStage((x, z, K, p, m, c) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m));
|
registerStage(burst(
|
||||||
registerStage((x, z, k, p, m, c) -> perfection.modify(x, z, k, m, c));
|
sDeposit,
|
||||||
|
sInsertMatter,
|
||||||
|
sDecorant
|
||||||
|
));
|
||||||
|
registerStage(sPerfection);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
if(i == buf + 1) {
|
if(i == buf + 1) {
|
||||||
buf = i;
|
buf = i;
|
||||||
zone.ceiling = buf;
|
zone.ceiling = buf;
|
||||||
} else if(zone.isValid()) {
|
} else if(zone.isValid(getEngine())) {
|
||||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||||
zone = new CaveZone();
|
zone = new CaveZone();
|
||||||
zone.setFloor(i);
|
zone.setFloor(i);
|
||||||
@@ -165,7 +165,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zone.isValid()) {
|
if(zone.isValid(getEngine())) {
|
||||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -276,8 +276,8 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
return (ceiling - floor) - 1;
|
return (ceiling - floor) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid(Engine engine) {
|
||||||
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= IrisContext.get().getEngine().getHeight() && airThickness() > 0;
|
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= engine.getHeight() && airThickness() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.volmit.iris.util.cache;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.data.ChunkCache;
|
||||||
|
import com.volmit.iris.util.function.Function2;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class ChunkCache2D<T> {
|
||||||
|
private final AtomicReferenceArray<T> cache;
|
||||||
|
|
||||||
|
public ChunkCache2D() {
|
||||||
|
this.cache = new AtomicReferenceArray<>(256);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(int x, int z, Function2<Integer, Integer, T> resolver) {
|
||||||
|
int key = ((z & 15) * 16) + (x & 15);
|
||||||
|
T t = cache.get(key);
|
||||||
|
|
||||||
|
if(t == null) {
|
||||||
|
t = resolver.apply(x, z);
|
||||||
|
cache.set(key, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.volmit.iris.util.cache;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
|
import com.volmit.iris.util.context.ChunkedDataCache;
|
||||||
|
import com.volmit.iris.util.data.KCache;
|
||||||
|
import com.volmit.iris.util.function.Function2;
|
||||||
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
|
import it.unimi.dsi.fastutil.longs.Long2LongMaps;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
public class WorldCache2D<T> {
|
||||||
|
private final KCache<Long, ChunkCache2D<T>> chunks;
|
||||||
|
private final Function2<Integer, Integer, T> resolver;
|
||||||
|
|
||||||
|
public WorldCache2D(Function2<Integer, Integer, T> resolver) {
|
||||||
|
this.resolver = resolver;
|
||||||
|
chunks = new KCache<>((x) -> new ChunkCache2D<>(), 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(int x, int z) {
|
||||||
|
ChunkCache2D<T> chunk = chunks.get(Cache.key(x >> 4, z >> 4));
|
||||||
|
return chunk.get(x, z, resolver);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return chunks.getSize() * 256L;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.volmit.iris.util.context;
|
|||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
import com.volmit.iris.engine.object.IrisRegion;
|
||||||
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.parallel.MultiBurst;
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
@@ -28,6 +29,7 @@ public class ChunkContext {
|
|||||||
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
if(cache) {
|
if(cache) {
|
||||||
BurstExecutor b = MultiBurst.burst.burst();
|
BurstExecutor b = MultiBurst.burst.burst();
|
||||||
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
package com.volmit.iris.util.context;
|
package com.volmit.iris.util.context;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.util.stream.ProceduralStream;
|
import com.volmit.iris.util.stream.ProceduralStream;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class ChunkedDataCache<T> {
|
public class ChunkedDataCache<T> {
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int z;
|
private final int z;
|
||||||
|
private final KSet<T> uniques;
|
||||||
private final Object[] data;
|
private final Object[] data;
|
||||||
private final boolean cache;
|
private final boolean cache;
|
||||||
private final ProceduralStream<T> stream;
|
private final ProceduralStream<T> stream;
|
||||||
@@ -21,6 +27,7 @@ public class ChunkedDataCache<T> {
|
|||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
this.uniques = cache ? new KSet<>() : null;
|
||||||
if(cache) {
|
if(cache) {
|
||||||
data = new Object[256];
|
data = new Object[256];
|
||||||
int i,j;
|
int i,j;
|
||||||
@@ -29,7 +36,11 @@ public class ChunkedDataCache<T> {
|
|||||||
int finalI = i;
|
int finalI = i;
|
||||||
for(j = 0; j < 16; j++) {
|
for(j = 0; j < 16; j++) {
|
||||||
int finalJ = j;
|
int finalJ = j;
|
||||||
burst.queue(() -> data[(finalJ * 16) + finalI] = stream.get(x+ finalI, z+ finalJ));
|
burst.queue(() -> {
|
||||||
|
T t = stream.get(x+ finalI, z+ finalJ);
|
||||||
|
data[(finalJ * 16) + finalI] = t;
|
||||||
|
uniques.add(t);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
|
|||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.temporal.TemporalUnit;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class KCache<K, V> implements MeteredCache {
|
public class KCache<K, V> implements MeteredCache {
|
||||||
private final long max;
|
private final long max;
|
||||||
private CacheLoader<K, V> loader;
|
private CacheLoader<K, V> loader;
|
||||||
@@ -46,7 +50,6 @@ public class KCache<K, V> implements MeteredCache {
|
|||||||
return Caffeine
|
return Caffeine
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.maximumSize(max)
|
.maximumSize(max)
|
||||||
.softValues()
|
|
||||||
.initialCapacity((int) (max))
|
.initialCapacity((int) (max))
|
||||||
.build((k) -> loader == null ? null : loader.load(k));
|
.build((k) -> loader == null ? null : loader.load(k));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public class ChunkDataHunkHolder extends AtomicHunk<BlockData> {
|
|||||||
for(int k = 0; k < getDepth(); k++) {
|
for(int k = 0; k < getDepth(); k++) {
|
||||||
BlockData b = super.getRaw(j, i, k);
|
BlockData b = super.getRaw(j, i, k);
|
||||||
|
|
||||||
if(b != null)
|
if(b != null) {
|
||||||
{
|
|
||||||
chunk.setBlock(j, i + chunk.getMinHeight(), k, b);
|
chunk.setBlock(j, i + chunk.getMinHeight(), k, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.hunk.view;
|
package com.volmit.iris.util.hunk.view;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.data.B;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
|
|
||||||
@SuppressWarnings("ClassCanBeRecord")
|
@SuppressWarnings("ClassCanBeRecord")
|
||||||
public class ChunkDataHunkView implements Hunk<BlockData> {
|
public class ChunkDataHunkView implements Hunk<BlockData> {
|
||||||
|
private static final BlockData AIR = B.getAir();
|
||||||
private final ChunkData chunk;
|
private final ChunkData chunk;
|
||||||
|
|
||||||
public ChunkDataHunkView(ChunkData chunk) {
|
public ChunkDataHunkView(ChunkData chunk) {
|
||||||
@@ -54,17 +56,44 @@ public class ChunkDataHunkView implements Hunk<BlockData> {
|
|||||||
chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, t);
|
chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BlockData get(int x, int y, int z) {
|
||||||
|
return getRaw(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(int x, int y, int z, BlockData t) {
|
||||||
|
setRaw(x, y, z, t);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(int x, int y, int z, BlockData t) {
|
public void setRaw(int x, int y, int z, BlockData t) {
|
||||||
if(t == null) {
|
if(t == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
chunk.setBlock(x, y + chunk.getMinHeight(), z, t);
|
chunk.setBlock(x, y + chunk.getMinHeight(), z, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(Throwable ignored)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockData getRaw(int x, int y, int z) {
|
public BlockData getRaw(int x, int y, int z) {
|
||||||
|
try {
|
||||||
|
|
||||||
return chunk.getBlockData(x, y + chunk.getMinHeight(), z);
|
return chunk.getBlockData(x, y + chunk.getMinHeight(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return AIR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -22,31 +22,7 @@ import com.volmit.iris.util.function.NoiseProvider;
|
|||||||
|
|
||||||
public class Starcast {
|
public class Starcast {
|
||||||
public static double starcast(int x, int z, double r, double checks, boolean optimized, NoiseProvider n) {
|
public static double starcast(int x, int z, double r, double checks, boolean optimized, NoiseProvider n) {
|
||||||
if(optimized) {
|
return CompiledStarcast.getStarcast((float)x, (float)z, (float)r, (float)checks, n);
|
||||||
if(checks == 3) return sc3(x, z, r, n);
|
|
||||||
else if(checks == 5) return sc5(x, z, r, n);
|
|
||||||
else if(checks == 6) return sc6(x, z, r, n);
|
|
||||||
else if(checks == 7) return sc7(x, z, r, n);
|
|
||||||
else if(checks == 9) return sc9(x, z, r, n);
|
|
||||||
else if(checks == 12) return sc12(x, z, r, n);
|
|
||||||
else if(checks == 24) return sc24(x, z, r, n);
|
|
||||||
else if(checks == 32) return sc32(x, z, r, n);
|
|
||||||
else if(checks == 48) return sc48(x, z, r, n);
|
|
||||||
else if(checks == 64) return sc64(x, z, r, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
double m = 360D / checks;
|
|
||||||
double v = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < 360; i += m) {
|
|
||||||
double sin = Math.sin(Math.toRadians(i));
|
|
||||||
double cos = Math.cos(Math.toRadians(i));
|
|
||||||
double cx = x + ((r * cos) - (r * sin));
|
|
||||||
double cz = z + ((r * sin) + (r * cos));
|
|
||||||
v += n.noise(cx, cz);
|
|
||||||
}
|
|
||||||
|
|
||||||
return v / checks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double starcast(int x, int z, double r, double checks, NoiseProvider n) {
|
public static double starcast(int x, int z, double r, double checks, NoiseProvider n) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.object.IRare;
|
import com.volmit.iris.engine.object.IRare;
|
||||||
import com.volmit.iris.engine.object.IrisStyledRange;
|
import com.volmit.iris.engine.object.IrisStyledRange;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.context.ChunkContext;
|
||||||
import com.volmit.iris.util.function.Function2;
|
import com.volmit.iris.util.function.Function2;
|
||||||
import com.volmit.iris.util.function.Function3;
|
import com.volmit.iris.util.function.Function3;
|
||||||
import com.volmit.iris.util.function.Function4;
|
import com.volmit.iris.util.function.Function4;
|
||||||
@@ -62,6 +63,7 @@ import com.volmit.iris.util.stream.interpolation.Interpolated;
|
|||||||
import com.volmit.iris.util.stream.sources.FunctionStream;
|
import com.volmit.iris.util.stream.sources.FunctionStream;
|
||||||
import com.volmit.iris.util.stream.utility.CachedStream2D;
|
import com.volmit.iris.util.stream.utility.CachedStream2D;
|
||||||
import com.volmit.iris.util.stream.utility.CachedStream3D;
|
import com.volmit.iris.util.stream.utility.CachedStream3D;
|
||||||
|
import com.volmit.iris.util.stream.utility.ContextInjectingStream;
|
||||||
import com.volmit.iris.util.stream.utility.NullSafeStream;
|
import com.volmit.iris.util.stream.utility.NullSafeStream;
|
||||||
import com.volmit.iris.util.stream.utility.ProfiledStream;
|
import com.volmit.iris.util.stream.utility.ProfiledStream;
|
||||||
import com.volmit.iris.util.stream.utility.SemaphoreStream;
|
import com.volmit.iris.util.stream.utility.SemaphoreStream;
|
||||||
@@ -135,12 +137,18 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
|||||||
return new AddingStream<>(this, a);
|
return new AddingStream<>(this, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default ProceduralStream<T> contextInjecting(Function3<ChunkContext, Integer, Integer, T> contextAccessor) {
|
||||||
|
//return this;
|
||||||
|
return new ContextInjectingStream<>(this, contextAccessor);
|
||||||
|
}
|
||||||
|
|
||||||
default ProceduralStream<T> add(ProceduralStream<Double> a) {
|
default ProceduralStream<T> add(ProceduralStream<Double> a) {
|
||||||
return add2D((x, z) -> a.get(x, z));
|
return add2D((x, z) -> a.get(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
default ProceduralStream<T> waste(String name) {
|
default ProceduralStream<T> waste(String name) {
|
||||||
return new WasteDetector<T>(this, name);
|
return this;
|
||||||
|
//return new WasteDetector<T>(this, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
default ProceduralStream<T> subtract(ProceduralStream<Double> a) {
|
default ProceduralStream<T> subtract(ProceduralStream<Double> a) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.volmit.iris.core.service.PreservationSVC;
|
|||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.MeteredCache;
|
import com.volmit.iris.engine.framework.MeteredCache;
|
||||||
|
import com.volmit.iris.util.cache.WorldCache2D;
|
||||||
import com.volmit.iris.util.data.KCache;
|
import com.volmit.iris.util.data.KCache;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.hunk.storage.ArrayHunk;
|
import com.volmit.iris.util.hunk.storage.ArrayHunk;
|
||||||
@@ -31,7 +32,7 @@ import com.volmit.iris.util.stream.ProceduralStream;
|
|||||||
|
|
||||||
public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStream<T>, MeteredCache {
|
public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStream<T>, MeteredCache {
|
||||||
private final ProceduralStream<T> stream;
|
private final ProceduralStream<T> stream;
|
||||||
private final KCache<Long, T> cache;
|
private final WorldCache2D<T> cache;
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private boolean chunked = true;
|
private boolean chunked = true;
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
super();
|
super();
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
cache = new KCache<>(k -> stream.get(Cache.keyX(k), Cache.keyZ(k)), size);
|
cache = new WorldCache2D<>(stream::get);
|
||||||
Iris.service(PreservationSVC.class).registerCache(this);
|
Iris.service(PreservationSVC.class).registerCache(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
@Override
|
@Override
|
||||||
public T get(double x, double z) {
|
public T get(double x, double z) {
|
||||||
//return stream.get(x, z);
|
//return stream.get(x, z);
|
||||||
return cache.get(Cache.key((int) x, (int) z));
|
return cache.get((int) x, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -71,12 +72,12 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KCache<?, ?> getRawCache() {
|
public KCache<?, ?> getRawCache() {
|
||||||
return cache;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaxSize() {
|
public long getMaxSize() {
|
||||||
return cache.getMaxSize();
|
return 256 * 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.volmit.iris.util.stream.utility;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.context.ChunkContext;
|
||||||
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
|
import com.volmit.iris.util.function.Function3;
|
||||||
|
import com.volmit.iris.util.stream.BasicStream;
|
||||||
|
import com.volmit.iris.util.stream.ProceduralStream;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class ContextInjectingStream<T> extends BasicStream<T> {
|
||||||
|
private final Function3<ChunkContext, Integer, Integer, T> contextAccessor;
|
||||||
|
|
||||||
|
public ContextInjectingStream(ProceduralStream<T> stream, Function3<ChunkContext, Integer, Integer, T> contextAccessor) {
|
||||||
|
super(stream);
|
||||||
|
this.contextAccessor = contextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get(double x, double z) {
|
||||||
|
IrisContext context = IrisContext.get();
|
||||||
|
|
||||||
|
if(context != null) {
|
||||||
|
ChunkContext chunkContext = context.getChunkContext();
|
||||||
|
|
||||||
|
if(chunkContext != null && (int)x >> 4 == chunkContext.getX() >> 4 && (int)z >> 4 == chunkContext.getZ() >> 4) {
|
||||||
|
T t = contextAccessor.apply(chunkContext, (int)x&15, (int)z&15);
|
||||||
|
|
||||||
|
if(t != null) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getTypedSource().get(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get(double x, double y, double z) {
|
||||||
|
return getTypedSource().get(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double toDouble(T t) {
|
||||||
|
return getTypedSource().toDouble(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T fromDouble(double d) {
|
||||||
|
return getTypedSource().fromDouble(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user