mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-24 17:49:16 +00:00
Compare commits
11 Commits
2.2.16-1.1
...
2.2.18-1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141ca76647 | ||
|
|
94557830f5 | ||
|
|
49acb7faba | ||
|
|
1904f67662 | ||
|
|
5b2bf38344 | ||
|
|
494c38a153 | ||
|
|
dd4b85cbfe | ||
|
|
8f7b54a5a4 | ||
|
|
cec502340e | ||
|
|
64e27c7fb0 | ||
|
|
b2bbd31548 |
@@ -24,7 +24,7 @@ plugins {
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '2.2.16-1.19.2' // Needs to be version specific
|
||||
version '2.2.18-1.19.2' // Needs to be version specific
|
||||
def nmsVersion = "1.19.2" //[NMS]
|
||||
def apiVersion = '1.19'
|
||||
def specialSourceVersion = '1.11.0' //[NMS]
|
||||
@@ -122,7 +122,7 @@ dependencies {
|
||||
// Provided or Classpath
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
implementation 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT' //[NMS]
|
||||
implementation 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.19.2-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.jobs.QueueJob;
|
||||
import com.volmit.iris.util.stream.utility.ProfiledStream;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -39,11 +39,14 @@ import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.util.stream.utility.WasteDetector;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@@ -112,96 +115,97 @@ public class IrisComplex implements DataProvider {
|
||||
.getAllBiomes(this).forEach((b) -> b
|
||||
.getGenerators()
|
||||
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
|
||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0.0D);
|
||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0.0D).waste("Overlay Stream");
|
||||
engine.getDimension().getOverlayNoise().forEach(i -> overlayStream = overlayStream.add((x, z) -> i.get(rng, getData(), x, z)));
|
||||
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data)).waste("Rock Stream");
|
||||
fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream()
|
||||
.select(engine.getDimension().getFluidPalette().getBlockData(data));
|
||||
.select(engine.getDimension().getFluidPalette().getBlockData(data)).waste("Fluid Stream");
|
||||
regionStyleStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883), getData()).stream()
|
||||
.zoom(engine.getDimension().getRegionZoom());
|
||||
regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
.zoom(engine.getDimension().getRegionZoom()).waste("Region Style");
|
||||
regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE).waste("Region Identity Stream");
|
||||
regionStream = focusRegion != null ?
|
||||
ProceduralStream.of((x, z) -> focusRegion,
|
||||
Interpolated.of(a -> 0D, a -> focusRegion))
|
||||
: regionStyleStream
|
||||
.selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions()))
|
||||
.cache2D("regionStream", engine, cacheSize);
|
||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
||||
.cache2D("regionStream", engine, cacheSize).waste("Region Stream");
|
||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i),
|
||||
String.valueOf(i * 38445).hashCode() * 3245556666L)).waste("Region ID Stream");
|
||||
caveBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
|
||||
.onNull(emptyBiome)
|
||||
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize);
|
||||
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize).waste("Cave Biome Stream");
|
||||
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
||||
landBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("landBiomeStream", engine, cacheSize);
|
||||
.cache2D("landBiomeStream", engine, cacheSize).waste("Land Biome Stream");
|
||||
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
||||
seaBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("seaBiomeStream", engine, cacheSize);
|
||||
.cache2D("seaBiomeStream", engine, cacheSize).waste("Sea Biome Stream");
|
||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||
shoreBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
|
||||
).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize);
|
||||
).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize).waste("Shore Biome Stream");
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(),
|
||||
Interpolated.of(a -> 0D, a -> focusBiome.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("bridgeStream", engine, cacheSize);
|
||||
.cache2D("bridgeStream", engine, cacheSize).waste("Bridge Stream");
|
||||
baseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome,
|
||||
Interpolated.of(a -> 0D, a -> focusBiome)) :
|
||||
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D("baseBiomeStream", engine, cacheSize);
|
||||
.cache2D("baseBiomeStream", engine, cacheSize).waste("Base Biome Stream");
|
||||
heightStream = ProceduralStream.of((x, z) -> {
|
||||
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize);
|
||||
roundedHeighteightStream = heightStream.round();
|
||||
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize);
|
||||
}, Interpolated.DOUBLE).clamp(0, engine.getHeight()).cache2D("heightStream", engine, cacheSize).waste("Height Stream");
|
||||
roundedHeighteightStream = heightStream.round().waste("Rounded Height Stream");
|
||||
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize).waste("Slope Stream");
|
||||
trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D,
|
||||
b -> focusBiome))
|
||||
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
||||
.convertAware2D((h, x, z) ->
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.cache2D("trueBiomeStream", engine, cacheSize);
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize);
|
||||
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||
.cache2D("trueBiomeStream", engine, cacheSize).waste("True Biome Stream");
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize).waste("True Biome Derivative Stream");
|
||||
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize).waste("Height Fluid Stream");
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height).waste("Max Height Stream");
|
||||
terrainSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize).waste("Surface Decoration Stream");
|
||||
terrainCeilingDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize).waste("Ceiling Decoration Stream");
|
||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize).waste("Cave Surface Stream");
|
||||
terrainCaveCeilingDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize).waste("Cave Ceiling Stream");
|
||||
shoreSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize).waste("Shore Surface Stream");
|
||||
seaSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize).waste("Sea Surface Stream");
|
||||
seaFloorDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize);
|
||||
.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) -> {
|
||||
UUID d = regionIDStream.get(x, z);
|
||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||
d.hashCode());
|
||||
})
|
||||
.cache2D("", engine, cacheSize);
|
||||
.cache2D("", engine, cacheSize).waste("Biome ID Stream");
|
||||
//@done
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.format.C;
|
||||
@@ -192,8 +193,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateMatter(int x, int z, boolean multicore) {
|
||||
getMantle().generateMatter(x, z, multicore);
|
||||
public void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
|
||||
getMantle().generateMatter(x, z, multicore, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -623,7 +623,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
});
|
||||
|
||||
KList<ItemStack> d = new KList<>();
|
||||
/*KList<ItemStack> d = new KList<>();
|
||||
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation().clone().subtract(0, getEngine().getWorld().minHeight(), 0));
|
||||
List<IrisBlockDrops> dropProviders = filterDrops(b.getBlockDrops(), e, getData());
|
||||
|
||||
@@ -642,7 +642,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
if(d.isNotEmpty()) {
|
||||
World w = e.getBlock().getWorld();
|
||||
J.s(() -> d.forEach(item -> w.dropItemNaturally(e.getBlock().getLocation().clone().add(.5, .5, .5), item)));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.hunk.view.BiomeGridHunkHolder;
|
||||
@@ -75,7 +76,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore) {
|
||||
public void onActuate(int x, int z, Hunk<Biome> h, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor burst = burst().burst(PaperLib.isPaper() && multicore);
|
||||
|
||||
@@ -84,7 +85,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
burst.queue(() -> {
|
||||
IrisBiome ib;
|
||||
for(int zf = 0; zf < h.getDepth(); zf++) {
|
||||
ib = getComplex().getTrueBiomeStream().get(finalXf + x, zf + z);
|
||||
ib = context.getBiome().get(finalXf, zf);
|
||||
int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData()));
|
||||
if(ib.isCustom()) {
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.framework.EngineDecorator;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -66,7 +67,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||
if(!getEngine().getDimension().isDecorate()) {
|
||||
return;
|
||||
}
|
||||
@@ -86,9 +87,9 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
int emptyFor = 0;
|
||||
int lastSolid = 0;
|
||||
realZ = Math.round(z + j);
|
||||
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ));
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null;
|
||||
height = (int) Math.round(context.getHeight().get(finalI, j));
|
||||
biome = context.getBiome().get(finalI, j);
|
||||
cave = shouldRay ? context.getCave().get(finalI, j) : null;
|
||||
|
||||
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
||||
continue;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -50,13 +51,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore) {
|
||||
public void onActuate(int x, int z, Hunk<BlockData> h, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
BurstExecutor e = burst().burst(multicore);
|
||||
for(int xf = 0; xf < h.getWidth(); xf++) {
|
||||
int finalXf = xf;
|
||||
e.queue(() -> terrainSliver(x, z, finalXf, h));
|
||||
e.queue(() -> terrainSliver(x, z, finalXf, h, context));
|
||||
}
|
||||
|
||||
e.complete();
|
||||
@@ -81,7 +82,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
* the blockdata
|
||||
*/
|
||||
@BlockCoordinates
|
||||
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) {
|
||||
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h, ChunkContext context) {
|
||||
int zf, realX, realZ, hf, he;
|
||||
IrisBiome biome;
|
||||
IrisRegion region;
|
||||
@@ -89,9 +90,9 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
for(zf = 0; zf < h.getDepth(); zf++) {
|
||||
realX = xf + x;
|
||||
realZ = zf + z;
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
region = getComplex().getRegionStream().get(realX, realZ);
|
||||
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
|
||||
biome = context.getBiome().get(xf, zf);
|
||||
region = context.getRegion().get(xf, zf);
|
||||
he = (int) Math.round(Math.min(h.getHeight(), context.getHeight().get(xf, zf)));
|
||||
hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
|
||||
|
||||
if(hf < 0) {
|
||||
@@ -126,7 +127,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
continue;
|
||||
}
|
||||
|
||||
h.set(xf, i, zf, getComplex().getFluidStream().get(realX, +realZ));
|
||||
h.set(xf, i, zf, context.getFluid().get(xf,zf));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -153,7 +154,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
if(ore != null) {
|
||||
h.set(xf, i, zf, ore);
|
||||
} else {
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
h.set(xf, i, zf, context.getRock().get(xf, zf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
@@ -194,7 +195,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
return getComplex().getRegionStream().get(x, z);
|
||||
}
|
||||
|
||||
void generateMatter(int x, int z, boolean multicore);
|
||||
void generateMatter(int x, int z, boolean multicore, ChunkContext context);
|
||||
|
||||
@BlockCoordinates
|
||||
default IrisBiome getCaveOrMantleBiome(int x, int y, int z) {
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
|
||||
public interface EngineActuator<O> extends EngineComponent {
|
||||
@BlockCoordinates
|
||||
void actuate(int x, int z, Hunk<O> output, boolean multicore);
|
||||
void actuate(int x, int z, Hunk<O> output, boolean multicore, ChunkContext context);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
|
||||
@@ -26,11 +27,11 @@ public abstract class EngineAssignedActuator<T> extends EngineAssignedComponent
|
||||
super(engine, name);
|
||||
}
|
||||
|
||||
public abstract void onActuate(int x, int z, Hunk<T> output, boolean multicore);
|
||||
public abstract void onActuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void actuate(int x, int z, Hunk<T> output, boolean multicore) {
|
||||
onActuate(x, z, output, multicore);
|
||||
public void actuate(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
|
||||
onActuate(x, z, output, multicore, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
|
||||
@@ -28,13 +29,13 @@ public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public abstract void onModify(int x, int z, Hunk<T> output, boolean multicore);
|
||||
public abstract void onModify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context);
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void modify(int x, int z, Hunk<T> output, boolean multicore) {
|
||||
public void modify(int x, int z, Hunk<T> output, boolean multicore, ChunkContext context) {
|
||||
try {
|
||||
onModify(x, z, output, multicore);
|
||||
onModify(x, z, output, multicore, context);
|
||||
} catch(Throwable e) {
|
||||
Iris.error("Modifier Failure: " + getName());
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.stream.utility.WasteDetector;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -145,6 +146,9 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
@EventHandler
|
||||
public void on(BlockBreakEvent e) {
|
||||
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
|
||||
WasteDetector.printAll();
|
||||
|
||||
onBlockBreak(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,19 @@
|
||||
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RollingSequence;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@@ -37,12 +44,12 @@ public interface EngineMode extends Staged {
|
||||
}
|
||||
|
||||
default EngineStage burst(EngineStage... stages) {
|
||||
return (x, z, blocks, biomes, multicore) -> {
|
||||
return (x, z, blocks, biomes, multicore, ctx) -> {
|
||||
BurstExecutor e = burst().burst(stages.length);
|
||||
e.setMulticore(multicore);
|
||||
|
||||
for(EngineStage i : stages) {
|
||||
e.queue(() -> i.generate(x, z, blocks, biomes, multicore));
|
||||
e.queue(() -> i.generate(x, z, blocks, biomes, multicore, ctx));
|
||||
}
|
||||
|
||||
e.complete();
|
||||
@@ -57,14 +64,25 @@ public interface EngineMode extends Staged {
|
||||
return getEngine().getMantle();
|
||||
}
|
||||
|
||||
default void generateMatter(int x, int z, boolean multicore) {
|
||||
getMantle().generateMatter(x, z, multicore);
|
||||
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
|
||||
getMantle().generateMatter(x, z, multicore, context);
|
||||
}
|
||||
|
||||
public static final RollingSequence r = new RollingSequence(64);
|
||||
public static final RollingSequence r2 = new RollingSequence(256);
|
||||
|
||||
@BlockCoordinates
|
||||
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());
|
||||
IrisContext.getOr(getEngine()).setChunkContext(ctx);
|
||||
r.put(p.getMilliseconds());
|
||||
|
||||
for(EngineStage i : getStages()) {
|
||||
i.generate(x, z, blocks, biomes, multicore);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,11 @@
|
||||
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
|
||||
public interface EngineModifier<T> extends EngineComponent {
|
||||
@BlockCoordinates
|
||||
void modify(int x, int z, Hunk<T> t, boolean multicore);
|
||||
void modify(int x, int z, Hunk<T> t, boolean multicore, ChunkContext context);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.framework;
|
||||
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -25,7 +26,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface EngineStage {
|
||||
@BlockCoordinates
|
||||
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore);
|
||||
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore, ChunkContext context);
|
||||
|
||||
default void close() {
|
||||
if(this instanceof EngineComponent c) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
@@ -175,7 +176,7 @@ public interface Locator<T> {
|
||||
static Locator<IrisBiome> caveOrMantleBiome(String loadKey) {
|
||||
return (e, c) -> {
|
||||
AtomicBoolean found = new AtomicBoolean(false);
|
||||
e.generateMatter(c.getX(), c.getZ(), true);
|
||||
e.generateMatter(c.getX(), c.getZ(), true, new ChunkContext(c.getX() << 4, c.getZ() << 4, e.getComplex(), false));
|
||||
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> {
|
||||
if(found.get()) {
|
||||
return;
|
||||
|
||||
@@ -126,8 +126,7 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
vo.place(xx, height, zz, placer, options, rng, e.shouldReduce(eng) ? null : (b)
|
||||
-> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
vo.place(xx, height, zz, placer, options, rng, (b) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
}
|
||||
|
||||
public void place(World world) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.engine.object.TileData;
|
||||
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.data.B;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
@@ -188,7 +189,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
|
||||
@ChunkCoordinates
|
||||
default void generateMatter(int x, int z, boolean multicore) {
|
||||
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
|
||||
if(!getEngine().getDimension().isUseMantle()) {
|
||||
return;
|
||||
}
|
||||
@@ -206,7 +207,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
MantleChunk mc = getMantle().getChunk(xx, zz);
|
||||
|
||||
for(MantleComponent k : getComponents()) {
|
||||
generateMantleComponent(writer, xx, zz, k, mc);
|
||||
generateMantleComponent(writer, xx, zz, k, mc, context);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -216,8 +217,8 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
burst.complete();
|
||||
}
|
||||
|
||||
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc) {
|
||||
mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z));
|
||||
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) {
|
||||
mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z, context));
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.volmit.iris.engine.mantle;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
@@ -60,5 +61,5 @@ public interface MantleComponent {
|
||||
MantleFlag getFlag();
|
||||
|
||||
@ChunkCoordinates
|
||||
void generateLayer(MantleWriter writer, int x, int z);
|
||||
void generateLayer(MantleWriter writer, int x, int z, ChunkContext context);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisCarving;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -35,12 +36,10 @@ public class MantleCarvingComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z) {
|
||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||
IrisRegion region = context.getRegion().get(8, 8);
|
||||
IrisBiome biome = context.getBiome().get(8, 8);
|
||||
carve(writer, rng, x, z, region, biome);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisFluidBodies;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -35,12 +36,10 @@ public class MantleFluidBodyComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z) {
|
||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed() + 405666);
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||
IrisRegion region = context.getRegion().get(8, 8);
|
||||
IrisBiome biome = context.getBiome().get(8, 8);
|
||||
generate(writer, rng, x, z, region, biome);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
@@ -46,12 +47,10 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z) {
|
||||
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));
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||
IrisRegion region = context.getRegion().get(8, 8);
|
||||
IrisBiome biome = context.getBiome().get(8, 8);
|
||||
generateJigsaw(writer, rng, x, z, biome, region);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
@@ -41,12 +42,10 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(MantleWriter writer, int x, int z) {
|
||||
public void generateLayer(MantleWriter writer, int x, int z, ChunkContext context) {
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||
IrisRegion region = context.getRegion().get(8, 8);
|
||||
IrisBiome biome = context.getBiome().get(8, 8);
|
||||
placeObjects(writer, rng, x, z, biome, region);
|
||||
}
|
||||
|
||||
@@ -95,9 +94,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
int xx = rng.i(x, x + 15);
|
||||
int zz = rng.i(z, z + 15);
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
v.place(xx, -1, zz, writer, objectPlacement, rng,
|
||||
getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(),
|
||||
v.getLoadKey() + "@" + id), null, getData());
|
||||
v.place(xx, -1, zz, writer, objectPlacement, rng, (b) -> writer.setData(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeEnclosure extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
|
||||
(x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeIslands extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
|
||||
(x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisPostModifier;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
|
||||
public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
||||
public ModeOverworld(Engine engine) {
|
||||
super(engine);
|
||||
@@ -42,16 +41,16 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
||||
var deposit = new IrisDepositModifier(getEngine());
|
||||
var perfection = new IrisPerfectionModifier(getEngine());
|
||||
|
||||
registerStage((x, z, k, p, m) -> biome.actuate(x, z, p, m));
|
||||
registerStage((x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c));
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m),
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m)
|
||||
(x, z, k, p, m, c) -> generateMatter(x >> 4, z >> 4, m, c),
|
||||
(x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c)
|
||||
));
|
||||
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
|
||||
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m));
|
||||
registerStage((x, z, k, p, m) -> decorant.actuate(x, z, k, m));
|
||||
registerStage((x, z, k, p, m) -> post.modify(x, z, k, m));
|
||||
registerStage((x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m));
|
||||
registerStage((x, z, k, p, m) -> perfection.modify(x, z, k, m));
|
||||
registerStage((x, z, k, p, m, c) -> cave.modify(x >> 4, z >> 4, k, m, c));
|
||||
registerStage((x, z, k, p, m, c) -> deposit.modify(x, z, k, m,c));
|
||||
registerStage((x, z, k, p, m, c) -> decorant.actuate(x, z, k, m, c));
|
||||
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((x, z, k, p, m, c) -> perfection.modify(x, z, k, m, c));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m, c) -> terrain.actuate(x, z, k, m, c),
|
||||
(x, z, k, p, m, c) -> biome.actuate(x, z, p, m, c)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.function.Consumer4;
|
||||
@@ -58,7 +59,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Mantle mantle = getEngine().getMantle().getMantle();
|
||||
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
|
||||
@@ -130,7 +131,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
biome.setInferredType(InferredType.CAVE);
|
||||
BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData());
|
||||
|
||||
if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) {
|
||||
if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= context.getHeight().get(i.getX(), i.getZ())) {
|
||||
output.set(i.getX(), i.getY(), i.getZ(), d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisDepositGenerator;
|
||||
import com.volmit.iris.engine.object.IrisObject;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.HeightMap;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
@@ -42,41 +43,41 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore);
|
||||
generateDeposits(rng, output, Math.floorDiv(x, 16), Math.floorDiv(z, 16), multicore, context);
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z, boolean multicore) {
|
||||
public void generateDeposits(RNG rx, Hunk<BlockData> terrain, int x, int z, boolean multicore, ChunkContext context) {
|
||||
RNG ro = rx.nextParallelRNG(x * x).nextParallelRNG(z * z);
|
||||
IrisRegion region = getComplex().getRegionStream().get((x * 16) + 7, (z * 16) + 7);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7);
|
||||
IrisRegion region = context.getRegion().get(7,7);
|
||||
IrisBiome biome = context.getBiome().get(7,7);
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits()) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : region.getDeposits()) {
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisDepositGenerator k : biome.getDeposits()) {
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false, context));
|
||||
}
|
||||
}
|
||||
burst.complete();
|
||||
}
|
||||
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe) {
|
||||
generate(k, data, rng, cx, cz, safe, null);
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, ChunkContext context) {
|
||||
generate(k, data, rng, cx, cz, safe, null, context);
|
||||
}
|
||||
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he) {
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he, ChunkContext context) {
|
||||
for(int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
IrisObject clump = k.getClump(rng, getData());
|
||||
|
||||
@@ -92,7 +93,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
int x = rng.i(af, bf);
|
||||
int z = rng.i(af, bf);
|
||||
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
|
||||
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
|
||||
context.getHeight().get( x, z)
|
||||
))) - 7;
|
||||
|
||||
if(height <= 0) {
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.engine.modifier;
|
||||
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
@@ -41,7 +42,7 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
AtomicBoolean changed = new AtomicBoolean(true);
|
||||
int passes = 0;
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.volmit.iris.engine.modifier;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.util.context.ChunkContext;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -45,7 +46,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
public void onModify(int x, int z, Hunk<BlockData> output, boolean multicore, ChunkContext context) {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
AtomicInteger j = new AtomicInteger();
|
||||
@@ -54,14 +55,14 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
for(j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
int ii = i.get();
|
||||
int jj = j.get();
|
||||
post(ii, jj, sync, ii + x, jj + z);
|
||||
post(ii, jj, sync, ii + x, jj + z, context);
|
||||
}
|
||||
}
|
||||
|
||||
getEngine().getMetrics().getPost().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z) {
|
||||
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z, ChunkContext context) {
|
||||
int h = getEngine().getMantle().trueHeight(x, z);
|
||||
int ha = getEngine().getMantle().trueHeight(x + 1, z);
|
||||
int hb = getEngine().getMantle().trueHeight(x, z + 1);
|
||||
@@ -136,7 +137,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
// Wall Patcher
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z);
|
||||
IrisBiome biome = context.getBiome().get(currentPostX, currentPostZ);
|
||||
|
||||
if(getDimension().isPostProcessingWalls()) {
|
||||
if(!biome.getWall().getPalette().isEmpty()) {
|
||||
|
||||
@@ -203,6 +203,8 @@ public class IrisObjectPlacement {
|
||||
TableCache tc = new TableCache();
|
||||
|
||||
for(IrisObjectLoot loot : getLoot()) {
|
||||
if(loot == null)
|
||||
continue;
|
||||
IrisLootTable table = manager.getLootLoader().load(loot.getName());
|
||||
if(table == null) {
|
||||
Iris.warn("Couldn't find loot table " + loot.getName());
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.Looper;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.stream.utility.ProfiledStream;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Setter;
|
||||
@@ -276,7 +277,6 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||
try {
|
||||
getEngine(world);
|
||||
loadLock.acquire();
|
||||
computeStudioGenerator();
|
||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||
this.world.bind(world);
|
||||
@@ -293,10 +293,9 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
|
||||
ChunkData c = tc.getRaw();
|
||||
Iris.debug("Generated " + x + " " + z);
|
||||
loadLock.release();
|
||||
|
||||
return c;
|
||||
} catch(Throwable e) {
|
||||
loadLock.release();
|
||||
Iris.error("======================================");
|
||||
e.printStackTrace();
|
||||
Iris.reportErrorChunk(x, z, e, "CHUNK");
|
||||
|
||||
51
src/main/java/com/volmit/iris/util/context/ChunkContext.java
Normal file
51
src/main/java/com/volmit/iris/util/context/ChunkContext.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.volmit.iris.util.context;
|
||||
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@Data
|
||||
public class ChunkContext {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private ChunkedDataCache<Double> height;
|
||||
private ChunkedDataCache<IrisBiome> biome;
|
||||
private ChunkedDataCache<IrisBiome> cave;
|
||||
private ChunkedDataCache<BlockData> rock;
|
||||
private ChunkedDataCache<BlockData> fluid;
|
||||
private ChunkedDataCache<IrisRegion> region;
|
||||
|
||||
@BlockCoordinates
|
||||
public ChunkContext(int x, int z, IrisComplex c) {
|
||||
this(x, z, c, true);
|
||||
}
|
||||
@BlockCoordinates
|
||||
public ChunkContext(int x, int z, IrisComplex c, boolean cache) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
if(cache) {
|
||||
BurstExecutor b = MultiBurst.burst.burst();
|
||||
height = new ChunkedDataCache<>(b, c.getHeightStream(), x, z);
|
||||
biome = new ChunkedDataCache<>(b, c.getTrueBiomeStream(), x, z);
|
||||
cave = new ChunkedDataCache<>(b, c.getCaveBiomeStream(), x, z);
|
||||
rock = new ChunkedDataCache<>(b, c.getRockStream(), x, z);
|
||||
fluid = new ChunkedDataCache<>(b, c.getFluidStream(), x, z);
|
||||
region = new ChunkedDataCache<>(b, c.getRegionStream(), x, z);
|
||||
b.complete();
|
||||
}
|
||||
|
||||
else {
|
||||
height = new ChunkedDataCache<>(null, c.getHeightStream(), x, z, false);
|
||||
biome = new ChunkedDataCache<>(null, c.getTrueBiomeStream(), x, z, false);
|
||||
cave = new ChunkedDataCache<>(null, c.getCaveBiomeStream(), x, z, false);
|
||||
rock = new ChunkedDataCache<>(null, c.getRockStream(), x, z, false);
|
||||
fluid = new ChunkedDataCache<>(null, c.getFluidStream(), x, z, false);
|
||||
region = new ChunkedDataCache<>(null, c.getRegionStream(), x, z, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.volmit.iris.util.context;
|
||||
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
public class ChunkedDataCache<T> {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final Object[] data;
|
||||
private final boolean cache;
|
||||
private final ProceduralStream<T> stream;
|
||||
|
||||
@BlockCoordinates
|
||||
public ChunkedDataCache(BurstExecutor burst, ProceduralStream<T> stream, int x, int z) {
|
||||
this(burst, stream, x, z, true);
|
||||
}
|
||||
@BlockCoordinates
|
||||
public ChunkedDataCache(BurstExecutor burst, ProceduralStream<T> stream, int x, int z, boolean cache) {
|
||||
this.stream = stream;
|
||||
this.cache = cache;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
if(cache) {
|
||||
data = new Object[256];
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
int finalI = i;
|
||||
for(j = 0; j < 16; j++) {
|
||||
int finalJ = j;
|
||||
burst.queue(() -> data[(finalJ * 16) + finalI] = stream.get(x+ finalI, z+ finalJ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
data = new Object[0];
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@BlockCoordinates
|
||||
public T get(int x, int z) {
|
||||
if(!cache) {
|
||||
return stream.get(this.x + x, this.z + z);
|
||||
}
|
||||
|
||||
T t = (T) data[(z * 16) + x];
|
||||
return t == null ? stream.get(this.x + x, this.z + z) : t;
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,26 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class IrisContext {
|
||||
private static final KMap<Thread, IrisContext> context = new KMap<>();
|
||||
private static ChronoLatch cl = new ChronoLatch(60000);
|
||||
private final Engine engine;
|
||||
private ChunkContext chunkContext;
|
||||
|
||||
public IrisContext(Engine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public static IrisContext getOr(Engine engine) {
|
||||
IrisContext c = get();
|
||||
|
||||
if(c == null) {
|
||||
c = new IrisContext(engine);
|
||||
touch(c);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
public static IrisContext get() {
|
||||
return context.get(Thread.currentThread());
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.BlockPosition;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.volmit.iris.util.function.Function3;
|
||||
import com.volmit.iris.util.function.Function4;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.GridLock;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.stream.arithmetic.AddingStream;
|
||||
import com.volmit.iris.util.stream.arithmetic.ClampedStream;
|
||||
import com.volmit.iris.util.stream.arithmetic.CoordinateBitShiftLeftStream;
|
||||
@@ -63,9 +66,11 @@ import com.volmit.iris.util.stream.utility.NullSafeStream;
|
||||
import com.volmit.iris.util.stream.utility.ProfiledStream;
|
||||
import com.volmit.iris.util.stream.utility.SemaphoreStream;
|
||||
import com.volmit.iris.util.stream.utility.SynchronizedStream;
|
||||
import com.volmit.iris.util.stream.utility.WasteDetector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
@@ -111,7 +116,7 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
}
|
||||
|
||||
default ProceduralStream<T> profile() {
|
||||
return profile(10);
|
||||
return profile(256);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> profile(int memory) {
|
||||
@@ -134,6 +139,10 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
return add2D((x, z) -> a.get(x, z));
|
||||
}
|
||||
|
||||
default ProceduralStream<T> waste(String name) {
|
||||
return new WasteDetector<T>(this, name);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> subtract(ProceduralStream<Double> a) {
|
||||
return subtract2D((x, z) -> a.get(x, z));
|
||||
}
|
||||
@@ -290,7 +299,7 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
return new To3DStream<T>(this);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> cache2D(String name, Engine engine, int size) {
|
||||
default CachedStream2D<T> cache2D(String name, Engine engine, int size) {
|
||||
return new CachedStream2D<T>(name, engine, this, size);
|
||||
}
|
||||
|
||||
@@ -406,6 +415,48 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
}, Interpolated.DOUBLE);
|
||||
}
|
||||
|
||||
default Hunk<T> fastFill2DParallel(int x, int z) {
|
||||
Hunk<T> hunk = Hunk.newAtomicHunk(16, 16, 1);
|
||||
BurstExecutor e = MultiBurst.burst.burst(256);
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
int fi = i;
|
||||
int fj = j;
|
||||
e.queue(() -> hunk.setRaw(fi, fj, 0, get(x+ fi, z+ fj)));
|
||||
}
|
||||
}
|
||||
|
||||
e.complete();
|
||||
return hunk;
|
||||
}
|
||||
|
||||
default void fastFill2DParallel(Hunk<T> hunk, BurstExecutor e, int x, int z) {
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
int fi = i;
|
||||
int fj = j;
|
||||
e.queue(() -> hunk.setRaw(fi, fj, 0, get(x+ fi, z+ fj)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default Hunk<T> fastFill2D(int x, int z) {
|
||||
Hunk<T> hunk = Hunk.newArrayHunk(16, 16, 1);
|
||||
int i,j;
|
||||
|
||||
for(i = 0; i < 16; i++) {
|
||||
for(j = 0; j < 16; j++) {
|
||||
hunk.setRaw(i, j, 0, get(x+ i, z+ j));
|
||||
}
|
||||
}
|
||||
|
||||
return hunk;
|
||||
}
|
||||
|
||||
default ProceduralStream<T> fit(double inMin, double inMax, double min, double max) {
|
||||
return new FittedStream<T>(this, inMin, inMax, min, max);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ 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.KCache;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.hunk.storage.ArrayHunk;
|
||||
import com.volmit.iris.util.stream.BasicStream;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
@@ -31,6 +33,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
private final ProceduralStream<T> stream;
|
||||
private final KCache<Long, T> cache;
|
||||
private final Engine engine;
|
||||
private boolean chunked = true;
|
||||
|
||||
public CachedStream2D(String name, Engine engine, ProceduralStream<T> stream, int size) {
|
||||
super();
|
||||
@@ -52,6 +55,7 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
|
||||
@Override
|
||||
public T get(double x, double z) {
|
||||
//return stream.get(x, z);
|
||||
return cache.get(Cache.key((int) x, (int) z));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,13 @@ public class ProfiledStream<T> extends BasicStream<T> {
|
||||
public static final AtomicInteger ids = new AtomicInteger();
|
||||
private final int id;
|
||||
private final RollingSequence metrics;
|
||||
public static final KList<ProfiledStream<?>> profiles = new KList<>();
|
||||
|
||||
public ProfiledStream(ProceduralStream<T> stream, int memory) {
|
||||
super(stream);
|
||||
this.metrics = new RollingSequence(memory);
|
||||
this.id = ids.getAndAdd(1);
|
||||
profiles.add(this);
|
||||
}
|
||||
|
||||
public static void print(Consumer<String> printer, ProceduralStream<?> stream) {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.volmit.iris.util.stream.utility;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.stream.BasicStream;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class WasteDetector<T> extends BasicStream<T> {
|
||||
public static final boolean checking = false;
|
||||
private static final KMap<String, Integer> allAccesses = new KMap<>();
|
||||
private static final KMap<String, List<Throwable>> allThrows = new KMap<>();
|
||||
private final AtomicInteger accesses;
|
||||
private final String name;
|
||||
|
||||
public WasteDetector(ProceduralStream<T> stream, String name) {
|
||||
super(stream);
|
||||
this.name = name;
|
||||
accesses = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(double x, double z) {
|
||||
if(checking)
|
||||
{
|
||||
if(x == 7 && z == 7) {
|
||||
// AHHHAAA!
|
||||
allAccesses.compute(name, (k, v) -> v == null ? 1 : v + 1);
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
catch(RuntimeException e) {
|
||||
allThrows.computeIfAbsent(name, (k) -> new KList<>()).add(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return getTypedSource().get(x, z);
|
||||
}
|
||||
|
||||
public static void printAll() {
|
||||
if(checking)
|
||||
{
|
||||
Iris.warn("=========================================================");
|
||||
for(String i : allAccesses.sortKNumber().reverse()) {
|
||||
Iris.warn(i + ": " + allAccesses.get(i) + " Time(s)");
|
||||
}
|
||||
Iris.warn("=========================================================");
|
||||
for(String i : allAccesses.sortKNumber().reverse()) {
|
||||
Iris.warn("======== "+ i + " ========");
|
||||
for(Throwable j : allThrows.get(i)) {
|
||||
j.printStackTrace();
|
||||
}
|
||||
Iris.warn("---------------------------------------------------------");
|
||||
}
|
||||
Iris.warn("=========================================================");
|
||||
}
|
||||
}
|
||||
|
||||
@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