mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-09 17:26:22 +00:00
Fixes & Fixes
This commit is contained in:
@@ -26,6 +26,8 @@ import java.util.Arrays;
|
||||
public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootProvider, BlockUpdater, Renderer, Hotloadable {
|
||||
public void close();
|
||||
|
||||
public int getCurrentlyGenerating();
|
||||
|
||||
public boolean isClosed();
|
||||
|
||||
public EngineWorldManager getWorldManager();
|
||||
@@ -145,8 +147,11 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
|
||||
if(B.isUpdatable(data))
|
||||
{
|
||||
getParallax().updateBlock(x,y,z);
|
||||
getParallax().getMetaRW(x>>4, z>>4).setUpdates(true);
|
||||
synchronized (getParallax())
|
||||
{
|
||||
getParallax().updateBlock(x,y,z);
|
||||
getParallax().getMetaRW(x>>4, z>>4).setUpdates(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.volmit.iris.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.scaffold.cache.Cache;
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.*;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -36,6 +37,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
private long mst = 0;
|
||||
private int generated = 0;
|
||||
private int lgenerated = 0;
|
||||
private final KMap<Long, PregeneratedData> chunkCache;
|
||||
private ChronoLatch hotloadcd;
|
||||
@Getter
|
||||
private double generatedPerSecond = 0;
|
||||
@@ -48,6 +50,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
|
||||
public EngineCompositeGenerator(String hint, boolean production) {
|
||||
super();
|
||||
chunkCache = new KMap<>();
|
||||
hotloadcd = new ChronoLatch(3500);
|
||||
mst = M.ms();
|
||||
this.production = production;
|
||||
@@ -305,16 +308,70 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
return tc.getRaw();
|
||||
}
|
||||
|
||||
public Chunk generatePaper(World world, int x, int z)
|
||||
{
|
||||
precache(world, x, z);
|
||||
Chunk c = PaperLib.getChunkAtAsync(world, x, z, true).join();
|
||||
chunkCache.remove(Cache.key(x, z));
|
||||
return c;
|
||||
}
|
||||
|
||||
public void precache(World world, int x, int z)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
initialize(world);
|
||||
}
|
||||
|
||||
synchronized (chunkCache)
|
||||
{
|
||||
if(chunkCache.containsKey(Cache.key(x, z)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PregeneratedData data = new PregeneratedData(getComposite().getHeight()-1);
|
||||
compound.generate(x * 16, z * 16, data.getBlocks(), data.getPost(), data.getBiomes());
|
||||
synchronized (chunkCache)
|
||||
{
|
||||
chunkCache.put(Cache.key(x, z), data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrecacheSize() {
|
||||
return chunkCache.size();
|
||||
}
|
||||
|
||||
public int getCachedChunks()
|
||||
{
|
||||
return chunkCache.size();
|
||||
}
|
||||
|
||||
public Runnable generateChunkRawData(World world, int x, int z, TerrainChunk tc)
|
||||
{
|
||||
initialize(world);
|
||||
|
||||
synchronized (chunkCache)
|
||||
{
|
||||
long g = Cache.key(x, z);
|
||||
if(chunkCache.containsKey(g))
|
||||
{
|
||||
generated++;
|
||||
return chunkCache.remove(g).inject(tc);
|
||||
}
|
||||
}
|
||||
|
||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||
Hunk<BlockData> post = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
||||
AtomicBoolean postMod = new AtomicBoolean(false);
|
||||
Hunk<BlockData> trk = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
||||
Hunk<BlockData> post = trk.trackWrite(postMod);
|
||||
compound.generate(x * 16, z * 16, blocks, post, biomes);
|
||||
generated++;
|
||||
|
||||
return () -> blocks.insertSoftly(0,0,0,post, (b) -> b == null || B.isAirOrFluid(b));
|
||||
return postMod.get() ? () -> blocks.insertSoftly(0,0,0, post, (b) -> b == null || B.isAirOrFluid(b)) : () -> {};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -454,12 +511,6 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
|
||||
@Override
|
||||
public void regenerate(int x, int z) {
|
||||
if (true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Chunk chunk = getComposite().getWorld().getChunkAt(x, z);
|
||||
generateChunkRawData(getComposite().getWorld(), x, z, new TerrainChunk() {
|
||||
@Override
|
||||
public void setRaw(ChunkData data) {
|
||||
@@ -557,6 +608,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
||||
Iris.edit.flushNow();
|
||||
|
||||
for (BlockPopulator i : populators) {
|
||||
Chunk chunk = getComposite().getWorld().getChunkAt(x, z);
|
||||
i.populate(compound.getWorld(), new RNG(Cache.key(x, z)), chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,17 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider
|
||||
|
||||
public World getWorld();
|
||||
|
||||
public int getCurrentlyGeneratingEngines();
|
||||
|
||||
public void printMetrics(CommandSender sender);
|
||||
|
||||
public int getSize();
|
||||
|
||||
public default int getHeight()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
public Engine getEngine(int index);
|
||||
|
||||
public MultiBurst getBurster();
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
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 com.volmit.iris.scaffold.parallel.MultiBurst;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.generator.IrisComplex;
|
||||
import com.volmit.iris.scaffold.data.DataProvider;
|
||||
|
||||
public interface EngineFramework extends DataProvider
|
||||
{
|
||||
public Engine getEngine();
|
||||
@@ -25,10 +23,12 @@ public interface EngineFramework extends DataProvider
|
||||
{
|
||||
if(M.r(0.1))
|
||||
{
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
synchronized (getEngine().getParallax())
|
||||
{
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
});
|
||||
}
|
||||
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.object.*;
|
||||
import com.volmit.iris.scaffold.data.DataProvider;
|
||||
import com.volmit.iris.util.*;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -388,4 +390,10 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
||||
}
|
||||
|
||||
public void clearRegeneratedLists(int x, int z);
|
||||
|
||||
void precache(World world, int x, int z);
|
||||
|
||||
int getPrecacheSize();
|
||||
|
||||
Chunk generatePaper(World world, int cx, int cz);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volmit.iris.scaffold.engine;
|
||||
|
||||
public interface IrisAccessProvider {
|
||||
public IrisAccess getAccess();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.volmit.iris.scaffold.engine;
|
||||
|
||||
import com.volmit.iris.scaffold.hunk.Hunk;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.TerrainChunk;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Data
|
||||
public class PregeneratedData {
|
||||
private final Hunk<BlockData> blocks;
|
||||
private final Hunk<BlockData> post;
|
||||
private final Hunk<Biome> biomes;
|
||||
private final AtomicBoolean postMod;
|
||||
|
||||
public PregeneratedData(int height)
|
||||
{
|
||||
postMod = new AtomicBoolean(false);
|
||||
blocks = Hunk.newAtomicHunk(16, height, 16);
|
||||
biomes = Hunk.newAtomicHunk(16, height, 16);
|
||||
Hunk<BlockData> p = Hunk.newMappedHunkSynced(16, height, 16);
|
||||
post = p.trackWrite(postMod);
|
||||
}
|
||||
|
||||
public Runnable inject(TerrainChunk tc) {
|
||||
blocks.iterateSync((x, y, z, b) -> {
|
||||
if(b != null)
|
||||
{
|
||||
tc.setBlock(x, y, z, b);
|
||||
}
|
||||
|
||||
Biome bf = biomes.get(x,y,z);
|
||||
if(bf != null)
|
||||
{
|
||||
tc.setBiome(x,y,z,bf);
|
||||
}
|
||||
});
|
||||
|
||||
if(postMod.get())
|
||||
{
|
||||
return () -> Hunk.view((ChunkGenerator.ChunkData) tc).insertSoftly(0,0,0, post, (b) -> b == null || B.isAirOrFluid(b));
|
||||
}
|
||||
|
||||
return () -> {};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user