Implement baseline caves

This commit is contained in:
Daniel Mills 2020-11-01 13:22:54 -05:00
parent cfc8458841
commit a9120edb70
6 changed files with 87 additions and 52 deletions

30
.idea/workspace.xml generated
View File

@ -44,7 +44,7 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" /> <property name="dart.analysis.tool.window.visible" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/com/volmit/iris/v2/nms" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/com/volmit/iris/v2/generator/nms" />
<property name="project.structure.last.edited" value="Modules" /> <property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.23643054" /> <property name="project.structure.side.proportion" value="0.23643054" />
@ -67,14 +67,14 @@
<recent name="com.volmit.iris.v2.scaffold.stream.utility" /> <recent name="com.volmit.iris.v2.scaffold.stream.utility" />
</key> </key>
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\generator\nms" />
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms" /> <recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms" />
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\mc16\r2" /> <recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\mc16\r2" />
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\abstract" /> <recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\abstract" />
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\mc16" /> <recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\v2\nms\mc16" />
<recent name="C:\Users\cyberpwn\Documents\development\workspace\Iris\src\main\java\com\volmit\iris\gen\v2\scaffold\hunk" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Maven.Iris Release"> <component name="RunManager" selected="Maven.Iris Build">
<configuration default="true" type="MavenRunConfiguration" factoryName="Maven"> <configuration default="true" type="MavenRunConfiguration" factoryName="Maven">
<MavenSettings> <MavenSettings>
<option name="myGeneralSettings" /> <option name="myGeneralSettings" />
@ -127,10 +127,10 @@
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state x="410" y="171" width="1234" height="708" key="#com.intellij.execution.impl.EditConfigurationsDialog/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603947263834" /> <state x="410" y="171" width="1234" height="708" key="#com.intellij.execution.impl.EditConfigurationsDialog/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603947263834" />
<state x="718" y="163" key="#com.intellij.ide.util.MemberChooser" timestamp="1604238671017"> <state x="718" y="163" key="#com.intellij.ide.util.MemberChooser" timestamp="1604254453027">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state x="718" y="163" key="#com.intellij.ide.util.MemberChooser/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604238671017" /> <state x="718" y="163" key="#com.intellij.ide.util.MemberChooser/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604254453027" />
<state x="675" y="394" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.classes" timestamp="1603943257126"> <state x="675" y="394" key="#com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesDialog.classes" timestamp="1603943257126">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
@ -147,22 +147,22 @@
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state x="485" y="234" key="#com.intellij.structuralsearch.plugin.ui.StructuralSearchDialog/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603860057506" /> <state x="485" y="234" key="#com.intellij.structuralsearch.plugin.ui.StructuralSearchDialog/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603860057506" />
<state width="1921" height="983" key="GridCell.Tab.0.bottom" timestamp="1604243429163"> <state width="1921" height="983" key="GridCell.Tab.0.bottom" timestamp="1604254677423">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state width="1921" height="983" key="GridCell.Tab.0.bottom/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604243429163" /> <state width="1921" height="983" key="GridCell.Tab.0.bottom/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604254677423" />
<state width="1921" height="983" key="GridCell.Tab.0.center" timestamp="1604243429163"> <state width="1921" height="983" key="GridCell.Tab.0.center" timestamp="1604254677423">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state width="1921" height="983" key="GridCell.Tab.0.center/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604243429163" /> <state width="1921" height="983" key="GridCell.Tab.0.center/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604254677423" />
<state width="1921" height="983" key="GridCell.Tab.0.left" timestamp="1604243429163"> <state width="1921" height="983" key="GridCell.Tab.0.left" timestamp="1604254677423">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state width="1921" height="983" key="GridCell.Tab.0.left/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604243429163" /> <state width="1921" height="983" key="GridCell.Tab.0.left/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604254677423" />
<state width="1921" height="983" key="GridCell.Tab.0.right" timestamp="1604243429163"> <state width="1921" height="983" key="GridCell.Tab.0.right" timestamp="1604254677423">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state width="1921" height="983" key="GridCell.Tab.0.right/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604243429163" /> <state width="1921" height="983" key="GridCell.Tab.0.right/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604254677423" />
<state x="312" y="0" key="SettingsEditor" timestamp="1603947206451"> <state x="312" y="0" key="SettingsEditor" timestamp="1603947206451">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
@ -175,9 +175,9 @@
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state x="532" y="239" key="run.anything.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603859771295" /> <state x="532" y="239" key="run.anything.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1603859771295" />
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup" timestamp="1604241752782"> <state x="539" y="15" width="840" height="1034" key="search.everywhere.popup" timestamp="1604253140774">
<screen x="0" y="0" width="1920" height="1050" /> <screen x="0" y="0" width="1920" height="1050" />
</state> </state>
<state x="539" y="15" width="840" height="1034" key="search.everywhere.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604241752782" /> <state x="539" y="15" width="840" height="1034" key="search.everywhere.popup/-1920.0.1920.1050/1920.0.1920.1050/0.0.1920.1050@0.0.1920.1050" timestamp="1604253140774" />
</component> </component>
</project> </project>

View File

