mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 03:29:06 +00:00
The engine is the framework
This commit is contained in:
@@ -230,7 +230,7 @@ public class IrisComplex implements DataProvider {
|
||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||
if (engine.getDimension().hasFeatures(engine)) {
|
||||
AtomicDouble str = new AtomicDouble(1D);
|
||||
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||
for (IrisFeaturePositional i : engine.getEngineParallax().forEachFeature(x, z)) {
|
||||
str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z, rng, getData())));
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class IrisComplex implements DataProvider {
|
||||
});
|
||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
||||
b -> focus)).convertAware2D((b, x, z) -> {
|
||||
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||
for (IrisFeaturePositional i : engine.getEngineParallax().forEachFeature(x, z)) {
|
||||
IrisBiome bx = i.filter(x, z, b, rng);
|
||||
|
||||
if (bx != null) {
|
||||
@@ -257,7 +257,7 @@ public class IrisComplex implements DataProvider {
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.convertAware2D((b, x, z) -> {
|
||||
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||
for (IrisFeaturePositional i : engine.getEngineParallax().forEachFeature(x, z)) {
|
||||
IrisBiome bx = i.filter(x, z, b, rng);
|
||||
|
||||
if (bx != null) {
|
||||
@@ -271,7 +271,7 @@ public class IrisComplex implements DataProvider {
|
||||
.cache2D(cacheSize);
|
||||
trueBiomeStream = focus != null ? ProceduralStream.of((x, y) -> focus, Interpolated.of(a -> 0D,
|
||||
b -> focus)).convertAware2D((b, x, z) -> {
|
||||
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||
for (IrisFeaturePositional i : engine.getEngineParallax().forEachFeature(x, z)) {
|
||||
IrisBiome bx = i.filter(x, z, b, rng);
|
||||
|
||||
if (bx != null) {
|
||||
@@ -287,7 +287,7 @@ public class IrisComplex implements DataProvider {
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.convertAware2D((b, x, z) -> {
|
||||
for (IrisFeaturePositional i : engine.getFramework().getEngineParallax().forEachFeature(x, z)) {
|
||||
for (IrisFeaturePositional i : engine.getEngineParallax().forEachFeature(x, z)) {
|
||||
IrisBiome bx = i.filter(x, z, b, rng);
|
||||
|
||||
if (bx != null) {
|
||||
@@ -330,17 +330,17 @@ public class IrisComplex implements DataProvider {
|
||||
int m = heightf;
|
||||
|
||||
if (engine.getDimension().isCarving() && engine.getDimension().getTerrainMode().equals(IrisTerrainMode.NORMAL)) {
|
||||
if (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getFramework().getTerrainActuator()).getRng(), heightf)) {
|
||||
if (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getTerrainActuator()).getRng(), heightf)) {
|
||||
m--;
|
||||
|
||||
while (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getFramework().getTerrainActuator()).getRng(), heightf)) {
|
||||
while (engine.getDimension().isCarved(getData(), rx, m, rz, ((IrisTerrainNormalActuator) engine.getTerrainActuator()).getRng(), heightf)) {
|
||||
m--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (engine.getDimension().isCaves()) {
|
||||
KList<CaveResult> caves = ((IrisCaveModifier) engine.getFramework().getCaveModifier()).genCaves(rx, rz, 0, 0, null);
|
||||
KList<CaveResult> caves = ((IrisCaveModifier) engine.getCaveModifier()).genCaves(rx, rz, 0, 0, null);
|
||||
boolean again = true;
|
||||
|
||||
while (again) {
|
||||
@@ -458,7 +458,7 @@ public class IrisComplex implements DataProvider {
|
||||
AtomicDouble noise = new AtomicDouble(h + fluidHeight + overlayStream.get(x, z));
|
||||
|
||||
if (features) {
|
||||
List<IrisFeaturePositional> p = engine.getFramework().getEngineParallax().forEachFeature(x, z);
|
||||
List<IrisFeaturePositional> p = engine.getEngineParallax().forEachFeature(x, z);
|
||||
|
||||
for (IrisFeaturePositional i : p) {
|
||||
noise.set(i.filter(x, z, noise.get(), rng, getData()));
|
||||
|
||||
@@ -20,9 +20,18 @@ package com.volmit.iris.engine;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
|
||||
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisTerrainIslandActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.*;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisDepositModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisRavineModifier;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
||||
@@ -35,10 +44,10 @@ import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@@ -48,57 +57,40 @@ import org.bukkit.generator.BlockPopulator;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Data
|
||||
public class IrisEngine extends BlockPopulator implements Engine {
|
||||
@Getter
|
||||
private final EngineCompound compound;
|
||||
|
||||
@Getter
|
||||
private final EngineTarget target;
|
||||
|
||||
@Getter
|
||||
private final IrisContext context;
|
||||
|
||||
@Getter
|
||||
private final EngineFramework framework;
|
||||
|
||||
@Getter
|
||||
private final EngineEffects effects;
|
||||
|
||||
@Getter
|
||||
private final EngineExecutionEnvironment execution;
|
||||
|
||||
@Getter
|
||||
private final EngineWorldManager worldManager;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private volatile int parallelism;
|
||||
|
||||
@Getter
|
||||
private final int index;
|
||||
|
||||
@Getter
|
||||
private final EngineMetrics metrics;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private volatile int minHeight;
|
||||
private boolean failing;
|
||||
private boolean closed;
|
||||
private int cacheId;
|
||||
private final int art;
|
||||
|
||||
@Getter
|
||||
private double maxBiomeObjectDensity;
|
||||
|
||||
@Getter
|
||||
private double maxBiomeLayerDensity;
|
||||
|
||||
@Getter
|
||||
private double maxBiomeDecoratorDensity;
|
||||
|
||||
private final IrisComplex complex;
|
||||
private final EngineParallaxManager engineParallax;
|
||||
private final EngineActuator<BlockData> terrainNormalActuator;
|
||||
private final EngineActuator<BlockData> terrainIslandActuator;
|
||||
private final EngineActuator<BlockData> decorantActuator;
|
||||
private final EngineActuator<Biome> biomeActuator;
|
||||
private final EngineModifier<BlockData> depositModifier;
|
||||
private final EngineModifier<BlockData> caveModifier;
|
||||
private final EngineModifier<BlockData> ravineModifier;
|
||||
private final EngineModifier<BlockData> postModifier;
|
||||
private final AtomicCache<IrisEngineData> engineData = new AtomicCache<>();
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngine(EngineTarget target, EngineCompound compound, int index) {
|
||||
execution = new IrisExecutionEnvironment(this);
|
||||
@@ -107,7 +99,6 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
this.target = target;
|
||||
getData().setEngine(this);
|
||||
getEngineData();
|
||||
this.framework = new IrisEngineFramework(this);
|
||||
worldManager = new IrisWorldManager(this);
|
||||
this.compound = compound;
|
||||
minHeight = 0;
|
||||
@@ -121,6 +112,20 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
Iris.callEvent(new IrisEngineHotloadEvent(this));
|
||||
context = new IrisContext(this);
|
||||
context.touch();
|
||||
this.complex = new IrisComplex(this);
|
||||
this.engineParallax = new IrisEngineParallax(this);
|
||||
this.terrainNormalActuator = new IrisTerrainNormalActuator(this);
|
||||
this.terrainIslandActuator = new IrisTerrainIslandActuator(this);
|
||||
this.decorantActuator = new IrisDecorantActuator(this);
|
||||
this.biomeActuator = new IrisBiomeActuator(this);
|
||||
this.depositModifier = new IrisDepositModifier(this);
|
||||
this.ravineModifier = new IrisRavineModifier(this);
|
||||
this.caveModifier = new IrisCaveModifier(this);
|
||||
this.postModifier = new IrisPostModifier(this);
|
||||
cleaning = new AtomicBoolean(false);
|
||||
cleanLatch = new ChronoLatch(Math.max(10000, Math.min(IrisSettings.get().getParallax()
|
||||
.getParallaxChunkEvictionMS(), IrisSettings.get().getParallax().getParallaxRegionEvictionMS())));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,9 +185,16 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
J.car(art);
|
||||
closed = true;
|
||||
getWorldManager().close();
|
||||
getFramework().close();
|
||||
getTarget().close();
|
||||
saveEngineData();
|
||||
getEngineParallax().close();
|
||||
getTerrainActuator().close();
|
||||
getDecorantActuator().close();
|
||||
getBiomeActuator().close();
|
||||
getDepositModifier().close();
|
||||
getRavineModifier().close();
|
||||
getCaveModifier().close();
|
||||
getPostModifier().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,7 +204,35 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
getFramework().recycle();
|
||||
if (!cleanLatch.flip()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get()) {
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try {
|
||||
getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cleaning.lazySet(false);
|
||||
}
|
||||
|
||||
|
||||
public EngineActuator<BlockData> getTerrainActuator() {
|
||||
return switch (getDimension().getTerrainMode()) {
|
||||
case NORMAL -> getTerrainNormalActuator();
|
||||
case ISLANDS -> getTerrainIslandActuator();
|
||||
};
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -218,18 +258,18 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
|
||||
switch (getDimension().getTerrainMode()) {
|
||||
case NORMAL -> {
|
||||
getFramework().getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
|
||||
getFramework().getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
getFramework().getBiomeActuator().actuate(x, z, vbiomes, multicore);
|
||||
getFramework().getCaveModifier().modify(x, z, vblocks, multicore);
|
||||
getFramework().getRavineModifier().modify(x, z, vblocks, multicore);
|
||||
getFramework().getPostModifier().modify(x, z, vblocks, multicore);
|
||||
getFramework().getDecorantActuator().actuate(x, z, blocks, multicore);
|
||||
getFramework().getEngineParallax().insertParallax(x >> 4, z >> 4, blocks);
|
||||
getFramework().getDepositModifier().modify(x, z, blocks, multicore);
|
||||
getEngineParallax().generateParallaxArea(x >> 4, z >> 4);
|
||||
getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
getBiomeActuator().actuate(x, z, vbiomes, multicore);
|
||||
getCaveModifier().modify(x, z, vblocks, multicore);
|
||||
getRavineModifier().modify(x, z, vblocks, multicore);
|
||||
getPostModifier().modify(x, z, vblocks, multicore);
|
||||
getDecorantActuator().actuate(x, z, blocks, multicore);
|
||||
getEngineParallax().insertParallax(x >> 4, z >> 4, blocks);
|
||||
getDepositModifier().modify(x, z, blocks, multicore);
|
||||
}
|
||||
case ISLANDS -> {
|
||||
getFramework().getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,138 +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.engine;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.engine.actuator.IrisBiomeActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisTerrainIslandActuator;
|
||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
||||
import com.volmit.iris.engine.framework.*;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisDepositModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisPostModifier;
|
||||
import com.volmit.iris.engine.modifier.IrisRavineModifier;
|
||||
import com.volmit.iris.util.io.ReactiveFolder;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class IrisEngineFramework implements EngineFramework {
|
||||
|
||||
@Getter
|
||||
private final Engine engine;
|
||||
|
||||
@Getter
|
||||
private final IrisComplex complex;
|
||||
|
||||
@Getter
|
||||
final EngineParallaxManager engineParallax;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<BlockData> terrainNormalActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<BlockData> terrainIslandActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<BlockData> decorantActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineActuator<Biome> biomeActuator;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> depositModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> caveModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> ravineModifier;
|
||||
|
||||
@Getter
|
||||
private final EngineModifier<BlockData> postModifier;
|
||||
|
||||
private final AtomicBoolean cleaning;
|
||||
private final ChronoLatch cleanLatch;
|
||||
|
||||
public IrisEngineFramework(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.complex = new IrisComplex(getEngine());
|
||||
this.engineParallax = new IrisEngineParallax(getEngine());
|
||||
this.terrainNormalActuator = new IrisTerrainNormalActuator(getEngine());
|
||||
this.terrainIslandActuator = new IrisTerrainIslandActuator(getEngine());
|
||||
this.decorantActuator = new IrisDecorantActuator(getEngine());
|
||||
this.biomeActuator = new IrisBiomeActuator(getEngine());
|
||||
this.depositModifier = new IrisDepositModifier(getEngine());
|
||||
this.ravineModifier = new IrisRavineModifier(getEngine());
|
||||
this.caveModifier = new IrisCaveModifier(engine);
|
||||
this.postModifier = new IrisPostModifier(engine);
|
||||
cleaning = new AtomicBoolean(false);
|
||||
cleanLatch = new ChronoLatch(Math.max(10000, Math.min(IrisSettings.get().getParallax().getParallaxChunkEvictionMS(), IrisSettings.get().getParallax().getParallaxRegionEvictionMS())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void recycle() {
|
||||
if (!cleanLatch.flip()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get()) {
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
|
||||
cleaning.set(true);
|
||||
|
||||
try {
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Cleanup failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
cleaning.lazySet(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EngineActuator<BlockData> getTerrainActuator() {
|
||||
return switch (getEngine().getDimension().getTerrainMode()) {
|
||||
case NORMAL -> getTerrainNormalActuator();
|
||||
case ISLANDS -> getTerrainIslandActuator();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
getEngineParallax().close();
|
||||
getTerrainActuator().close();
|
||||
getDecorantActuator().close();
|
||||
getBiomeActuator().close();
|
||||
getDepositModifier().close();
|
||||
getRavineModifier().close();
|
||||
getCaveModifier().close();
|
||||
getPostModifier().close();
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,7 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
private final Engine engine;
|
||||
private final Mantle mantle;
|
||||
|
||||
public IrisEngineMantle(Engine engine)
|
||||
{
|
||||
public IrisEngineMantle(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.mantle = new Mantle(new File(engine.getWorld().worldFolder(), "mantle/" + engine.getIndex()), engine.getTarget().getHeight());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.engine.scripting.IrisScriptingAPI;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import lombok.Data;
|
||||
import org.apache.bsf.BSFEngine;
|
||||
import org.apache.bsf.BSFException;
|
||||
import org.apache.bsf.BSFManager;
|
||||
import org.apache.bsf.engines.javascript.JavaScriptEngine;
|
||||
@@ -36,8 +35,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
private final IrisScriptingAPI api;
|
||||
private JavaScriptEngine javaScriptEngine;
|
||||
|
||||
public IrisExecutionEnvironment(Engine engine)
|
||||
{
|
||||
public IrisExecutionEnvironment(Engine engine) {
|
||||
this.engine = engine;
|
||||
this.api = new IrisScriptingAPI(engine);
|
||||
this.manager = new BSFManager();
|
||||
@@ -55,8 +53,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
return api;
|
||||
}
|
||||
|
||||
public void execute(String script)
|
||||
{
|
||||
public void execute(String script) {
|
||||
Iris.debug("Execute Script (void) " + C.DARK_GREEN + script);
|
||||
try {
|
||||
javaScriptEngine.exec("", 0, 0, getEngine().getData().getScriptLoader().load(script));
|
||||
@@ -65,8 +62,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
}
|
||||
}
|
||||
|
||||
public Object evaluate(String script)
|
||||
{
|
||||
public Object evaluate(String script) {
|
||||
Iris.debug("Execute Script (for result) " + C.DARK_GREEN + script);
|
||||
try {
|
||||
return javaScriptEngine.eval("", 0, 0, getEngine().getData().getScriptLoader().load(script));
|
||||
|
||||
@@ -87,13 +87,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
looper = new Looper() {
|
||||
@Override
|
||||
protected long loop() {
|
||||
if(getEngine().isClosed())
|
||||
{
|
||||
if (getEngine().isClosed()) {
|
||||
interrupt();
|
||||
}
|
||||
|
||||
if(getDimension().isInfiniteEnergy())
|
||||
{
|
||||
if (getDimension().isInfiniteEnergy()) {
|
||||
energy += 1000;
|
||||
fixEnergy();
|
||||
}
|
||||
@@ -138,8 +136,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private boolean onAsyncTick() {
|
||||
if(getEngine().isClosed())
|
||||
{
|
||||
if (getEngine().isClosed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -164,13 +161,9 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
if (cl.flip()) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
J.s(() -> precount = getEngine().getWorld().realWorld().getEntities());
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
@@ -213,7 +206,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn),
|
||||
getData().getSpawnerLoader().streamAll(getEngine().getFramework().getEngineParallax()
|
||||
getData().getSpawnerLoader().streamAll(getEngine().getEngineParallax()
|
||||
.getFeaturesInChunk(c).stream()
|
||||
.flatMap((o) -> o.getFeature().getEntitySpawners().stream()))
|
||||
.filter(this::canSpawn))
|
||||
@@ -241,13 +234,9 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
spawn(c, v);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
J.s(() -> spawn(c, v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.gui.components.RenderType;
|
||||
import com.volmit.iris.core.gui.components.Renderer;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.object.basic.IrisColor;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
@@ -62,6 +63,26 @@ import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootProvider, BlockUpdater, Renderer, Hotloadable {
|
||||
IrisComplex getComplex();
|
||||
|
||||
void recycle();
|
||||
|
||||
EngineParallaxManager getEngineParallax();
|
||||
|
||||
EngineActuator<BlockData> getTerrainActuator();
|
||||
|
||||
EngineActuator<BlockData> getDecorantActuator();
|
||||
|
||||
EngineActuator<Biome> getBiomeActuator();
|
||||
|
||||
EngineModifier<BlockData> getCaveModifier();
|
||||
|
||||
EngineModifier<BlockData> getRavineModifier();
|
||||
|
||||
EngineModifier<BlockData> getDepositModifier();
|
||||
|
||||
EngineModifier<BlockData> getPostModifier();
|
||||
|
||||
void close();
|
||||
|
||||
IrisContext getContext();
|
||||
@@ -81,19 +102,15 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
void setParallelism(int parallelism);
|
||||
|
||||
default UUID getBiomeID(int x, int z) {
|
||||
return getFramework().getComplex().getBaseBiomeIDStream().get(x, z);
|
||||
return getComplex().getBaseBiomeIDStream().get(x, z);
|
||||
}
|
||||
|
||||
int getParallelism();
|
||||
|
||||
EngineTarget getTarget();
|
||||
|
||||
EngineFramework getFramework();
|
||||
|
||||
void setMinHeight(int min);
|
||||
|
||||
void recycle();
|
||||
|
||||
int getIndex();
|
||||
|
||||
int getMinHeight();
|
||||
@@ -152,7 +169,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
IrisBiome biome = getSurfaceBiome((int) x, (int) z);
|
||||
int height = getHeight((int) x, (int) z);
|
||||
double heightFactor = M.lerpInverse(0, getHeight(), height);
|
||||
Color irc = region.getColor(this.getFramework().getComplex(), RenderType.BIOME);
|
||||
Color irc = region.getColor(this.getComplex(), RenderType.BIOME);
|
||||
Color ibc = biome.getColor(this, RenderType.BIOME);
|
||||
Color rc = irc != null ? irc : Color.GREEN.darker();
|
||||
Color bc = ibc != null ? ibc : biome.isAquatic() ? Color.BLUE : Color.YELLOW;
|
||||
@@ -164,7 +181,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
default IrisRegion getRegion(int x, int z) {
|
||||
return getFramework().getComplex().getRegionStream().get(x, z);
|
||||
return getComplex().getRegionStream().get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,13 +192,13 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
default IrisBiome getCaveBiome(int x, int z) {
|
||||
return getFramework().getComplex().getCaveBiomeStream().get(x, z);
|
||||
return getComplex().getCaveBiomeStream().get(x, z);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
default IrisBiome getSurfaceBiome(int x, int z) {
|
||||
return getFramework().getComplex().getTrueBiomeStream().get(x, z);
|
||||
return getComplex().getTrueBiomeStream().get(x, z);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -192,7 +209,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
|
||||
@BlockCoordinates
|
||||
default int getHeight(int x, int z, boolean ignoreFluid) {
|
||||
return getFramework().getEngineParallax().getHighest(x, z, getData(), ignoreFluid);
|
||||
return getEngineParallax().getHighest(x, z, getData(), ignoreFluid);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -326,7 +343,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
list.clear();
|
||||
}
|
||||
|
||||
list.addAll(r.getLootTables(getFramework().getComplex()));
|
||||
list.addAll(r.getLootTables(getComplex()));
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -334,8 +351,8 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
default KList<IrisLootTable> getLootTables(RNG rng, Block b) {
|
||||
int rx = b.getX();
|
||||
int rz = b.getZ();
|
||||
double he = getFramework().getComplex().getHeightStream().get(rx, rz);
|
||||
PlacedObject po = getFramework().getEngine().getObjectPlacement(rx, b.getY(), rz);
|
||||
double he = getComplex().getHeightStream().get(rx, rz);
|
||||
PlacedObject po = getObjectPlacement(rx, b.getY(), rz);
|
||||
if (po != null && po.getPlacement() != null) {
|
||||
|
||||
if (B.isStorageChest(b.getBlockData())) {
|
||||
@@ -345,9 +362,9 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
||||
}
|
||||
}
|
||||
}
|
||||
IrisRegion region = getFramework().getComplex().getRegionStream().get(rx, rz);
|
||||
IrisBiome biomeSurface = getFramework().getComplex().getTrueBiomeStream().get(rx, rz);
|
||||
IrisBiome biomeUnder = b.getY() < he ? getFramework().getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface;
|
||||
IrisRegion region = getComplex().getRegionStream().get(rx, rz);
|
||||
IrisBiome biomeSurface = getComplex().getTrueBiomeStream().get(rx, rz);
|
||||
IrisBiome biomeUnder = b.getY() < he ? getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface;
|
||||
KList<IrisLootTable> tables = new KList<>();
|
||||
double multiplier = 1D * getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier();
|
||||
injectTables(tables, getDimension().getLoot());
|
||||
|
||||
@@ -72,15 +72,11 @@ public interface EngineComponent {
|
||||
return getTarget().getWorld().seed();
|
||||
}
|
||||
|
||||
default EngineFramework getFramework() {
|
||||
return getEngine().getFramework();
|
||||
}
|
||||
|
||||
default int getParallelism() {
|
||||
return getEngine().getParallelism();
|
||||
}
|
||||
|
||||
default IrisComplex getComplex() {
|
||||
return getFramework().getComplex();
|
||||
return getEngine().getComplex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider {
|
||||
Engine e = getEngine(i);
|
||||
|
||||
if (e.getDimension().isBedrock()) {
|
||||
int m = ((IrisTerrainNormalActuator) e.getFramework().getTerrainActuator()).getLastBedrock();
|
||||
int m = ((IrisTerrainNormalActuator) e.getTerrainActuator()).getLastBedrock();
|
||||
|
||||
if (f > m) {
|
||||
f = m;
|
||||
|
||||
@@ -1,58 +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.engine.framework;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface EngineFramework extends DataProvider {
|
||||
Engine getEngine();
|
||||
|
||||
IrisComplex getComplex();
|
||||
|
||||
EngineParallaxManager getEngineParallax();
|
||||
|
||||
default IrisData getData() {
|
||||
return getComplex().getData();
|
||||
}
|
||||
|
||||
default void recycle() {
|
||||
getEngine().getParallax().cleanup();
|
||||
getData().getObjectLoader().clean();
|
||||
}
|
||||
|
||||
EngineActuator<BlockData> getTerrainActuator();
|
||||
|
||||
EngineActuator<BlockData> getDecorantActuator();
|
||||
|
||||
EngineActuator<Biome> getBiomeActuator();
|
||||
|
||||
EngineModifier<BlockData> getCaveModifier();
|
||||
|
||||
EngineModifier<BlockData> getRavineModifier();
|
||||
|
||||
EngineModifier<BlockData> getDepositModifier();
|
||||
|
||||
EngineModifier<BlockData> getPostModifier();
|
||||
|
||||
void close();
|
||||
}
|
||||
@@ -74,10 +74,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
|
||||
int getParallaxSize();
|
||||
|
||||
default EngineFramework getFramework() {
|
||||
return getEngine().getFramework();
|
||||
}
|
||||
|
||||
default ParallaxAccess getParallaxAccess() {
|
||||
return getEngine().getParallax();
|
||||
}
|
||||
@@ -87,7 +83,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
|
||||
default IrisComplex getComplex() {
|
||||
return getEngine().getFramework().getComplex();
|
||||
return getEngine().getComplex();
|
||||
}
|
||||
|
||||
default KList<IrisRegion> getAllRegions() {
|
||||
@@ -214,13 +210,13 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
|
||||
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
|
||||
if (i.shouldFilter((x << 4) + 8, (z << 4) + 8, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
if (i.shouldFilter((x << 4) + 8, (z << 4) + 8, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisFeaturePositional i : getParallaxAccess().getMetaR(x, z).getFeatures()) {
|
||||
if (i.shouldFilter((x << 4) + 8, (z << 4) + 8, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
if (i.shouldFilter((x << 4) + 8, (z << 4) + 8, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
@@ -242,7 +238,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
}
|
||||
|
||||
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
|
||||
if (i.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
if (i.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
@@ -259,7 +255,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
||||
|
||||
try {
|
||||
for (IrisFeaturePositional k : m.getFeatures()) {
|
||||
if (k.shouldFilter(x, z, getEngine().getFramework().getComplex().getRng(), getData())) {
|
||||
if (k.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.common.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
@@ -33,8 +32,7 @@ import com.volmit.iris.util.mantle.Mantle;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface EngineMantle extends IObjectPlacer
|
||||
{
|
||||
public interface EngineMantle extends IObjectPlacer {
|
||||
BlockData AIR = B.get("AIR");
|
||||
|
||||
Mantle getMantle();
|
||||
@@ -65,7 +63,7 @@ public interface EngineMantle extends IObjectPlacer
|
||||
|
||||
@Override
|
||||
default void set(int x, int y, int z, BlockData d) {
|
||||
getMantle().set(x,y,z,d == null ? AIR : d);
|
||||
getMantle().set(x, y, z, d == null ? AIR : d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,7 +74,7 @@ public interface EngineMantle extends IObjectPlacer
|
||||
|
||||
@Override
|
||||
default BlockData get(int x, int y, int z) {
|
||||
BlockData block = getMantle().get(x,y,z,BlockData.class);
|
||||
BlockData block = getMantle().get(x, y, z, BlockData.class);
|
||||
|
||||
if (block == null) {
|
||||
return AIR;
|
||||
@@ -110,8 +108,7 @@ public interface EngineMantle extends IObjectPlacer
|
||||
return getEngine().getDimension().isDebugSmartBore();
|
||||
}
|
||||
|
||||
default void trim(long dur)
|
||||
{
|
||||
default void trim(long dur) {
|
||||
getMantle().trim(dur);
|
||||
}
|
||||
|
||||
@@ -131,16 +128,11 @@ public interface EngineMantle extends IObjectPlacer
|
||||
return getEngine().getDimension();
|
||||
}
|
||||
|
||||
default EngineFramework getFramework() {
|
||||
return getEngine().getFramework();
|
||||
}
|
||||
|
||||
default IrisComplex getComplex() {
|
||||
return getFramework().getComplex();
|
||||
return getEngine().getComplex();
|
||||
}
|
||||
|
||||
default void close()
|
||||
{
|
||||
default void close() {
|
||||
getMantle().close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@
|
||||
package com.volmit.iris.engine.mantle;
|
||||
|
||||
public interface MantleSized {
|
||||
public int getMaxChunkSize();
|
||||
int getMaxChunkSize();
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
|
||||
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z) {
|
||||
int h = getFramework().getEngineParallax().trueHeight(x, z);
|
||||
int ha = getFramework().getEngineParallax().trueHeight(x + 1, z);
|
||||
int hb = getFramework().getEngineParallax().trueHeight(x, z + 1);
|
||||
int hc = getFramework().getEngineParallax().trueHeight(x - 1, z);
|
||||
int hd = getFramework().getEngineParallax().trueHeight(x, z - 1);
|
||||
int h = getEngine().getEngineParallax().trueHeight(x, z);
|
||||
int ha = getEngine().getEngineParallax().trueHeight(x + 1, z);
|
||||
int hb = getEngine().getEngineParallax().trueHeight(x, z + 1);
|
||||
int hc = getEngine().getEngineParallax().trueHeight(x - 1, z);
|
||||
int hd = getEngine().getEngineParallax().trueHeight(x, z - 1);
|
||||
|
||||
// Floating Nibs
|
||||
int g = 0;
|
||||
@@ -234,7 +234,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
IrisBiome cave = getComplex().getCaveBiomeStream().get(x, z);
|
||||
|
||||
if (cave != null) {
|
||||
for (CaveResult i : ((IrisCaveModifier) getFramework().getCaveModifier()).genCaves(x, z, 0, 0, null)) {
|
||||
for (CaveResult i : ((IrisCaveModifier) getEngine().getCaveModifier()).genCaves(x, z, 0, 0, null)) {
|
||||
if (i.getCeiling() >= currentData.getMax2DParallelism() || i.getFloor() < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,20 +21,17 @@ package com.volmit.iris.engine.object.common;
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class IrisScript extends IrisRegistrant {
|
||||
private final String source;
|
||||
|
||||
public IrisScript()
|
||||
{
|
||||
public IrisScript() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public IrisScript(String source)
|
||||
{
|
||||
public IrisScript(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@@ -48,8 +45,7 @@ public class IrisScript extends IrisRegistrant {
|
||||
return "Script";
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,26 +169,19 @@ public class IrisEntity extends IrisRegistrant {
|
||||
public Entity spawn(Engine gen, Location at, RNG rng) {
|
||||
Entity ee = doSpawn(at);
|
||||
|
||||
if(!spawnerScript.isEmpty() && ee == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (!spawnerScript.isEmpty() && ee == null) {
|
||||
synchronized (this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
try
|
||||
{
|
||||
try {
|
||||
ee = (Entity) gen.getExecution().evaluate(spawnerScript);
|
||||
}
|
||||
|
||||
catch(Throwable ex)
|
||||
{
|
||||
} catch (Throwable ex) {
|
||||
Iris.error("You must return an Entity in your scripts to use entity scripts!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ee == null)
|
||||
{
|
||||
if (ee == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -313,15 +306,12 @@ public class IrisEntity extends IrisRegistrant {
|
||||
spawnEffect.apply(e);
|
||||
}
|
||||
|
||||
if(postSpawnScripts.isNotEmpty())
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (postSpawnScripts.isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
gen.getExecution().getAPI().setEntity(ee);
|
||||
|
||||
for(String i : postSpawnScripts)
|
||||
{
|
||||
for (String i : postSpawnScripts) {
|
||||
gen.getExecution().execute(i);
|
||||
}
|
||||
}
|
||||
@@ -331,8 +321,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}
|
||||
|
||||
private Entity doSpawn(Location at) {
|
||||
if(type.equals(EntityType.UNKNOWN))
|
||||
{
|
||||
if (type.equals(EntityType.UNKNOWN)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
@@ -86,12 +85,11 @@ public class IrisEntitySpawn implements IRare {
|
||||
Location l = switch (getReferenceSpawner().getGroup()) {
|
||||
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
|
||||
case CAVE -> {
|
||||
IrisComplex comp = gen.getFramework().getComplex();
|
||||
EngineFramework frame = gen.getFramework();
|
||||
IrisComplex comp = gen.getComplex();
|
||||
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
|
||||
KList<Location> r = new KList<>();
|
||||
if (cave != null) {
|
||||
for (CaveResult i : ((IrisCaveModifier) frame.getCaveModifier()).genCaves(x, z)) {
|
||||
for (CaveResult i : ((IrisCaveModifier) gen.getCaveModifier()).genCaves(x, z)) {
|
||||
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling() - 2 <= i.getFloor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.noise;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
@@ -56,13 +56,13 @@ public enum IrisEngineStreamType {
|
||||
@Desc("Represents the identity of regions. Each region has a unique number (very large numbers)")
|
||||
REGION_IDENTITY((f) -> f.getComplex().getRegionIdentityStream());
|
||||
|
||||
private final Function<EngineFramework, ProceduralStream<Double>> getter;
|
||||
private final Function<Engine, ProceduralStream<Double>> getter;
|
||||
|
||||
IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter) {
|
||||
IrisEngineStreamType(Function<Engine, ProceduralStream<Double>> getter) {
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> get(EngineFramework engine) {
|
||||
public ProceduralStream<Double> get(Engine engine) {
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object.noise;
|
||||
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
|
||||
import java.util.function.Function;
|
||||
@@ -26,28 +26,28 @@ import java.util.function.Function;
|
||||
@Desc("Represents a value from the engine")
|
||||
public enum IrisEngineValueType {
|
||||
@Desc("Represents actual height of the engine")
|
||||
ENGINE_HEIGHT((f) -> Double.valueOf(f.getEngine().getHeight())),
|
||||
ENGINE_HEIGHT((f) -> Double.valueOf(f.getHeight())),
|
||||
|
||||
@Desc("Represents virtual bottom of the engine in the compound. If this engine is on top of another engine, it's min height would be at the maxHeight of the previous engine + 1")
|
||||
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getEngine().getMinHeight())),
|
||||
ENGINE_MIN_HEIGHT((f) -> Double.valueOf(f.getMinHeight())),
|
||||
|
||||
@Desc("Represents virtual top of the engine in the compound. If this engine is below another engine, it's max height would be at the minHeight of the next engine - 1")
|
||||
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getEngine().getMaxHeight())),
|
||||
ENGINE_MAX_HEIGHT((f) -> Double.valueOf(f.getMaxHeight())),
|
||||
|
||||
@Desc("Represents the position of the engine in the dimensional compound. The bottom (first) dimension stasts at 0. Each new dimension added stacks on top with n+1 for the id.")
|
||||
ENGINE_INDEX((f) -> Double.valueOf(f.getEngine().getIndex())),
|
||||
ENGINE_INDEX((f) -> Double.valueOf(f.getIndex())),
|
||||
|
||||
@Desc("The fluid height defined in the dimension file")
|
||||
FLUID_HEIGHT((f) -> Double.valueOf(f.getComplex().getFluidHeight())),
|
||||
;
|
||||
|
||||
private final Function<EngineFramework, Double> getter;
|
||||
private final Function<Engine, Double> getter;
|
||||
|
||||
IrisEngineValueType(Function<EngineFramework, Double> getter) {
|
||||
IrisEngineValueType(Function<Engine, Double> getter) {
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
public Double get(EngineFramework engine) {
|
||||
public Double get(Engine engine) {
|
||||
return getter.apply(engine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ public class IrisExpressionLoad {
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double z) {
|
||||
if (engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
@@ -75,11 +75,11 @@ public class IrisExpressionLoad {
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
|
||||
@@ -21,8 +21,7 @@ package com.volmit.iris.engine.scripting;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import org.apache.bsf.BSFManager;
|
||||
|
||||
public interface EngineExecutionEnvironment
|
||||
{
|
||||
public interface EngineExecutionEnvironment {
|
||||
Engine getEngine();
|
||||
|
||||
IrisScriptingAPI getAPI();
|
||||
@@ -33,8 +32,7 @@ public interface EngineExecutionEnvironment
|
||||
|
||||
Object evaluate(String script);
|
||||
|
||||
default void close()
|
||||
{
|
||||
default void close() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.core.project.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineFramework;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
import com.volmit.iris.engine.object.noise.IrisExpression;
|
||||
@@ -41,70 +40,53 @@ public class IrisScriptingAPI {
|
||||
private Location location;
|
||||
private Entity entity;
|
||||
|
||||
public IrisScriptingAPI(Engine engine)
|
||||
{
|
||||
public IrisScriptingAPI(Engine engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public IrisData getData()
|
||||
{
|
||||
public IrisData getData() {
|
||||
return getEngine().getData();
|
||||
}
|
||||
|
||||
public EngineFramework getFramework()
|
||||
{
|
||||
return getEngine().getFramework();
|
||||
public IrisComplex getComplex() {
|
||||
return getEngine().getComplex();
|
||||
}
|
||||
|
||||
public IrisComplex getComplex()
|
||||
{
|
||||
return getFramework().getComplex();
|
||||
}
|
||||
|
||||
public long getSeed()
|
||||
{
|
||||
public long getSeed() {
|
||||
return getEngine().getTarget().getWorld().seed();
|
||||
}
|
||||
|
||||
public double expression(String expressionName, double x, double y, double z)
|
||||
{
|
||||
public double expression(String expressionName, double x, double y, double z) {
|
||||
IrisExpression expression = getData().getExpressionLoader().load(expressionName);
|
||||
return expression.evaluate(getComplex().getRng(), x, y, z);
|
||||
}
|
||||
|
||||
public double expression(String expressionName, double x, double z)
|
||||
{
|
||||
public double expression(String expressionName, double x, double z) {
|
||||
IrisExpression expression = getData().getExpressionLoader().load(expressionName);
|
||||
return expression.evaluate(getComplex().getRng(), x, z);
|
||||
}
|
||||
|
||||
public IrisBiome getBiomeAt(int x, int z)
|
||||
{
|
||||
public IrisBiome getBiomeAt(int x, int z) {
|
||||
return getEngine().getSurfaceBiome(x, z);
|
||||
}
|
||||
|
||||
public IrisDimension getDimension()
|
||||
{
|
||||
public IrisDimension getDimension() {
|
||||
return getEngine().getDimension();
|
||||
}
|
||||
|
||||
public void info(String log)
|
||||
{
|
||||
public void info(String log) {
|
||||
Iris.info(log);
|
||||
}
|
||||
|
||||
public void debug(String log)
|
||||
{
|
||||
public void debug(String log) {
|
||||
Iris.debug(log);
|
||||
}
|
||||
|
||||
public void warn(String log)
|
||||
{
|
||||
public void warn(String log) {
|
||||
Iris.warn(log);
|
||||
}
|
||||
|
||||
public void error(String log)
|
||||
{
|
||||
public void error(String log) {
|
||||
Iris.error(log);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user