mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 03:29:06 +00:00
Auto stash before revert of "f"
This commit is contained in:
@@ -423,14 +423,21 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
switch (getDimension().getTerrainMode()) {
|
||||
case NORMAL -> {
|
||||
getMantle().generateMatter(x >> 4, z >> 4, multicore);
|
||||
getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
getBiomeActuator().actuate(x, z, vbiomes, multicore);
|
||||
getCaveModifier().modify(x, z, vblocks, multicore);
|
||||
getRavineModifier().modify(x, z, vblocks, multicore);
|
||||
getPostModifier().modify(x, z, vblocks, multicore);
|
||||
getDecorantActuator().actuate(x, z, blocks, multicore);
|
||||
getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore);
|
||||
getDepositModifier().modify(x, z, blocks, multicore);
|
||||
burst().burst(
|
||||
() ->getTerrainActuator().actuate(x, z, vblocks, multicore),
|
||||
() ->getBiomeActuator().actuate(x, z, vbiomes, multicore)
|
||||
);
|
||||
burst().burst(
|
||||
() ->getCaveModifier().modify(x, z, vblocks, multicore),
|
||||
()->getDecorantActuator().actuate(x, z, blocks, multicore),
|
||||
()->getRavineModifier().modify(x, z, vblocks, multicore),
|
||||
()->getPostModifier().modify(x, z, vblocks, multicore)
|
||||
);
|
||||
burst().burst(
|
||||
()->getDecorantActuator().actuate(x, z, blocks, multicore),
|
||||
()->getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore),
|
||||
()->getDepositModifier().modify(x, z, blocks, multicore)
|
||||
);
|
||||
}
|
||||
case ISLANDS -> {
|
||||
getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.bukkit.util.BlockVector;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -63,8 +64,6 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
private final KList<MantleComponent> components;
|
||||
private final int radius;
|
||||
private final AtomicCache<Integer> radCache = new AtomicCache<>();
|
||||
private ProceduralStream<KList<IrisFeaturePositional>> featureChunkStream;
|
||||
private ProceduralStream<KList<IrisFeaturePositional>> featureStream;
|
||||
|
||||
public IrisEngineMantle(Engine engine) {
|
||||
this.engine = engine;
|
||||
@@ -74,21 +73,6 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
registerComponent(new MantleFeatureComponent(this));
|
||||
registerComponent(new MantleJigsawComponent(this));
|
||||
registerComponent(new MantleObjectComponent(this));
|
||||
featureChunkStream = ProceduralStream.of((x, z)
|
||||
-> EngineMantle.super.getFeaturesInChunk(x.intValue(), z.intValue()),
|
||||
Interpolated.of((i) -> 0D, (i) -> new KList<IrisFeaturePositional>())).cache2D(2048);
|
||||
featureStream = ProceduralStream.of(EngineMantle.super::forEachFeature,
|
||||
Interpolated.of((i) -> 0D, (i) -> new KList<IrisFeaturePositional>())).cache2D(8192);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
public KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z) {
|
||||
return featureChunkStream.get(x, z);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public KList<IrisFeaturePositional> forEachFeature(double x, double z) {
|
||||
return featureStream.get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -211,7 +211,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
.shuffleCopy(RNG.r).stream()
|
||||
.filter(this::canSpawn),
|
||||
getData().getSpawnerLoader().streamAll(getEngine().getMantle()
|
||||
.getFeaturesInChunk(c).stream()
|
||||
.forEachFeature(c).stream()
|
||||
.flatMap((o) -> o.getFeature().getEntitySpawners().stream()))
|
||||
.filter(this::canSpawn))
|
||||
.filter((i) -> i.isValid(biome))
|
||||
@@ -294,6 +294,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
private KList<IrisEntitySpawn> spawnRandomly(List<IrisEntitySpawn> types) {
|
||||
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
||||
int totalRarity = 0;
|
||||
|
||||
for (IrisEntitySpawn i : types) {
|
||||
totalRarity += IRare.get(i);
|
||||
}
|
||||
@@ -344,7 +345,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
public void onChunkLoad(Chunk e, boolean generated) {
|
||||
if (generated) {
|
||||
energy += 1.2;
|
||||
spawnIn(e, true);
|
||||
J.a(() -> spawnIn(e, true), RNG.r.i(5, 50));
|
||||
} else {
|
||||
energy += 0.3;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
updateLighting(x, y, z, c);
|
||||
}
|
||||
}
|
||||
}, MantleFlag.UPDATE);
|
||||
});
|
||||
getMetrics().getUpdates().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,14 @@ import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -51,7 +53,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
Engine getEngine();
|
||||
|
||||
Integer getRadius();
|
||||
int getRadius();
|
||||
|
||||
KList<MantleComponent> getComponents();
|
||||
|
||||
@@ -166,15 +168,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
}
|
||||
|
||||
default int getRealRadius() {
|
||||
try {
|
||||
return (int) Math.ceil(getRadius().get() / 2D);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (int) Math.ceil(getRadius() / 2D);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,8 +189,8 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
BurstExecutor burst = burst().burst();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
int xx = i + x;
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int xx = i + x;
|
||||
int zz = j + z;
|
||||
burst.queue(() -> {
|
||||
getComponents().forEach((f) -> generateMantleComponent(xx, zz, f, c));
|
||||
@@ -229,20 +223,23 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
@BlockCoordinates
|
||||
default void updateBlock(int x, int y, int z) {
|
||||
getMantle().flag(x >> 4, z >> 4, MantleFlag.UPDATE, true);
|
||||
getMantle().set(x, y, z, true);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> getFeaturesInChunk(Chunk c) {
|
||||
default List<IrisFeaturePositional> getFeaturesInChunk(Chunk c) {
|
||||
return getFeaturesInChunk(c.getX(), c.getZ());
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> getFeaturesInChunk(int x, int z) {
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
getMantle().iterateChunk(x, z, IrisFeaturePositional.class, (a, b, c, f) -> pos.add(f), MantleFlag.FEATURE);
|
||||
return pos;
|
||||
default List<IrisFeaturePositional> getFeaturesInChunk(int x, int z) {
|
||||
return getMantle().getChunk(x, z).getFeatures();
|
||||
}
|
||||
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> forEachFeature(Chunk c) {
|
||||
return forEachFeature((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -267,7 +264,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
for (i = -s; i <= s; i++) {
|
||||
for (j = -s; j <= s; j++) {
|
||||
try {
|
||||
for (IrisFeaturePositional k : getFeaturesInChunk(i + cx, j + cx)) {
|
||||
for (IrisFeaturePositional k : getFeaturesInChunk(i + cx, j + cz)) {
|
||||
if (k.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(k);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
package com.volmit.iris.engine.mantle.components;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.jigsaw.PlannedStructure;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
@@ -27,24 +29,29 @@ import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructurePlacement;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.engine.object.regional.IrisRegion;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
private final CNG cng;
|
||||
|
||||
public MantleJigsawComponent(EngineMantle engineMantle) {
|
||||
super(engineMantle, MantleFlag.JIGSAW);
|
||||
cng = NoiseStyle.STATIC.create(new RNG());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(int x, int z, Consumer<Runnable> post) {
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
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);
|
||||
@@ -109,7 +116,6 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
if (structure.getFeature().getBlockRadius() == 32) {
|
||||
structure.getFeature().setBlockRadius((double) structure.getMaxDimension() / 3);
|
||||
}
|
||||
|
||||
getMantle().set(position.getX(), 0, position.getZ(),
|
||||
new IrisFeaturePositional(position.getX(), position.getZ(), structure.getFeature()));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.engine.object.feature;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -63,7 +64,18 @@ public class IrisFeaturePositional {
|
||||
private static double BLOCK = 1D / 256D; // TODO: WARNING HEIGHT
|
||||
|
||||
public static IrisFeaturePositional read(DataInputStream s) throws IOException {
|
||||
return new Gson().fromJson(s.readUTF(), IrisFeaturePositional.class);
|
||||
String sx = s.readUTF();
|
||||
try
|
||||
{
|
||||
return new Gson().fromJson(sx, IrisFeaturePositional.class);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.error(sx);
|
||||
e.printStackTrace();
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(DataOutputStream s) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user