mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 18:49:06 +00:00
Merge branch 'master' of https://github.com/cyberpwnn/Iris
This commit is contained in:
@@ -34,7 +34,7 @@ public class IrisSettings
|
||||
public String defaultWorldType = "overworld";
|
||||
|
||||
@DontObfuscate
|
||||
public int maxAsyncChunkPregenThreads = 32;
|
||||
public int maxAsyncChunkPregenThreads = 128;
|
||||
|
||||
@DontObfuscate
|
||||
public boolean maximumPregenGuiFPS = false;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
@@ -52,7 +52,6 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
private volatile int minHeight;
|
||||
private int permits;
|
||||
private boolean failing;
|
||||
private ChronoLatch cl = new ChronoLatch(10000);
|
||||
private boolean closed;
|
||||
private int cacheId;
|
||||
private Semaphore s;
|
||||
@@ -62,7 +61,7 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
{
|
||||
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||
metrics = new EngineMetrics(32);
|
||||
permits = 1000;
|
||||
permits = 10000;
|
||||
this.s = new Semaphore(permits);
|
||||
this.target = target;
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
@@ -110,36 +109,49 @@ public class IrisEngine extends BlockPopulator implements Engine
|
||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<BlockData> postblocks, Hunk<Biome> vbiomes) {
|
||||
try
|
||||
{
|
||||
boolean multicore = !IrisSettings.get().isUseGleamPregenerator(); //TODO: LATER
|
||||
s.acquire(1);
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<Biome> biomes = vbiomes;
|
||||
Hunk<BlockData> blocks = vblocks.synchronize().listen((xx,y,zz,t) -> catchBlockUpdates(x+xx,y+getMinHeight(),z+zz, t));
|
||||
Hunk<BlockData> pblocks = postblocks.synchronize().listen((xx,y,zz,t) -> catchBlockUpdates(x+xx,y+getMinHeight(),z+zz, t));
|
||||
Hunk<BlockData> fringe = Hunk.fringe(blocks, pblocks);
|
||||
getFramework().getEngineParallax().generateParallaxArea(x, z);
|
||||
getFramework().getBiomeActuator().actuate(x, z, biomes);
|
||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
||||
getFramework().getCaveModifier().modify(x, z, blocks);
|
||||
getFramework().getRavineModifier().modify(x, z, blocks);
|
||||
|
||||
if(multicore)
|
||||
{
|
||||
MultiBurst.burst.burst(
|
||||
() -> getFramework().getEngineParallax().generateParallaxArea(x, z),
|
||||
() -> getFramework().getBiomeActuator().actuate(x, z, biomes),
|
||||
() -> getFramework().getTerrainActuator().actuate(x, z, blocks)
|
||||
);
|
||||
|
||||
|
||||
|
||||
MultiBurst.burst.burst(
|
||||
() -> getFramework().getCaveModifier().modify(x, z, blocks),
|
||||
() -> getFramework().getRavineModifier().modify(x, z, blocks),
|
||||
() -> getFramework().getPostModifier().modify(x, z, blocks),
|
||||
() -> getFramework().getDecorantActuator().actuate(x, z, fringe),
|
||||
() -> getFramework().getEngineParallax().insertParallax(x, z, fringe)
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
getFramework().getEngineParallax().generateParallaxArea(x, z);
|
||||
getFramework().getBiomeActuator().actuate(x, z, biomes);
|
||||
getFramework().getTerrainActuator().actuate(x, z, blocks);
|
||||
getFramework().getCaveModifier().modify(x, z, blocks);
|
||||
getFramework().getRavineModifier().modify(x, z, blocks);
|
||||
getFramework().getPostModifier().modify(x, z, blocks);
|
||||
getFramework().getDecorantActuator().actuate(x, z, fringe);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, fringe);
|
||||
}
|
||||
|
||||
getFramework().getDepositModifier().modify(x, z, blocks);
|
||||
getFramework().getPostModifier().modify(x, z, blocks);
|
||||
getFramework().getDecorantActuator().actuate(x, z, fringe);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, fringe);
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
s.release(1);
|
||||
|
||||
if(cl.flip())
|
||||
{
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
try {
|
||||
s.acquire(permits);
|
||||
getFramework().recycle();
|
||||
s.release(permits);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
getFramework().recycle();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import com.volmit.iris.generator.actuator.*;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.generator.actuator.IrisBiomeActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.generator.actuator.IrisTerrainActuator;
|
||||
import com.volmit.iris.generator.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisDepositModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.generator.modifier.IrisRavineModifier;
|
||||
import com.volmit.iris.scaffold.engine.*;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class IrisEngineFramework implements EngineFramework {
|
||||
|
||||
@Getter
|
||||
@@ -42,6 +49,9 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> postModifier;
|
||||
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngineFramework(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
@@ -54,6 +64,38 @@ public class IrisEngineFramework implements EngineFramework {
|
||||
this.ravineModifier = new IrisRavineModifier(getEngine());
|
||||
this.caveModifier = new IrisCaveModifier(engine);
|
||||
this.postModifier = new IrisPostModifier(engine);
|
||||
cleaning = new AtomicBoolean(false);
|
||||
cleanLatch = new ChronoLatch(Math.max(10000, Math.min(IrisSettings.get().parallaxChunkEvictionMS, IrisSettings.get().parallaxRegionEvictionMS)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void recycle() {
|
||||
if(!cleanLatch.flip())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get())
|
||||
{
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try
|
||||
{
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cleaning.lazySet(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.volmit.iris.generator.decorator;
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisDecorator;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.scaffold.engine.Engine;
|
||||
import com.volmit.iris.scaffold.engine.EngineAssignedComponent;
|
||||
@@ -25,17 +27,21 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem
|
||||
|
||||
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ)
|
||||
{
|
||||
KList<IrisDecorator> v = new KList<>();
|
||||
RNG rng = new RNG(Cache.key((int)realX, (int)realZ));
|
||||
|
||||
for(IrisDecorator i : biome.getDecorators())
|
||||
{
|
||||
if(i.getPartOf().equals(part))
|
||||
if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null)
|
||||
{
|
||||
if(i.getBlockData(biome, rng, realX, realZ, getData()) != null)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
v.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(v.isNotEmpty()) {
|
||||
return v.get(rng.nextInt(v.size()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,14 @@ public class IrisWorldCreator
|
||||
{
|
||||
return World.Environment.NORMAL;
|
||||
}
|
||||
else if(dimensionName == "NETHER")
|
||||
{
|
||||
return World.Environment.NETHER;
|
||||
}
|
||||
else if(dimensionName == "END")
|
||||
{
|
||||
return World.Environment.THE_END;
|
||||
}
|
||||
|
||||
IrisDimension dim = IrisDataManager.loadAnyDimension(dimensionName);
|
||||
|
||||
|
||||
@@ -614,12 +614,14 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
@Override
|
||||
public void close() {
|
||||
J.car(art);
|
||||
getComposite().close();
|
||||
if (getComposite() != null) {
|
||||
getComposite().close();
|
||||
|
||||
if(isStudio())
|
||||
{
|
||||
IrisWorlds.evacuate(getComposite().getWorld());
|
||||
Bukkit.unloadWorld(getComposite().getWorld(), !isStudio());
|
||||
|
||||
if (isStudio()) {
|
||||
IrisWorlds.evacuate(getComposite().getWorld());
|
||||
Bukkit.unloadWorld(getComposite().getWorld(), !isStudio());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.volmit.iris.scaffold.engine;
|
||||
import com.volmit.iris.generator.IrisComplex;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.scaffold.data.DataProvider;
|
||||
import com.volmit.iris.util.M;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@@ -21,15 +20,8 @@ public interface EngineFramework extends DataProvider
|
||||
|
||||
default void recycle()
|
||||
{
|
||||
if(M.r(0.1))
|
||||
{
|
||||
synchronized (getEngine().getParallax())
|
||||
{
|
||||
getEngine().getParallax().cleanup();
|
||||
}
|
||||
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
||||
public EngineActuator<BlockData> getTerrainActuator();
|
||||
|
||||
@@ -9,9 +9,9 @@ import java.io.IOException;
|
||||
|
||||
public class HunkRegionSlice<T>
|
||||
{
|
||||
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
|
||||
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t);
|
||||
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t);
|
||||
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
|
||||
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new StringHunkIOAdapter(), c, t);
|
||||
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newAtomicHunk, new BooleanHunkIOAdapter(), c, t);
|
||||
private final Function3<Integer, Integer, Integer, Hunk<T>> factory;
|
||||
private final HunkIOAdapter<T> adapter;
|
||||
private final CompoundTag compound;
|
||||
|
||||
@@ -66,14 +66,18 @@ public abstract class PaletteHunkIOAdapter<T> implements HunkIOAdapter<T> {
|
||||
int x = din.readShort() - Short.MIN_VALUE;
|
||||
int y = din.readShort() - Short.MIN_VALUE;
|
||||
int z = din.readShort() - Short.MIN_VALUE;
|
||||
T v = palette.getPalette().get(din.readShort() - Short.MIN_VALUE);
|
||||
int vf = din.readShort() - Short.MIN_VALUE;
|
||||
|
||||
if(v == null)
|
||||
T v = null;
|
||||
if( palette.getPalette().hasIndex(vf))
|
||||
{
|
||||
throw new IOException("NULL VALUE AT " + x + " " + y + " " + z);
|
||||
v = palette.getPalette().get(vf);
|
||||
}
|
||||
|
||||
t.setRaw(x,y,z, v);
|
||||
if(v != null)
|
||||
{
|
||||
t.setRaw(x,y,z, v);
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
return getMetaHunkR();
|
||||
}
|
||||
|
||||
public synchronized Hunk<ParallaxChunkMeta> loadMetaHunk()
|
||||
public Hunk<ParallaxChunkMeta> loadMetaHunk()
|
||||
{
|
||||
lastUse = M.ms();
|
||||
if(meta == null)
|
||||
@@ -115,7 +115,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
return meta;
|
||||
}
|
||||
|
||||
public synchronized void unloadMetaHunk()
|
||||
public void unloadMetaHunk()
|
||||
{
|
||||
if(dirtyMeta)
|
||||
{
|
||||
@@ -126,7 +126,7 @@ public class ParallaxRegion extends HunkRegion
|
||||
meta = null;
|
||||
}
|
||||
|
||||
public synchronized void saveMetaHunk()
|
||||
public void saveMetaHunk()
|
||||
{
|
||||
if(meta != null && dirtyMeta)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return m;
|
||||
}
|
||||
|
||||
public synchronized void close()
|
||||
public void close()
|
||||
{
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
@@ -65,7 +65,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
loadedRegions.clear();
|
||||
}
|
||||
|
||||
public synchronized void save(ParallaxRegion region)
|
||||
public void save(ParallaxRegion region)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
return loadedRegions.containsKey(key(x, z));
|
||||
}
|
||||
|
||||
public synchronized void save(int x, int z)
|
||||
public void save(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -91,7 +91,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void unload(int x, int z)
|
||||
public void unload(int x, int z)
|
||||
{
|
||||
long key = key(x, z);
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized ParallaxRegion load(int x, int z)
|
||||
public ParallaxRegion load(int x, int z)
|
||||
{
|
||||
if(isLoaded(x, z))
|
||||
{
|
||||
@@ -157,7 +157,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<BlockData> getBlocksRW(int x, int z)
|
||||
public Hunk<BlockData> getBlocksRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getBlockSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<String> getObjectsRW(int x, int z)
|
||||
public Hunk<String> getObjectsRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getObjectSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Hunk<Boolean> getUpdatesRW(int x, int z)
|
||||
public Hunk<Boolean> getUpdatesRW(int x, int z)
|
||||
{
|
||||
return getRW(x >> 5, z >> 5).getUpdateSlice().getRW(x & 31, z & 31);
|
||||
}
|
||||
@@ -227,15 +227,12 @@ public class ParallaxWorld implements ParallaxAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void saveAllNOW() {
|
||||
public void saveAllNOW() {
|
||||
for(ParallaxRegion i : loadedRegions.v())
|
||||
{
|
||||
synchronized (save)
|
||||
if(save.contains(key(i.getX(), i.getZ())))
|
||||
{
|
||||
if(save.contains(key(i.getX(), i.getZ())))
|
||||
{
|
||||
save(i.getX(), i.getZ());
|
||||
}
|
||||
save(i.getX(), i.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PregenJob implements Listener
|
||||
private double cps = 0;
|
||||
private int lg = 0;
|
||||
private long lt = M.ms();
|
||||
private int cubeSize = IrisSettings.get().isUseGleamPregenerator() ? 11 : 32;
|
||||
private int cubeSize = (IrisSettings.get().isUseGleamPregenerator() && PaperLib.isPaper()) ? 11 : 32;
|
||||
private long nogen = M.ms();
|
||||
private KList<ChunkPosition> requeueMCA = new KList<ChunkPosition>();
|
||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||
@@ -65,7 +65,7 @@ public class PregenJob implements Listener
|
||||
|
||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||
{
|
||||
gleaming = IrisSettings.get().isUseGleamPregenerator();
|
||||
gleaming = (IrisSettings.get().isUseGleamPregenerator() && PaperLib.isPaper());
|
||||
g.set(0);
|
||||
burst = new MultiBurst(gleaming ? IrisSettings.get().getMaxAsyncChunkPregenThreads() : tc());
|
||||
instance = this;
|
||||
@@ -431,7 +431,7 @@ public class PregenJob implements Listener
|
||||
consumer.accept(new ChunkPosition(cx, cz), Color.magenta);
|
||||
}
|
||||
|
||||
Chunk chunk = PaperLib.getChunkAtAsync(world, cx, cz, true).join();
|
||||
Chunk chunk = PaperLib.getChunkAtAsync(world, cx, cz, true, true).join();
|
||||
working.release();
|
||||
genned++;
|
||||
nogen = M.ms();
|
||||
|
||||
Reference in New Issue
Block a user