mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Merge pull request #433 from VolmitSoftware/headless
Iris Headless Support
This commit is contained in:
commit
802574fb44
@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.volmit.iris'
|
group 'com.volmit.iris'
|
||||||
version '1.5.3'
|
version '1.5.3-HEADLESS'
|
||||||
def apiVersion = '1.17'
|
def apiVersion = '1.17'
|
||||||
def name = 'Iris'
|
def name = 'Iris'
|
||||||
def main = 'com.volmit.iris.Iris'
|
def main = 'com.volmit.iris.Iris'
|
||||||
|
@ -307,9 +307,9 @@ public class IrisProject {
|
|||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
activeProvider.close();
|
activeProvider.close();
|
||||||
File folder = activeProvider.getTarget().getWorld().getWorldFolder();
|
File folder = activeProvider.getTarget().getWorld().worldFolder();
|
||||||
Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().getName());
|
Iris.linkMultiverseCore.removeFromConfig(activeProvider.getTarget().getWorld().name());
|
||||||
Bukkit.unloadWorld(activeProvider.getTarget().getWorld().getName(), false);
|
Bukkit.unloadWorld(activeProvider.getTarget().getWorld().name(), false);
|
||||||
J.attemptAsync(() -> IO.delete(folder));
|
J.attemptAsync(() -> IO.delete(folder));
|
||||||
activeProvider = null;
|
activeProvider = null;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class CommandIrisStudioClose extends MortarCommand {
|
|||||||
World f = null;
|
World f = null;
|
||||||
|
|
||||||
for (World i : Bukkit.getWorlds()) {
|
for (World i : Bukkit.getWorlds()) {
|
||||||
if (i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getWorldFolder().getAbsolutePath())) {
|
if (i.getWorldFolder().getAbsolutePath().equals(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().worldFolder().getAbsolutePath())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
|
|||||||
|
|
||||||
if (Iris.proj.isProjectOpen()) {
|
if (Iris.proj.isProjectOpen()) {
|
||||||
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
|
generator = Iris.proj.getActiveProject().getActiveProvider().getData().getGeneratorLoader().load(args[0]);
|
||||||
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSeed();
|
seed = Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().seed();
|
||||||
} else {
|
} else {
|
||||||
generator = IrisDataManager.loadAnyGenerator(args[0]);
|
generator = IrisDataManager.loadAnyGenerator(args[0]);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class CommandIrisStudioTPStudio extends MortarCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
sender.sendMessage("Teleporting you to the active studio world.");
|
sender.sendMessage("Teleporting you to the active studio world.");
|
||||||
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().getSpawnLocation());
|
sender.player().teleport(Iris.proj.getActiveProject().getActiveProvider().getTarget().getWorld().spawnLocation());
|
||||||
sender.player().setGameMode(GameMode.SPECTATOR);
|
sender.player().setGameMode(GameMode.SPECTATOR);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
|
@ -60,8 +60,4 @@ public class IrisRenderer {
|
|||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(double worldX, double worldZ) {
|
|
||||||
renderer.getWorld().getBlockAt((int) worldX, 20, (int) worldZ).setType(Material.DIAMOND_BLOCK);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.engine.framework.IrisAccess;
|
import com.volmit.iris.engine.framework.IrisAccess;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
import com.volmit.iris.engine.object.IrisRegion;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
@ -70,7 +71,7 @@ public class IrisVision extends JPanel implements MouseWheelListener, KeyListene
|
|||||||
private boolean alt = false;
|
private boolean alt = false;
|
||||||
private int posX = 0;
|
private int posX = 0;
|
||||||
private IrisRenderer renderer;
|
private IrisRenderer renderer;
|
||||||
private World world;
|
private IrisWorld world;
|
||||||
private double velocity = 0;
|
private double velocity = 0;
|
||||||
private int lowq = 12;
|
private int lowq = 12;
|
||||||
private int posZ = 0;
|
private int posZ = 0;
|
||||||
@ -726,7 +727,7 @@ public class IrisVision extends JPanel implements MouseWheelListener, KeyListene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createAndShowGUI(Engine r, int s, World world) {
|
private static void createAndShowGUI(Engine r, int s, IrisWorld world) {
|
||||||
JFrame frame = new JFrame("Vision");
|
JFrame frame = new JFrame("Vision");
|
||||||
IrisVision nv = new IrisVision(frame);
|
IrisVision nv = new IrisVision(frame);
|
||||||
nv.world = world;
|
nv.world = world;
|
||||||
|
@ -250,7 +250,7 @@ public class Pregenerator implements Listener {
|
|||||||
method.set("Direct (Fast)");
|
method.set("Direct (Fast)");
|
||||||
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> e.queue(() -> {
|
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> e.queue(() -> {
|
||||||
draw(ii, jj, COLOR_MCA_GENERATE);
|
draw(ii, jj, COLOR_MCA_GENERATE);
|
||||||
access.directWriteChunk(world, ii, jj, directWriter);
|
access.directWriteChunk(access.getCompound().getWorld(), ii, jj, directWriter);
|
||||||
draw(ii, jj, COLOR_MCA_GENERATED_MCA);
|
draw(ii, jj, COLOR_MCA_GENERATED_MCA);
|
||||||
generated.getAndIncrement();
|
generated.getAndIncrement();
|
||||||
vcax.set(ii);
|
vcax.set(ii);
|
||||||
@ -286,7 +286,7 @@ public class Pregenerator implements Listener {
|
|||||||
int finalJ = j;
|
int finalJ = j;
|
||||||
requeue.add(() -> {
|
requeue.add(() -> {
|
||||||
draw(((x << 5) + finalI), ((z << 5) + finalJ), COLOR_MCA_GENERATE);
|
draw(((x << 5) + finalI), ((z << 5) + finalJ), COLOR_MCA_GENERATE);
|
||||||
access.directWriteChunk(world, ((x << 5) + finalI), ((z << 5) + finalJ), directWriter);
|
access.directWriteChunk(access.getCompound().getWorld(), ((x << 5) + finalI), ((z << 5) + finalJ), directWriter);
|
||||||
draw(((x << 5) + finalI), ((z << 5) + finalJ), COLOR_MCA_GENERATED_MCA);
|
draw(((x << 5) + finalI), ((z << 5) + finalJ), COLOR_MCA_GENERATED_MCA);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -108,14 +108,14 @@ public class IrisComplex implements DataProvider {
|
|||||||
|
|
||||||
public IrisComplex(Engine engine, boolean simple) {
|
public IrisComplex(Engine engine, boolean simple) {
|
||||||
int cacheSize = 1024 * 128;
|
int cacheSize = 1024 * 128;
|
||||||
this.rng = new RNG(engine.getWorld().getSeed());
|
this.rng = new RNG(engine.getWorld().seed());
|
||||||
this.data = engine.getData();
|
this.data = engine.getData();
|
||||||
double height = engine.getHeight();
|
double height = engine.getHeight();
|
||||||
fluidHeight = engine.getDimension().getFluidHeight();
|
fluidHeight = engine.getDimension().getFluidHeight();
|
||||||
generators = new KList<>();
|
generators = new KList<>();
|
||||||
focus = engine.getFocus();
|
focus = engine.getFocus();
|
||||||
IrisRegion focusRegion = focus != null ? findRegion(focus, engine) : null;
|
IrisRegion focusRegion = focus != null ? findRegion(focus, engine) : null;
|
||||||
RNG rng = new RNG(engine.getWorld().getSeed());
|
RNG rng = new RNG(engine.getWorld().seed());
|
||||||
//@builder
|
//@builder
|
||||||
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
||||||
.getAllBiomes(this).forEach((b) -> b
|
.getAllBiomes(this).forEach((b) -> b
|
||||||
@ -124,7 +124,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
|
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
|
||||||
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, x, z)));
|
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, x, z)));
|
||||||
rngStream = ProceduralStream.of((x, z) -> new RNG(((x.longValue()) << 32) | (z.longValue() & 0xffffffffL))
|
rngStream = ProceduralStream.of((x, z) -> new RNG(((x.longValue()) << 32) | (z.longValue() & 0xffffffffL))
|
||||||
.nextParallelRNG(engine.getWorld().getSeed()), Interpolated.RNG);
|
.nextParallelRNG(engine.getWorld().seed()), Interpolated.RNG);
|
||||||
chunkRngStream = rngStream.blockToChunkCoords();
|
chunkRngStream = rngStream.blockToChunkCoords();
|
||||||
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
||||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||||
@ -193,7 +193,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
.convertAware2D(this::implode).cache2D(cacheSize);
|
.convertAware2D(this::implode).cache2D(cacheSize);
|
||||||
heightStream = ProceduralStream.of((x, z) -> {
|
heightStream = ProceduralStream.of((x, z) -> {
|
||||||
IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z);
|
IrisBiome b = focus != null ? focus : baseBiomeStream.get(x, z);
|
||||||
return getHeight(engine, b, x, z, engine.getWorld().getSeed());
|
return getHeight(engine, b, x, z, engine.getWorld().seed());
|
||||||
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
||||||
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
||||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||||
|
@ -88,7 +88,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
private double maxBiomeDecoratorDensity;
|
private double maxBiomeDecoratorDensity;
|
||||||
|
|
||||||
public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
|
public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
|
||||||
Iris.info("Initializing Engine: " + target.getWorld().getName() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
Iris.info("Initializing Engine: " + target.getWorld().name() + "/" + target.getDimension().getLoadKey() + " (" + target.getHeight() + " height)");
|
||||||
metrics = new EngineMetrics(32);
|
metrics = new EngineMetrics(32);
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.framework = new IrisEngineFramework(this);
|
this.framework = new IrisEngineFramework(this);
|
||||||
|
@ -28,6 +28,7 @@ import com.volmit.iris.engine.hunk.Hunk;
|
|||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.engine.object.IrisDimensionIndex;
|
import com.volmit.iris.engine.object.IrisDimensionIndex;
|
||||||
import com.volmit.iris.engine.object.IrisPosition;
|
import com.volmit.iris.engine.object.IrisPosition;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
@ -50,7 +51,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class IrisEngineCompound implements EngineCompound {
|
public class IrisEngineCompound implements EngineCompound {
|
||||||
@Getter
|
@Getter
|
||||||
private World world;
|
private IrisWorld world;
|
||||||
|
|
||||||
private final AtomicRollingSequence wallClock;
|
private final AtomicRollingSequence wallClock;
|
||||||
|
|
||||||
@ -77,10 +78,10 @@ public class IrisEngineCompound implements EngineCompound {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean studio;
|
private boolean studio;
|
||||||
|
|
||||||
public IrisEngineCompound(World world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads) {
|
public IrisEngineCompound(IrisWorld world, IrisDimension rootDimension, IrisDataManager data, int maximumThreads) {
|
||||||
wallClock = new AtomicRollingSequence(32);
|
wallClock = new AtomicRollingSequence(32);
|
||||||
this.rootDimension = rootDimension;
|
this.rootDimension = rootDimension;
|
||||||
Iris.info("Initializing Engine Composite for " + world.getName());
|
Iris.info("Initializing Engine Composite for " + world.name());
|
||||||
this.world = world;
|
this.world = world;
|
||||||
engineMetadata = EngineData.load(getEngineMetadataFile());
|
engineMetadata = EngineData.load(getEngineMetadataFile());
|
||||||
engineMetadata.setDimension(rootDimension.getLoadKey());
|
engineMetadata.setDimension(rootDimension.getLoadKey());
|
||||||
@ -208,7 +209,7 @@ public class IrisEngineCompound implements EngineCompound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private File getEngineMetadataFile() {
|
private File getEngineMetadataFile() {
|
||||||
return new File(world.getWorldFolder(), "iris/engine-metadata.json");
|
return new File(world.worldFolder(), "iris/engine-metadata.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,11 +275,6 @@ public class IrisEngineCompound implements EngineCompound {
|
|||||||
return defaultEngine;
|
return defaultEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateWorld(World world) {
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
for (int i = 0; i < getSize(); i++) {
|
for (int i = 0; i < getSize(); i++) {
|
||||||
|
@ -21,7 +21,7 @@ package com.volmit.iris.engine;
|
|||||||
import com.volmit.iris.core.IrisDataManager;
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.util.fakenews.FakeWorld;
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
@ -78,8 +78,14 @@ public class IrisWorldCreator {
|
|||||||
|
|
||||||
public WorldCreator create() {
|
public WorldCreator create() {
|
||||||
EngineCompositeGenerator g = new EngineCompositeGenerator(dimensionName, !studio);
|
EngineCompositeGenerator g = new EngineCompositeGenerator(dimensionName, !studio);
|
||||||
g.initialize(new FakeWorld(name, minHeight, maxHeight, seed, new File(name), findEnvironment()));
|
g.initialize(IrisWorld.builder()
|
||||||
|
.name(name)
|
||||||
|
.minHeight(minHeight)
|
||||||
|
.maxHeight(maxHeight)
|
||||||
|
.seed(seed)
|
||||||
|
.worldFolder(new File(name))
|
||||||
|
.environment(findEnvironment())
|
||||||
|
.build());
|
||||||
return new WorldCreator(name)
|
return new WorldCreator(name)
|
||||||
.environment(findEnvironment())
|
.environment(findEnvironment())
|
||||||
.generateStructures(true)
|
.generateStructures(true)
|
||||||
|
@ -37,7 +37,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
|||||||
|
|
||||||
public IrisBiomeActuator(Engine engine) {
|
public IrisBiomeActuator(Engine engine) {
|
||||||
super(engine, "Biome");
|
super(engine, "Biome");
|
||||||
rng = new RNG(engine.getWorld().getSeed() + 243995);
|
rng = new RNG(engine.getWorld().seed() + 243995);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean injectBiome(Hunk<Biome> h, int x, int y, int z, Object bb) {
|
private boolean injectBiome(Hunk<Biome> h, int x, int y, int z, Object bb) {
|
||||||
|
@ -50,7 +50,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
|||||||
public IrisDecorantActuator(Engine engine) {
|
public IrisDecorantActuator(Engine engine) {
|
||||||
super(engine, "Decorant");
|
super(engine, "Decorant");
|
||||||
shouldRay = shouldRayDecorate();
|
shouldRay = shouldRayDecorate();
|
||||||
this.rng = new RNG(engine.getTarget().getWorld().getSeed());
|
this.rng = new RNG(engine.getTarget().getWorld().seed());
|
||||||
surfaceDecorator = new IrisSurfaceDecorator(getEngine());
|
surfaceDecorator = new IrisSurfaceDecorator(getEngine());
|
||||||
ceilingDecorator = new IrisCeilingDecorator(getEngine());
|
ceilingDecorator = new IrisCeilingDecorator(getEngine());
|
||||||
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
|
||||||
|
@ -45,7 +45,7 @@ public class IrisTerrainIslandActuator extends EngineAssignedActuator<BlockData>
|
|||||||
|
|
||||||
public IrisTerrainIslandActuator(Engine engine) {
|
public IrisTerrainIslandActuator(Engine engine) {
|
||||||
super(engine, "TerrainIsland");
|
super(engine, "TerrainIsland");
|
||||||
rng = new RNG(engine.getWorld().getSeed());
|
rng = new RNG(engine.getWorld().seed());
|
||||||
carving = getDimension().isCarving() && getDimension().getCarveLayers().isNotEmpty();
|
carving = getDimension().isCarving() && getDimension().getCarveLayers().isNotEmpty();
|
||||||
hasUnder = getDimension().getUndercarriage() != null && !getDimension().getUndercarriage().getGenerator().isFlat();
|
hasUnder = getDimension().getUndercarriage() != null && !getDimension().getUndercarriage().getGenerator().isFlat();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
|||||||
|
|
||||||
public IrisTerrainNormalActuator(Engine engine) {
|
public IrisTerrainNormalActuator(Engine engine) {
|
||||||
super(engine, "Terrain");
|
super(engine, "Terrain");
|
||||||
rng = new RNG(engine.getWorld().getSeed());
|
rng = new RNG(engine.getWorld().seed());
|
||||||
carving = getDimension().isCarving() && getDimension().getCarveLayers().isNotEmpty();
|
carving = getDimension().isCarving() && getDimension().getCarveLayers().isNotEmpty();
|
||||||
hasUnder = getDimension().getUndercarriage() != null && !getDimension().getUndercarriage().getGenerator().isFlat();
|
hasUnder = getDimension().getUndercarriage() != null && !getDimension().getUndercarriage().getGenerator().isFlat();
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,10 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.nms.BiomeBaseInjector;
|
import com.volmit.iris.core.nms.BiomeBaseInjector;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.util.data.IrisBiomeStorage;
|
import com.volmit.iris.util.data.IrisBiomeStorage;
|
||||||
import com.volmit.iris.util.fakenews.HeightedFakeWorld;
|
import net.minecraft.world.level.chunk.BiomeStorage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
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.ChunkGenerator.BiomeGrid;
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
@ -38,8 +39,14 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
|||||||
private ChunkData rawChunkData;
|
private ChunkData rawChunkData;
|
||||||
private final BiomeGrid storage;
|
private final BiomeGrid storage;
|
||||||
|
|
||||||
public LinkedTerrainChunk(int maxHeight) {
|
public LinkedTerrainChunk(World world)
|
||||||
this(null, maxHeight);
|
{
|
||||||
|
this(null, Bukkit.createChunkData(world));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedTerrainChunk(World world, BiomeGrid storage)
|
||||||
|
{
|
||||||
|
this(storage, Bukkit.createChunkData(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedTerrainChunk(BiomeGrid storage, ChunkData data) {
|
public LinkedTerrainChunk(BiomeGrid storage, ChunkData data) {
|
||||||
@ -48,23 +55,6 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
|||||||
biome3D = storage != null ? null : new IrisBiomeStorage();
|
biome3D = storage != null ? null : new IrisBiomeStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedTerrainChunk(BiomeGrid storage, int maxHeight) {
|
|
||||||
this.storage = storage;
|
|
||||||
rawChunkData = createChunkData(maxHeight);
|
|
||||||
biome3D = storage != null ? null : new IrisBiomeStorage();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ChunkData createChunkData(int maxHeight) {
|
|
||||||
try {
|
|
||||||
return Bukkit.createChunkData(new HeightedFakeWorld(maxHeight));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Iris.reportError(e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeBaseInjector getBiomeBaseInjector() {
|
public BiomeBaseInjector getBiomeBaseInjector() {
|
||||||
return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage);
|
return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage);
|
||||||
|
@ -28,25 +28,17 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public interface TerrainChunk extends BiomeGrid, ChunkData {
|
public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||||
static TerrainChunk create(World world) {
|
static TerrainChunk create(World world) {
|
||||||
return create(world.getMaxHeight());
|
return new LinkedTerrainChunk(world);
|
||||||
}
|
|
||||||
|
|
||||||
static TerrainChunk create(int maxHeight) {
|
|
||||||
return new LinkedTerrainChunk(maxHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static TerrainChunk create(World world, BiomeGrid grid) {
|
static TerrainChunk create(World world, BiomeGrid grid) {
|
||||||
return create(world.getMaxHeight(), grid);
|
return new LinkedTerrainChunk(world, grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TerrainChunk create(ChunkData raw, BiomeGrid grid) {
|
static TerrainChunk create(ChunkData raw, BiomeGrid grid) {
|
||||||
return new LinkedTerrainChunk(grid, raw);
|
return new LinkedTerrainChunk(grid, raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TerrainChunk create(int maxHeight, BiomeGrid grid) {
|
|
||||||
return new LinkedTerrainChunk(grid, maxHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
BiomeBaseInjector getBiomeBaseInjector();
|
BiomeBaseInjector getBiomeBaseInjector();
|
||||||
|
|
||||||
void setRaw(ChunkData data);
|
void setRaw(ChunkData data);
|
||||||
|
@ -27,6 +27,7 @@ import com.volmit.iris.engine.data.B;
|
|||||||
import com.volmit.iris.engine.data.DataProvider;
|
import com.volmit.iris.engine.data.DataProvider;
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
@ -105,7 +106,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
|||||||
return getTarget().getData();
|
return getTarget().getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
default World getWorld() {
|
default IrisWorld getWorld() {
|
||||||
return getTarget().getWorld();
|
return getTarget().getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public interface EngineComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default long getSeed() {
|
default long getSeed() {
|
||||||
return getTarget().getWorld().getSeed();
|
return getTarget().getWorld().seed();
|
||||||
}
|
}
|
||||||
|
|
||||||
default EngineFramework getFramework() {
|
default EngineFramework getFramework() {
|
||||||
|
@ -33,11 +33,11 @@ import com.volmit.iris.engine.hunk.Hunk;
|
|||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.engine.object.IrisPosition;
|
import com.volmit.iris.engine.object.IrisPosition;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.fakenews.FakeWorld;
|
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.io.ReactiveFolder;
|
import com.volmit.iris.util.io.ReactiveFolder;
|
||||||
@ -48,7 +48,6 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
|
|||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -79,9 +78,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
private long mst = 0;
|
private long mst = 0;
|
||||||
private int generated = 0;
|
private int generated = 0;
|
||||||
private int lgenerated = 0;
|
private int lgenerated = 0;
|
||||||
private final KMap<Long, PregeneratedData> chunkCache;
|
|
||||||
private final ChronoLatch hotloadcd;
|
private final ChronoLatch hotloadcd;
|
||||||
private final AtomicBoolean fake;
|
|
||||||
@Getter
|
@Getter
|
||||||
private double generatedPerSecond = 0;
|
private double generatedPerSecond = 0;
|
||||||
private final int art;
|
private final int art;
|
||||||
@ -93,8 +90,6 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
|
|
||||||
public EngineCompositeGenerator(String query, boolean production) {
|
public EngineCompositeGenerator(String query, boolean production) {
|
||||||
super();
|
super();
|
||||||
chunkCache = new KMap<>();
|
|
||||||
fake = new AtomicBoolean(true);
|
|
||||||
hotloadcd = new ChronoLatch(3500);
|
hotloadcd = new ChronoLatch(3500);
|
||||||
mst = M.ms();
|
mst = M.ms();
|
||||||
this.production = production;
|
this.production = production;
|
||||||
@ -113,6 +108,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
if (isStudio()) {
|
if (isStudio()) {
|
||||||
Iris.proj.updateWorkspace();
|
Iris.proj.updateWorkspace();
|
||||||
@ -158,14 +154,14 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized IrisDimension getDimension(World world) {
|
private synchronized IrisDimension getDimension(IrisWorld world) {
|
||||||
String query = dimensionQuery;
|
String query = dimensionQuery;
|
||||||
query = Iris.linkMultiverseCore.getWorldNameType(world.getName(), query);
|
query = Iris.linkMultiverseCore.getWorldNameType(world.name(), query);
|
||||||
|
|
||||||
IrisDimension dim = null;
|
IrisDimension dim = null;
|
||||||
|
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
File iris = new File(world.getWorldFolder(), "iris");
|
File iris = new File(world.worldFolder(), "iris");
|
||||||
|
|
||||||
if (iris.exists() && iris.isDirectory()) {
|
if (iris.exists() && iris.isDirectory()) {
|
||||||
for (File i : iris.listFiles()) {
|
for (File i : iris.listFiles()) {
|
||||||
@ -191,7 +187,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
Iris.error("Cannot find iris dimension data for world: " + world.getName() + "! Assuming " + IrisSettings.get().getGenerator().getDefaultWorldType() + "!");
|
Iris.error("Cannot find iris dimension data for world: " + world.name() + "! Assuming " + IrisSettings.get().getGenerator().getDefaultWorldType() + "!");
|
||||||
query = IrisSettings.get().getGenerator().getDefaultWorldType();
|
query = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,8 +209,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
dim = new IrisDataManager(getDataFolder(world)).getDimensionLoader().load(od.getLoadKey());
|
dim = new IrisDataManager(getDataFolder(world)).getDimensionLoader().load(od.getLoadKey());
|
||||||
|
|
||||||
if (dim == null) {
|
if (dim == null) {
|
||||||
Iris.info("Installing Iris pack " + od.getName() + " into world " + world.getName() + "...");
|
Iris.info("Installing Iris pack " + od.getName() + " into world " + world.name() + "...");
|
||||||
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), od.getLoadKey(), world.getWorldFolder());
|
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), od.getLoadKey(), world.worldFolder());
|
||||||
dim = new IrisDataManager(getDataFolder(world)).getDimensionLoader().load(od.getLoadKey());
|
dim = new IrisDataManager(getDataFolder(world)).getDimensionLoader().load(od.getLoadKey());
|
||||||
|
|
||||||
if (dim == null) {
|
if (dim == null) {
|
||||||
@ -294,20 +290,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return dim;
|
return dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initialize(World world) {
|
public synchronized void initialize(IrisWorld world) {
|
||||||
if (!(world instanceof FakeWorld) && fake.get() && this.compound.get() != null) {
|
|
||||||
fake.set(false);
|
|
||||||
this.compound.get().updateWorld(world);
|
|
||||||
getTarget().updateWorld(world);
|
|
||||||
placeStrongholds(world);
|
|
||||||
|
|
||||||
for (int i = 0; i < getComposite().getSize(); i++) {
|
|
||||||
getComposite().getEngine(i).getTarget().updateWorld(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
Iris.info("Attached Real World to Engine Target");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initialized.get()) {
|
if (initialized.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -445,8 +428,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getDataFolder(World world) {
|
private File getDataFolder(IrisWorld world) {
|
||||||
return new File(world.getWorldFolder(), "iris/pack");
|
return new File(world.worldFolder(), "iris/pack");
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getDataFolder(String world) {
|
private File getDataFolder(String world) {
|
||||||
@ -458,7 +441,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
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) {
|
||||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||||
generateChunkRawData(world, x, z, tc).run();
|
generateChunkRawData(getComposite().getWorld(), x, z, tc).run();
|
||||||
|
|
||||||
|
if(!getComposite().getWorld().hasRealWorld())
|
||||||
|
{
|
||||||
|
getComposite().getWorld().bind(world);
|
||||||
|
}
|
||||||
|
|
||||||
generated++;
|
generated++;
|
||||||
ps.end();
|
ps.end();
|
||||||
|
|
||||||
@ -469,7 +458,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return tc.getRaw();
|
return tc.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void directWriteMCA(World w, int x, int z, NBTWorld writer, MultiBurst burst) {
|
@Override
|
||||||
|
public void directWriteMCA(IrisWorld w, int x, int z, NBTWorld writer, MultiBurst burst) {
|
||||||
BurstExecutor e = burst.burst(1024);
|
BurstExecutor e = burst.burst(1024);
|
||||||
int mcaox = x << 5;
|
int mcaox = x << 5;
|
||||||
int mcaoz = z << 5;
|
int mcaoz = z << 5;
|
||||||
@ -485,7 +475,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
e.complete();
|
e.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void directWriteChunk(World w, int x, int z, NBTWorld writer) {
|
@Override
|
||||||
|
public void directWriteChunk(IrisWorld w, int x, int z, NBTWorld writer) {
|
||||||
int ox = x << 4;
|
int ox = x << 4;
|
||||||
int oz = z << 4;
|
int oz = z << 4;
|
||||||
com.volmit.iris.engine.data.mca.Chunk cc = writer.getChunk(x, z);
|
com.volmit.iris.engine.data.mca.Chunk cc = writer.getChunk(x, z);
|
||||||
@ -526,12 +517,12 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMinHeight() {
|
public int getMinHeight() {
|
||||||
return w.getMinHeight();
|
return w.minHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHeight() {
|
public int getMaxHeight() {
|
||||||
return w.getMaxHeight();
|
return w.maxHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -614,50 +605,8 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
}).run();
|
}).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk generatePaper(World world, int x, int z) {
|
public Runnable generateChunkRawData(IrisWorld world, int x, int z, TerrainChunk tc) {
|
||||||
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.get().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);
|
initialize(world);
|
||||||
|
|
||||||
synchronized (chunkCache) {
|
|
||||||
long g = Cache.key(x, z);
|
|
||||||
if (chunkCache.containsKey(g)) {
|
|
||||||
return chunkCache.remove(g).inject(tc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||||
Hunk<BlockData> post = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
Hunk<BlockData> post = Hunk.newAtomicHunk(biomes.getWidth(), biomes.getHeight(), biomes.getDepth());
|
||||||
@ -783,146 +732,15 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
// TODO: DO IT
|
// TODO: DO IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearRegeneratedLists(int x, int z) {
|
|
||||||
for (int i = 0; i < getComposite().getSize(); i++) {
|
|
||||||
getComposite().getEngine(i).getParallax().delete(x, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void regenerate(int x, int z) {
|
|
||||||
|
|
||||||
clearRegeneratedLists(x, z);
|
|
||||||
int xx = x * 16;
|
|
||||||
int zz = z * 16;
|
|
||||||
BiomeBaseInjector inj = (a, b, c, d) -> {
|
|
||||||
};
|
|
||||||
//noinspection deprecation
|
|
||||||
generateChunkRawData(getComposite().getWorld(), x, z, new TerrainChunk() {
|
|
||||||
@Override
|
|
||||||
public BiomeBaseInjector getBiomeBaseInjector() {
|
|
||||||
return inj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRaw(ChunkData data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Biome getBiome(int x, int z) {
|
|
||||||
return Biome.THE_VOID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Biome getBiome(int x, int y, int z) {
|
|
||||||
return Biome.THE_VOID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBiome(int x, int z, Biome bio) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBiome(int x, int y, int z, Biome bio) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinHeight() {
|
|
||||||
return getComposite().getWorld().getMinHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxHeight() {
|
|
||||||
return getComposite().getWorld().getMaxHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlock(int x, int y, int z, BlockData blockData) {
|
|
||||||
if (!getBlockData(x, y, z).matches(blockData)) {
|
|
||||||
Iris.edit.set(compound.get().getWorld(), x + xx, y, z + zz, blockData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public BlockData getBlockData(int x, int y, int z) {
|
|
||||||
return Iris.edit.get(compound.get().getWorld(), x + xx, y, z + zz);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChunkData getRaw() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inject(BiomeGrid biome) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlock(int i, int i1, int i2, @NotNull Material material) {
|
|
||||||
setBlock(i, i1, i2, material.createBlockData());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBlock(int i, int i1, int i2, @NotNull MaterialData materialData) {
|
|
||||||
setBlock(i, i1, i2, materialData.getItemType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegion(int i, int i1, int i2, int i3, int i4, int i5, @NotNull Material material) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegion(int i, int i1, int i2, int i3, int i4, int i5, @NotNull MaterialData materialData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRegion(int i, int i1, int i2, int i3, int i4, int i5, @NotNull BlockData blockData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Material getType(int i, int i1, int i2) {
|
|
||||||
return getBlockData(i, i1, i2).getMaterial();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MaterialData getTypeAndData(int i, int i1, int i2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte getData(int i, int i1, int i2) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Iris.edit.flushNow();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
J.car(art);
|
J.car(art);
|
||||||
if (getComposite() != null) {
|
if (getComposite() != null) {
|
||||||
getComposite().close();
|
getComposite().close();
|
||||||
|
|
||||||
|
if (isStudio() && getComposite().getWorld().hasRealWorld()) {
|
||||||
if (isStudio()) {
|
getComposite().getWorld().evacuate();
|
||||||
IrisWorlds.evacuate(getComposite().getWorld());
|
Bukkit.unloadWorld(getComposite().getWorld().realWorld(), !isStudio());
|
||||||
Bukkit.unloadWorld(getComposite().getWorld(), !isStudio());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import com.volmit.iris.engine.hunk.Hunk;
|
|||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.engine.object.IrisPosition;
|
import com.volmit.iris.engine.object.IrisPosition;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
@ -43,7 +44,7 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider {
|
|||||||
|
|
||||||
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes);
|
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<BlockData> postblocks, Hunk<Biome> biomes);
|
||||||
|
|
||||||
World getWorld();
|
IrisWorld getWorld();
|
||||||
|
|
||||||
List<IrisPosition> getStrongholdPositions();
|
List<IrisPosition> getStrongholdPositions();
|
||||||
|
|
||||||
@ -149,8 +150,6 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider {
|
|||||||
return v.v();
|
return v.v();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWorld(World world);
|
|
||||||
|
|
||||||
default int getLowestBedrock() {
|
default int getLowestBedrock() {
|
||||||
int f = Integer.MAX_VALUE;
|
int f = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
if (!getParallaxAccess().isFeatureGenerated(xx, zz)) {
|
if (!getParallaxAccess().isFeatureGenerated(xx, zz)) {
|
||||||
burst.queue(() -> {
|
burst.queue(() -> {
|
||||||
getParallaxAccess().setFeatureGenerated(xx, zz);
|
getParallaxAccess().setFeatureGenerated(xx, zz);
|
||||||
RNG rng = new RNG(Cache.key(xx, zz)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
|
RNG rng = new RNG(Cache.key(xx, zz)).nextParallelRNG(getEngine().getTarget().getWorld().seed());
|
||||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xxx, zzz);
|
||||||
generateParallaxFeatures(rng, xx, zz, region, biome);
|
generateParallaxFeatures(rng, xx, zz, region, biome);
|
||||||
@ -332,7 +332,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
if (getEngine().getDimension().isPlaceObjects()) {
|
if (getEngine().getDimension().isPlaceObjects()) {
|
||||||
int xx = x << 4;
|
int xx = x << 4;
|
||||||
int zz = z << 4;
|
int zz = z << 4;
|
||||||
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
|
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().seed());
|
||||||
IrisRegion region = getComplex().getRegionStream().get(xx + 8, zz + 8);
|
IrisRegion region = getComplex().getRegionStream().get(xx + 8, zz + 8);
|
||||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx + 8, zz + 8);
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx + 8, zz + 8);
|
||||||
after.addAll(generateParallaxJigsaw(rng, x, z, biome, region));
|
after.addAll(generateParallaxJigsaw(rng, x, z, biome, region));
|
||||||
@ -351,7 +351,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
int xx = x << 4;
|
int xx = x << 4;
|
||||||
int zz = z << 4;
|
int zz = z << 4;
|
||||||
getParallaxAccess().setParallaxGenerated(x, z);
|
getParallaxAccess().setParallaxGenerated(x, z);
|
||||||
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
|
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().seed());
|
||||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx + 8, zz + 8);
|
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx + 8, zz + 8);
|
||||||
IrisRegion region = getComplex().getRegionStream().get(xx + 8, zz + 8);
|
IrisRegion region = getComplex().getRegionStream().get(xx + 8, zz + 8);
|
||||||
generateParallaxSurface(rng, x, z, biome, region, false);
|
generateParallaxSurface(rng, x, z, biome, region, false);
|
||||||
|
@ -20,10 +20,10 @@ package com.volmit.iris.engine.framework;
|
|||||||
|
|
||||||
import com.volmit.iris.core.IrisDataManager;
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallax.ParallaxWorld;
|
import com.volmit.iris.engine.parallax.ParallaxWorld;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -31,27 +31,23 @@ import java.io.File;
|
|||||||
public class EngineTarget {
|
public class EngineTarget {
|
||||||
private final MultiBurst burster;
|
private final MultiBurst burster;
|
||||||
private final IrisDimension dimension;
|
private final IrisDimension dimension;
|
||||||
private World world;
|
private IrisWorld world;
|
||||||
private final int height;
|
private final int height;
|
||||||
private final IrisDataManager data;
|
private final IrisDataManager data;
|
||||||
private final ParallaxWorld parallaxWorld;
|
private final ParallaxWorld parallaxWorld;
|
||||||
private final boolean inverted;
|
private final boolean inverted;
|
||||||
|
|
||||||
public EngineTarget(World world, IrisDimension dimension, IrisDataManager data, int height, boolean inverted, int threads) {
|
public EngineTarget(IrisWorld world, IrisDimension dimension, IrisDataManager data, int height, boolean inverted, int threads) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.parallaxWorld = new ParallaxWorld(256, new File(world.getWorldFolder(), "iris/" + dimension.getLoadKey() + "/parallax"));
|
this.parallaxWorld = new ParallaxWorld(256, new File(world.worldFolder(), "iris/" + dimension.getLoadKey() + "/parallax"));
|
||||||
this.inverted = inverted;
|
this.inverted = inverted;
|
||||||
this.burster = new MultiBurst(threads);
|
this.burster = new MultiBurst(threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateWorld(World world) {
|
public EngineTarget(IrisWorld world, IrisDimension dimension, IrisDataManager data, int height, int threads) {
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EngineTarget(World world, IrisDimension dimension, IrisDataManager data, int height, int threads) {
|
|
||||||
this(world, dimension, data, height, false, threads);
|
this(world, dimension, data, height, false, threads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.volmit.iris.engine.data.DataProvider;
|
|||||||
import com.volmit.iris.engine.data.mca.NBTWorld;
|
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisRegion;
|
import com.volmit.iris.engine.object.IrisRegion;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
@ -44,9 +45,9 @@ import java.util.function.Consumer;
|
|||||||
@SuppressWarnings("EmptyMethod")
|
@SuppressWarnings("EmptyMethod")
|
||||||
public interface IrisAccess extends Hotloadable, DataProvider {
|
public interface IrisAccess extends Hotloadable, DataProvider {
|
||||||
|
|
||||||
void directWriteMCA(World w, int x, int z, NBTWorld writer, MultiBurst burst);
|
void directWriteMCA(IrisWorld w, int x, int z, NBTWorld writer, MultiBurst burst);
|
||||||
|
|
||||||
void directWriteChunk(World w, int x, int z, NBTWorld writer);
|
void directWriteChunk(IrisWorld w, int x, int z, NBTWorld writer);
|
||||||
|
|
||||||
int getGenerated();
|
int getGenerated();
|
||||||
|
|
||||||
@ -72,8 +73,6 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
void changeThreadCount(int m);
|
void changeThreadCount(int m);
|
||||||
|
|
||||||
void regenerate(int x, int z);
|
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
boolean isClosed();
|
boolean isClosed();
|
||||||
@ -87,6 +86,12 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
boolean isStudio();
|
boolean isStudio();
|
||||||
|
|
||||||
default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc) {
|
default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc) {
|
||||||
|
if(!getCompound().getWorld().hasRealWorld())
|
||||||
|
{
|
||||||
|
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
IrisComplex.cacheLock.set(true);
|
IrisComplex.cacheLock.set(true);
|
||||||
ChronoLatch cl = new ChronoLatch(250, false);
|
ChronoLatch cl = new ChronoLatch(250, false);
|
||||||
long s = M.ms();
|
long s = M.ms();
|
||||||
@ -130,7 +135,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
if (b != null && b.getLoadKey().equals(biome.getLoadKey())) {
|
if (b != null && b.getLoadKey().equals(biome.getLoadKey())) {
|
||||||
found.lazySet(true);
|
found.lazySet(true);
|
||||||
location.lazySet(new Location(e.getWorld(), x, e.getHeight(x, z), z));
|
location.lazySet(new Location(e.getWorld().realWorld(), x, e.getHeight(x, z), z));
|
||||||
}
|
}
|
||||||
|
|
||||||
tries.getAndIncrement();
|
tries.getAndIncrement();
|
||||||
@ -167,6 +172,12 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Location lookForRegion(IrisRegion reg, long timeout, Consumer<Integer> triesc) {
|
default Location lookForRegion(IrisRegion reg, long timeout, Consumer<Integer> triesc) {
|
||||||
|
if(!getCompound().getWorld().hasRealWorld())
|
||||||
|
{
|
||||||
|
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
IrisComplex.cacheLock.set(true);
|
IrisComplex.cacheLock.set(true);
|
||||||
ChronoLatch cl = new ChronoLatch(3000, false);
|
ChronoLatch cl = new ChronoLatch(3000, false);
|
||||||
long s = M.ms();
|
long s = M.ms();
|
||||||
@ -204,7 +215,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
if (b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) {
|
if (b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) {
|
||||||
found.lazySet(true);
|
found.lazySet(true);
|
||||||
location.lazySet(new Location(e.getWorld(), x, e.getHeight(x, z) + e.getMinHeight(), z));
|
location.lazySet(new Location(e.getWorld().realWorld(), x, e.getHeight(x, z) + e.getMinHeight(), z));
|
||||||
}
|
}
|
||||||
|
|
||||||
tries.getAndIncrement();
|
tries.getAndIncrement();
|
||||||
@ -238,14 +249,6 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
return location.get();
|
return location.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearRegeneratedLists(int x, int z);
|
|
||||||
|
|
||||||
void precache(World world, int x, int z);
|
|
||||||
|
|
||||||
int getPrecacheSize();
|
|
||||||
|
|
||||||
Chunk generatePaper(World world, int cx, int cz);
|
|
||||||
|
|
||||||
default int getParallaxChunkCount() {
|
default int getParallaxChunkCount() {
|
||||||
int v = 0;
|
int v = 0;
|
||||||
|
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.headless;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||||
|
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||||
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HeadlessGenerator {
|
||||||
|
private final HeadlessWorld world;
|
||||||
|
private final EngineCompositeGenerator generator;
|
||||||
|
private final NBTWorld writer;
|
||||||
|
private final MultiBurst burst;
|
||||||
|
|
||||||
|
public HeadlessGenerator(HeadlessWorld world)
|
||||||
|
{
|
||||||
|
this.world = world;
|
||||||
|
burst = new MultiBurst("Iris Headless Generator", 9, Runtime.getRuntime().availableProcessors());
|
||||||
|
generator = new EngineCompositeGenerator(world.getDimension().getLoadKey(), true);
|
||||||
|
generator.initialize(world.getWorld());
|
||||||
|
writer = new NBTWorld(world.getWorld().worldFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateChunk(int x, int z)
|
||||||
|
{
|
||||||
|
generator.directWriteChunk(world.getWorld(), x, z, writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateRegion(int x, int z)
|
||||||
|
{
|
||||||
|
generator.directWriteMCA(world.getWorld(), x, z, writer, burst);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
writer.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
burst.shutdownAndAwait();
|
||||||
|
generator.close();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.headless;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
|
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||||
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
|
public class HeadlessWorld {
|
||||||
|
private final IrisDimension dimension;
|
||||||
|
private final String worldName;
|
||||||
|
private final IrisWorld world;
|
||||||
|
|
||||||
|
public HeadlessWorld(String worldName, IrisDimension dimension, long seed)
|
||||||
|
{
|
||||||
|
this.worldName = worldName;
|
||||||
|
this.dimension = dimension;
|
||||||
|
world = IrisWorld.builder()
|
||||||
|
.environment(dimension.getEnvironment())
|
||||||
|
.worldFolder(new File(worldName))
|
||||||
|
.seed(seed)
|
||||||
|
.maxHeight(256)
|
||||||
|
.minHeight(0)
|
||||||
|
.name(worldName)
|
||||||
|
.build();
|
||||||
|
world.worldFolder().mkdirs();
|
||||||
|
new File(world.worldFolder(), "region").mkdirs();
|
||||||
|
|
||||||
|
if(!new File(world.worldFolder(), "iris").exists())
|
||||||
|
{
|
||||||
|
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeadlessGenerator headlessMode()
|
||||||
|
{
|
||||||
|
return new HeadlessGenerator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public World load()
|
||||||
|
{
|
||||||
|
return new WorldCreator(worldName)
|
||||||
|
.environment(dimension.getEnvironment())
|
||||||
|
.seed(world.seed())
|
||||||
|
.generator(new EngineCompositeGenerator(dimension.getLoadKey(), true))
|
||||||
|
.createWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HeadlessWorld from(String name, String dimension, long seed)
|
||||||
|
{
|
||||||
|
return new HeadlessWorld(name, IrisDataManager.loadAnyDimension(dimension), seed);
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,7 @@ public class IrisCaveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
public IrisCaveModifier(Engine engine) {
|
public IrisCaveModifier(Engine engine) {
|
||||||
super(engine, "Cave");
|
super(engine, "Cave");
|
||||||
rng = new RNG(engine.getWorld().getSeed() + 28934555);
|
rng = new RNG(engine.getWorld().seed() + 28934555);
|
||||||
gg = new FastNoiseDouble(324895L * rng.nextParallelRNG(49678).imax());
|
gg = new FastNoiseDouble(324895L * rng.nextParallelRNG(49678).imax());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
public IrisDepositModifier(Engine engine) {
|
public IrisDepositModifier(Engine engine) {
|
||||||
super(engine, "Deposit");
|
super(engine, "Deposit");
|
||||||
rng = new RNG(getEngine().getWorld().getSeed() + 12938).nextParallelRNG(28348777);
|
rng = new RNG(getEngine().getWorld().seed() + 12938).nextParallelRNG(28348777);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,7 +40,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
public IrisPostModifier(Engine engine) {
|
public IrisPostModifier(Engine engine) {
|
||||||
super(engine, "Post");
|
super(engine, "Post");
|
||||||
rng = new RNG(getEngine().getWorld().getSeed() + 12938).nextParallelRNG(28348777);
|
rng = new RNG(getEngine().getWorld().seed() + 12938).nextParallelRNG(28348777);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
public IrisRavineModifier(Engine engine) {
|
public IrisRavineModifier(Engine engine) {
|
||||||
super(engine, "Ravine");
|
super(engine, "Ravine");
|
||||||
rng = new RNG(getEngine().getWorld().getSeed()).nextParallelRNG(29596878);
|
rng = new RNG(getEngine().getWorld().seed()).nextParallelRNG(29596878);
|
||||||
cng = NoiseStyle.IRIS_THICK.create(rng);
|
cng = NoiseStyle.IRIS_THICK.create(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class IrisEntityInitialSpawn {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)).i(1, getRarity()) == 1) {
|
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)).i(1, getRarity()) == 1) {
|
||||||
return spawn100(g, at);
|
return spawn100(g, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +90,6 @@ public class IrisEntityInitialSpawn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Entity spawn100(Engine g, Location at) {
|
private Entity spawn100(Engine g, Location at) {
|
||||||
return getRealEntity(g).spawn(g, at.clone().add(0.5, 1, 0.5), rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)));
|
return getRealEntity(g).spawn(g, at.clone().add(0.5, 1, 0.5), rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,8 @@ public class IrisEntitySpawnOverride {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)).i(1, getRarity()) == 1) {
|
if (rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)).i(1, getRarity()) == 1) {
|
||||||
return getRealEntity(g).spawn(g, at, rng.aquire(() -> new RNG(g.getTarget().getWorld().getSeed() + 4)));
|
return getRealEntity(g).spawn(g, at, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -18,28 +18,94 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object.common;
|
package com.volmit.iris.engine.object.common;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.engine.IrisWorlds;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true, fluent = true)
|
||||||
public class IrisWorld {
|
public class IrisWorld {
|
||||||
|
private static final KList<Player> NO_PLAYERS = new KList<>();
|
||||||
|
private static final KList<? extends Entity> NO_ENTITIES = new KList<>();
|
||||||
private String name;
|
private String name;
|
||||||
private File worldFolder;
|
private File worldFolder;
|
||||||
private long seed;
|
private long seed;
|
||||||
private World.Environment environment;
|
private World.Environment environment;
|
||||||
private boolean real;
|
private World realWorld;
|
||||||
|
private int minHeight;
|
||||||
|
private int maxHeight;
|
||||||
|
|
||||||
public static IrisWorld fromWorld(World world)
|
public static IrisWorld fromWorld(World world)
|
||||||
{
|
{
|
||||||
return IrisWorld.builder()
|
return bindWorld(IrisWorld.builder().build(), world);
|
||||||
.name(world.getName())
|
}
|
||||||
.worldFolder(world.getWorldFolder())
|
|
||||||
.seed(world.getSeed())
|
private static IrisWorld bindWorld(IrisWorld iw, World world)
|
||||||
.environment(world.getEnvironment())
|
{
|
||||||
.build();
|
return iw.name(world.getName())
|
||||||
|
.worldFolder(world.getWorldFolder())
|
||||||
|
.seed(world.getSeed())
|
||||||
|
.minHeight(world.getMinHeight())
|
||||||
|
.maxHeight(world.getMaxHeight())
|
||||||
|
.realWorld(world)
|
||||||
|
.environment(world.getEnvironment());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRealWorld()
|
||||||
|
{
|
||||||
|
return realWorld != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Player> getPlayers() {
|
||||||
|
|
||||||
|
if(hasRealWorld())
|
||||||
|
{
|
||||||
|
return realWorld().getPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NO_PLAYERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void evacuate() {
|
||||||
|
if(hasRealWorld())
|
||||||
|
{
|
||||||
|
IrisWorlds.evacuate(realWorld());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bind(World world) {
|
||||||
|
bindWorld(this, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location spawnLocation() {
|
||||||
|
if(hasRealWorld())
|
||||||
|
{
|
||||||
|
return realWorld().getSpawnLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.error("This world is not real yet, cannot get spawn location! HEADLESS!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Entity> Collection<? extends T> getEntitiesByClass(Class<T> t) {
|
||||||
|
if(hasRealWorld())
|
||||||
|
{
|
||||||
|
return realWorld().getEntitiesByClass(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (KList<? extends T>) NO_ENTITIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,4 +95,22 @@ public class MultiBurst {
|
|||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdownAndAwait() {
|
||||||
|
service.shutdown();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while(!service.awaitTermination(10, TimeUnit.SECONDS))
|
||||||
|
{
|
||||||
|
Iris.info("Still waiting to shutdown burster...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
Iris.reportError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,197 +0,0 @@
|
|||||||
/*
|
|
||||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
|
||||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.volmit.iris.util.fakenews;
|
|
||||||
|
|
||||||
import com.volmit.iris.core.IrisDataManager;
|
|
||||||
import com.volmit.iris.engine.IrisEngineFramework;
|
|
||||||
import com.volmit.iris.engine.framework.*;
|
|
||||||
import com.volmit.iris.engine.hunk.Hunk;
|
|
||||||
import com.volmit.iris.engine.object.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
|
|
||||||
|
|
||||||
public class FakeEngine implements Engine {
|
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private double maxBiomeObjectDensity;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private double maxBiomeLayerDensity;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private double maxBiomeDecoratorDensity;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final IrisDimension dimension;
|
|
||||||
|
|
||||||
private final EngineFramework framework;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final World world;
|
|
||||||
|
|
||||||
public FakeEngine(IrisDimension dimension, FakeWorld world) {
|
|
||||||
this.dimension = dimension;
|
|
||||||
this.world = world;
|
|
||||||
computeBiomeMaxes();
|
|
||||||
this.framework = new IrisEngineFramework(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void computeBiomeMaxes() {
|
|
||||||
for (IrisBiome i : getDimension().getAllBiomes(this)) {
|
|
||||||
double density = 0;
|
|
||||||
|
|
||||||
for (IrisObjectPlacement j : i.getObjects()) {
|
|
||||||
density += j.getDensity() * j.getChance();
|
|
||||||
}
|
|
||||||
|
|
||||||
maxBiomeObjectDensity = Math.max(maxBiomeObjectDensity, density);
|
|
||||||
density = 0;
|
|
||||||
|
|
||||||
for (IrisDecorator j : i.getDecorators()) {
|
|
||||||
density += Math.max(j.getStackMax(), 1) * j.getChance();
|
|
||||||
}
|
|
||||||
|
|
||||||
maxBiomeDecoratorDensity = Math.max(maxBiomeDecoratorDensity, density);
|
|
||||||
density = 0;
|
|
||||||
|
|
||||||
for (IrisBiomePaletteLayer j : i.getLayers()) {
|
|
||||||
density++;
|
|
||||||
}
|
|
||||||
|
|
||||||
maxBiomeLayerDensity = Math.max(maxBiomeLayerDensity, density);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isClosed() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IrisDataManager getData() {
|
|
||||||
return dimension.getLoader().copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineWorldManager getWorldManager() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setParallelism(int parallelism) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getParallelism() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineTarget getTarget() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineFramework getFramework() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMinHeight(int min) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void recycle() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIndex() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinHeight() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double modifyX(double x) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double modifyZ(double z) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineMetrics getMetrics() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineEffects getEffects() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EngineCompound getCompound() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IrisBiome getFocus() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fail(String error, Throwable e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasFailed() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCacheID() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hotload() {
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user