mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-23 17:19:16 +00:00
Engine stages
This commit is contained in:
@@ -25,7 +25,9 @@ import com.volmit.iris.core.link.MythicMobsLink;
|
|||||||
import com.volmit.iris.core.link.OraxenLink;
|
import com.volmit.iris.core.link.OraxenLink;
|
||||||
import com.volmit.iris.core.loader.IrisData;
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
|
import com.volmit.iris.core.service.CommandSVC;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.core.service.WandSVC;
|
||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||||
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.volmit.iris.engine.modifier.IrisPostModifier;
|
|||||||
import com.volmit.iris.engine.object.*;
|
import com.volmit.iris.engine.object.*;
|
||||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||||
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.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.context.IrisContext;
|
import com.volmit.iris.util.context.IrisContext;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
@@ -85,6 +86,7 @@ public class IrisEngine implements Engine {
|
|||||||
private boolean failing;
|
private boolean failing;
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
private int cacheId;
|
private int cacheId;
|
||||||
|
private final KList<EngineStage> stages;
|
||||||
private final AtomicRollingSequence wallClock;
|
private final AtomicRollingSequence wallClock;
|
||||||
private final int art;
|
private final int art;
|
||||||
private double maxBiomeObjectDensity;
|
private double maxBiomeObjectDensity;
|
||||||
@@ -105,6 +107,7 @@ public class IrisEngine implements Engine {
|
|||||||
public IrisEngine(EngineTarget target, boolean studio) {
|
public IrisEngine(EngineTarget target, boolean studio) {
|
||||||
this.studio = studio;
|
this.studio = studio;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
stages = new KList<>();
|
||||||
getEngineData();
|
getEngineData();
|
||||||
verifySeed();
|
verifySeed();
|
||||||
this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed());
|
this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed());
|
||||||
@@ -180,6 +183,7 @@ public class IrisEngine implements Engine {
|
|||||||
postModifier = new IrisPostModifier(this);
|
postModifier = new IrisPostModifier(this);
|
||||||
caveModifier = new IrisCarveModifier(this);
|
caveModifier = new IrisCarveModifier(this);
|
||||||
effects = new IrisEngineEffects(this);
|
effects = new IrisEngineEffects(this);
|
||||||
|
setupStages();
|
||||||
J.a(this::computeBiomeMaxes);
|
J.a(this::computeBiomeMaxes);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.error("FAILED TO SETUP ENGINE!");
|
Iris.error("FAILED TO SETUP ENGINE!");
|
||||||
@@ -189,6 +193,17 @@ public class IrisEngine implements Engine {
|
|||||||
Iris.debug("Engine Setup Complete " + getCacheID());
|
Iris.debug("Engine Setup Complete " + getCacheID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupStages() {
|
||||||
|
registerStage((x, z, k, p, m) -> getMantle().generateMatter(x >> 4, z >> 4, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getTerrainActuator().actuate(x, z, k, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getBiomeActuator().actuate(x, z, p, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getDecorantActuator().actuate(x, z, k, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getCaveModifier().modify(x >> 4, z >> 4, k, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getPostModifier().modify(x, z, k, m));
|
||||||
|
registerStage((x, z, k, p, m) -> getDepositModifier().modify(x, z, k, m));
|
||||||
|
registerStage((x, z, K, p, m) -> getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, K, m));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
hotloadSilently();
|
hotloadSilently();
|
||||||
@@ -289,6 +304,11 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerStage(EngineStage stage) {
|
||||||
|
stages.add(stage);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockUpdatesPerSecond() {
|
public int getBlockUpdatesPerSecond() {
|
||||||
return buds.get();
|
return buds.get();
|
||||||
@@ -434,15 +454,12 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getMantle().generateMatter(x >> 4, z >> 4, multicore);
|
for(EngineStage i : stages)
|
||||||
getTerrainActuator().actuate(x, z, blocks, multicore);
|
{
|
||||||
getBiomeActuator().actuate(x, z, vbiomes, multicore);
|
i.generate(x, z, blocks, vbiomes, multicore);
|
||||||
getDecorantActuator().actuate(x, z, blocks, multicore);
|
}
|
||||||
getCaveModifier().modify(x >> 4, z >> 4, blocks, multicore);
|
|
||||||
getPostModifier().modify(x, z, blocks, multicore);
|
|
||||||
getDepositModifier().modify(x, z, blocks, multicore);
|
|
||||||
getMantle().insertMatter(x >> 4, z >> 4, BlockData.class, blocks, multicore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
generated.incrementAndGet();
|
generated.incrementAndGet();
|
||||||
recycle();
|
recycle();
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdater, Renderer, Hotloadable {
|
public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdater, Renderer, Hotloadable {
|
||||||
|
KList<EngineStage> getStages();
|
||||||
|
|
||||||
|
public void registerStage(EngineStage stage);
|
||||||
|
|
||||||
IrisComplex getComplex();
|
IrisComplex getComplex();
|
||||||
|
|
||||||
int getBlockUpdatesPerSecond();
|
int getBlockUpdatesPerSecond();
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* 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.framework;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
public interface EngineStage {
|
||||||
|
@BlockCoordinates
|
||||||
|
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore);
|
||||||
|
}
|
||||||
@@ -49,18 +49,17 @@ public class IrisFluidBodies {
|
|||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||||
//TODO: Impl
|
if (rivers.isNotEmpty()) {
|
||||||
// if (rivers.isNotEmpty()) {
|
for (IrisRiver i : rivers) {
|
||||||
// for (IrisRiver i : rivers) {
|
i.generate(writer, rng, engine, x, y, z);
|
||||||
// i.generate(writer, rng, engine, x, y, z);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
if (lakes.isNotEmpty()) {
|
||||||
// if (lakes.isNotEmpty()) {
|
for (IrisLake i : lakes) {
|
||||||
// for (IrisLake i : lakes) {
|
i.generate(writer, rng, engine, x, y, z);
|
||||||
// i.generate(writer, rng, engine, x, y, z);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxRange(IrisData data) {
|
public int getMaxRange(IrisData data) {
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ import com.volmit.iris.core.loader.IrisData;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||||
import com.volmit.iris.engine.object.annotations.*;
|
import com.volmit.iris.engine.object.annotations.*;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
|
import com.volmit.iris.util.matter.MatterFluidBody;
|
||||||
|
import com.volmit.iris.util.matter.slices.FluidBodyMatter;
|
||||||
|
import com.volmit.iris.util.noise.CNG;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@@ -50,10 +54,57 @@ public class IrisRiver implements IRare {
|
|||||||
@Desc("Force this river to only generate the specified custom biome")
|
@Desc("Force this river to only generate the specified custom biome")
|
||||||
private String customBiome = "";
|
private String customBiome = "";
|
||||||
|
|
||||||
|
@Desc("The width style of this lake")
|
||||||
|
private IrisShapedGeneratorStyle widthStyle = new IrisShapedGeneratorStyle(NoiseStyle.PERLIN.style(), 5, 9);
|
||||||
|
|
||||||
|
@Desc("The depth style of this lake")
|
||||||
|
private IrisShapedGeneratorStyle depthStyle = new IrisShapedGeneratorStyle(NoiseStyle.PERLIN.style(), 4, 7);
|
||||||
|
|
||||||
public int getSize(IrisData data) {
|
public int getSize(IrisData data) {
|
||||||
return worm.getMaxDistance();
|
return worm.getMaxDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||||
|
KList<IrisPosition> pos = getWorm().generate(rng, engine.getData(), writer, null, x, y, z, (at) -> {
|
||||||
|
});
|
||||||
|
CNG dg = depthStyle.getGenerator().createNoCache(rng, engine.getData());
|
||||||
|
CNG bw = widthStyle.getGenerator().createNoCache(rng, engine.getData());
|
||||||
|
IrisPosition avg;
|
||||||
|
double ax = 0;
|
||||||
|
double ay = 0;
|
||||||
|
double az = 0;
|
||||||
|
double[] surfaces = new double[pos.size()];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (IrisPosition p : pos) {
|
||||||
|
surfaces[i] = engine.getComplex().getHeightStream().get(x, z);
|
||||||
|
ax += p.getX();
|
||||||
|
ay += surfaces[i];
|
||||||
|
az += p.getZ();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
avg = new IrisPosition(ax / pos.size(), ay / pos.size(), az / pos.size());
|
||||||
|
MatterFluidBody body = FluidBodyMatter.get(customBiome, false);
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (IrisPosition p : pos) {
|
||||||
|
|
||||||
|
double surface = surfaces[i];
|
||||||
|
double depth = dg.fitDouble(depthStyle.getMin(), depthStyle.getMax(), p.getX(), p.getZ()) + (surface - avg.getY());
|
||||||
|
double width = bw.fitDouble(widthStyle.getMin(), widthStyle.getMax(), p.getX(), p.getZ());
|
||||||
|
|
||||||
|
if (depth > 1) {
|
||||||
|
writer.setElipsoidFunction(p.getX(), avg.getY(), p.getZ(), width, depth, width, true, (xx, yy, zz) -> {
|
||||||
|
if (yy > avg.getY()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return body;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user