mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-25 01:59:15 +00:00
Implement baseline caves
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.volmit.iris.v2.generator;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.v2.scaffold.engine.Engine;
|
||||
import com.volmit.iris.v2.scaffold.engine.EngineFramework;
|
||||
import com.volmit.iris.v2.scaffold.engine.EngineTarget;
|
||||
@@ -37,17 +39,24 @@ public class IrisEngine implements Engine
|
||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) {
|
||||
MultiBurst.burst.burst(
|
||||
() -> getFramework().getEngineParallax().generateParallaxArea(x, z),
|
||||
() -> blocks.compute2D(getParallelism(), (xx,yy,zz, b) -> {
|
||||
getFramework().getTerrainActuator().actuate(x+xx, z+zz, b);
|
||||
getFramework().getDecorantActuator().actuate(x+xx, z+zz, b);
|
||||
}),
|
||||
()->biomes.compute2D(getParallelism(), (xx,yy,zz,b) -> {
|
||||
getFramework().getBiomeActuator().actuate(x+xx, z+zz, b);
|
||||
() -> Hunk.computeDual2D(getParallelism(), blocks, biomes, (xx,yy,zz,ha,hb) -> {
|
||||
getFramework().getTerrainActuator().actuate(x+xx, z+zz, ha);
|
||||
getFramework().getCaveModifier().modify(x, z, ha);
|
||||
getFramework().getDecorantActuator().actuate(x+xx, z+zz, ha);
|
||||
getFramework().getBiomeActuator().actuate(x+xx, z+zz, hb);
|
||||
})
|
||||
);
|
||||
|
||||
// getFramework().getCaveModifier().modify(x, z, blocks, biomes);
|
||||
getFramework().getEngineParallax().insertParallax(x, z, blocks);
|
||||
getParallax().cleanup();
|
||||
blocks.compute2D(getParallelism(), (xx,yy,zz,ha) -> {
|
||||
getFramework().getEngineParallax().insertParallax(x, z, ha);
|
||||
});
|
||||
|
||||
if(M.r(0.1))
|
||||
{
|
||||
MultiBurst.burst.lazy(() -> {
|
||||
getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class IrisCaveModifier extends EngineAssignedBiModifier<BlockData, Biome>
|
||||
public class IrisCaveModifier extends EngineAssignedModifier<BlockData>
|
||||
{
|
||||
public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
@@ -31,16 +31,14 @@ public class IrisCaveModifier extends EngineAssignedBiModifier<BlockData, Biome>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModify(int x, int z, Hunk<BlockData> a, Hunk<Biome> b) {
|
||||
Hunk.computeDual2D(getParallelism(), a, b, (xx,yy,zz, ha, hb) -> {
|
||||
for(int i = 0; i < ha.getWidth(); i++)
|
||||
public void onModify(int x, int z, Hunk<BlockData> a) {
|
||||
for(int i = 0; i < a.getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < a.getDepth(); j++)
|
||||
{
|
||||
for(int j = 0; j < ha.getDepth(); i++)
|
||||
{
|
||||
|
||||
}
|
||||
genCaves(x + i, z + j, i, j, a);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data)
|
||||
|
||||
@@ -5,8 +5,11 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.volmit.iris.gen.scaffold.TerrainChunk;
|
||||
import com.volmit.iris.v2.generator.nms.v1X.DummyWorld;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
@@ -39,6 +42,18 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
|
||||
initialized = new AtomicBoolean(false);
|
||||
}
|
||||
|
||||
public EngineCompositeGenerator initDummy(WorldCreator wc)
|
||||
{
|
||||
return initDummy(new DummyWorld(wc.name(), wc.seed()));
|
||||
}
|
||||
|
||||
public EngineCompositeGenerator initDummy(World world)
|
||||
{
|
||||
initialize(world);
|
||||
initialized.lazySet(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void hotload()
|
||||
{
|
||||
Iris.globaldata.dump();
|
||||
@@ -113,14 +128,19 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
|
||||
@NotNull
|
||||
@Override
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||
generateChunkRawData(world, ignored, x, z, tc);
|
||||
return tc.getRaw();
|
||||
}
|
||||
|
||||
public void generateChunkRawData(World world, Random ignored, int x, int z, TerrainChunk tc)
|
||||
{
|
||||
initialize(world);
|
||||
ChunkData chunk = createChunkData(world);
|
||||
Hunk<BlockData> blocks = Hunk.view(chunk);
|
||||
Hunk<Biome> biomes = Hunk.view(biome);
|
||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||
long m = M.ms();
|
||||
compound.generate(x * 16, z * 16, blocks, biomes);
|
||||
System.out.println("Generated " + x + "," + z + " in " + Form.duration(M.ms() - m, 0));
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,38 +80,42 @@ public interface EngineParallax extends DataProvider, IObjectPlacer
|
||||
return;
|
||||
}
|
||||
|
||||
data.compute2DYRange(getEngine().getParallelism(), meta.getMinObject(), meta.getMaxObject(), (xx,yy,zz,h)->{
|
||||
for(int i = x+xx; i < x+xx+ h.getWidth(); i++)
|
||||
for(int i = x; i < x+ data.getWidth(); i++)
|
||||
{
|
||||
for(int j= z; j < z + data.getDepth(); j++)
|
||||
{
|
||||
for(int j= z+zz; j < z+zz + h.getDepth(); j++)
|
||||
for(int k = 0; k < data.getHeight(); k++)
|
||||
{
|
||||
for(int k = yy; k < yy+h.getHeight(); k++)
|
||||
{
|
||||
BlockData d = getParallaxAccess().getBlock(i, k, j);
|
||||
BlockData d = getParallaxAccess().getBlock(i, k, j);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
h.set(i - (x-xx), k-yy, j - (z+zz), d);
|
||||
// DONT TRUST INTELIJ ^^^^
|
||||
// ITS A FUCKING LIE
|
||||
}
|
||||
if(d != null)
|
||||
{
|
||||
data.set(i - x, k, j - z, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
default void generateParallaxArea(int x, int z)
|
||||
{
|
||||
int s = (int) Math.ceil(getParallaxSize() / 2D);
|
||||
int j;
|
||||
BurstExecutor e = MultiBurst.burst.burst(getParallaxSize() * getParallaxSize());
|
||||
|
||||
for(int i = -s; i <= s; i++)
|
||||
{
|
||||
for(int j = -s; j <= s; j++)
|
||||
int ii = i;
|
||||
|
||||
for(j = -s; j <= s; j++)
|
||||
{
|
||||
generateParallaxLayer((i*16)+x, (j*16)+z);
|
||||
int jj = j;
|
||||
e.queue(() -> generateParallaxLayer((ii*16)+x, (jj*16)+z));
|
||||
}
|
||||
}
|
||||
|
||||
e.complete();
|
||||
|
||||
getParallaxAccess().setChunkGenerated(x>>4, z>>4);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,4 +27,8 @@ public class MultiBurst
|
||||
{
|
||||
return burst(16);
|
||||
}
|
||||
|
||||
public void lazy(Runnable o) {
|
||||
service.execute(o);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user