@ -1,6 +1,8 @@
package com.volmit.iris.v2.generator; package com.volmit.iris.v2.generator;
import com.volmit.iris.Iris; 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.Engine;
import com.volmit.iris.v2.scaffold.engine.EngineFramework; import com.volmit.iris.v2.scaffold.engine.EngineFramework;
import com.volmit.iris.v2.scaffold.engine.EngineTarget; 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) { public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) {
MultiBurst.burst.burst( MultiBurst.burst.burst(
() -> getFramework().getEngineParallax().generateParallaxArea(x, z), () -> getFramework().getEngineParallax().generateParallaxArea(x, z),
() -> blocks.compute2D(getParallelism(), (xx,yy,zz, b) -> { () -> Hunk.computeDual2D(getParallelism(), blocks, biomes, (xx,yy,zz,ha,hb) -> {
getFramework().getTerrainActuator().actuate(x+xx, z+zz, b); getFramework().getTerrainActuator().actuate(x+xx, z+zz, ha);
getFramework().getDecorantActuator().actuate(x+xx, z+zz, b); getFramework().getCaveModifier().modify(x, z, ha);
}), getFramework().getDecorantActuator().actuate(x+xx, z+zz, ha);
()->biomes.compute2D(getParallelism(), (xx,yy,zz,b) -> { getFramework().getBiomeActuator().actuate(x+xx, z+zz, hb);
getFramework().getBiomeActuator().actuate(x+xx, z+zz, b);
}) })
); );
// getFramework().getCaveModifier().modify(x, z, blocks, biomes); blocks.compute2D(getParallelism(), (xx,yy,zz,ha) -> {
getFramework().getEngineParallax().insertParallax(x, z, blocks); getFramework().getEngineParallax().insertParallax(x, z, ha);
});
if(M.r(0.1))
{
MultiBurst.burst.lazy(() -> {
getParallax().cleanup(); getParallax().cleanup();
getData().getObjectLoader().clean();
});
}
} }
} }

View File

@ -16,7 +16,7 @@ import org.bukkit.block.data.BlockData;
import java.util.function.Function; 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 CAVE_AIR = B.getBlockData("CAVE_AIR");
public static final BlockData AIR = B.getBlockData("AIR"); public static final BlockData AIR = B.getBlockData("AIR");
@ -31,16 +31,14 @@ public class IrisCaveModifier extends EngineAssignedBiModifier<BlockData, Biome>
} }
@Override @Override
public void onModify(int x, int z, Hunk<BlockData> a, Hunk<Biome> b) { public void onModify(int x, int z, Hunk<BlockData> a) {
Hunk.computeDual2D(getParallelism(), a, b, (xx,yy,zz, ha, hb) -> { for(int i = 0; i < a.getWidth(); i++)
for(int i = 0; i < ha.getWidth(); i++)
{ {
for(int j = 0; j < ha.getDepth(); i++) for(int j = 0; j < a.getDepth(); j++)
{ {
genCaves(x + i, z + j, i, j, a);
} }
} };
});
} }
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data) public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, Hunk<BlockData> data)

View File

@ -5,8 +5,11 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean; 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.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@ -39,6 +42,18 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
initialized = new AtomicBoolean(false); 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() public void hotload()
{ {
Iris.globaldata.dump(); Iris.globaldata.dump();
@ -113,14 +128,19 @@ public class EngineCompositeGenerator extends ChunkGenerator implements Hotloada
@NotNull @NotNull
@Override @Override
public ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) { 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); initialize(world);
ChunkData chunk = createChunkData(world); Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
Hunk<BlockData> blocks = Hunk.view(chunk); Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
Hunk<Biome> biomes = Hunk.view(biome);
long m = M.ms(); long m = M.ms();
compound.generate(x * 16, z * 16, blocks, biomes); compound.generate(x * 16, z * 16, blocks, biomes);
System.out.println("Generated " + x + "," + z + " in " + Form.duration(M.ms() - m, 0)); System.out.println("Generated " + x + "," + z + " in " + Form.duration(M.ms() - m, 0));
return chunk;
} }
@Override @Override

View File

@ -80,38 +80,42 @@ public interface EngineParallax extends DataProvider, IObjectPlacer
return; return;
} }
data.compute2DYRange(getEngine().getParallelism(), meta.getMinObject(), meta.getMaxObject(), (xx,yy,zz,h)->{ for(int i = x; i < x+ data.getWidth(); i++)
for(int i = x+xx; i < x+xx+ h.getWidth(); i++)
{ {
for(int j= z+zz; j < z+zz + h.getDepth(); j++) for(int j= z; j < z + data.getDepth(); j++)
{ {
for(int k = yy; k < yy+h.getHeight(); k++) for(int k = 0; k < data.getHeight(); k++)
{ {
BlockData d = getParallaxAccess().getBlock(i, k, j); BlockData d = getParallaxAccess().getBlock(i, k, j);
if(d != null) if(d != null)
{ {
h.set(i - (x-xx), k-yy, j - (z+zz), d); data.set(i - x, k, j - z, d);
// DONT TRUST INTELIJ ^^^^
// ITS A FUCKING LIE
} }
} }
} }
} }
});
} }
default void generateParallaxArea(int x, int z) default void generateParallaxArea(int x, int z)
{ {
int s = (int) Math.ceil(getParallaxSize() / 2D); 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 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); getParallaxAccess().setChunkGenerated(x>>4, z>>4);
} }

View File

@ -27,4 +27,8 @@ public class MultiBurst
{ {
return burst(16); return burst(16);
} }
public void lazy(Runnable o) {
service.execute(o);
}
} }