mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 11:09:06 +00:00
The engine is the framework
This commit is contained in:
@@ -30,7 +30,6 @@ import com.volmit.iris.core.link.OraxenLink;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
|
||||
|
||||
@@ -148,12 +148,12 @@ public class IrisBoardManager implements BoardProvider, Listener {
|
||||
if (engine != null) {
|
||||
v.add("&7&m------------------");
|
||||
KList<IrisFeaturePositional> f = new KList<>();
|
||||
f.add(engine.getFramework().getEngineParallax().forEachFeature(x, z));
|
||||
f.add(engine.getEngineParallax().forEachFeature(x, z));
|
||||
v.add(C.AQUA + "Engine" + C.GRAY + ": " + engine.getName() + " " + engine.getMinHeight() + "-" + engine.getMaxHeight());
|
||||
v.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName());
|
||||
v.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiome(x, y, z).getName());
|
||||
v.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z)));
|
||||
v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getFramework().getComplex().getSlopeStream().get(x, z), 2));
|
||||
v.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2));
|
||||
v.add(C.AQUA + "Features" + C.GRAY + ": " + Form.f(f.size()));
|
||||
v.add(C.AQUA + "Energy" + C.GRAY + ": " + Form.f(engine.getWorldManager().getEnergy(), 0));
|
||||
v.add(C.AQUA + "Sat" + C.GRAY + ": " + Form.f(engine.getWorldManager().getEntityCount()) + "e / " + Form.f(engine.getWorldManager().getChunkCount()) + "c (" + Form.pc(engine.getWorldManager().getEntitySaturation(), 0) + ")");
|
||||
|
||||
@@ -24,7 +24,10 @@ import com.volmit.iris.core.command.object.CommandIrisObject;
|
||||
import com.volmit.iris.core.command.pregen.CommandIrisPregen;
|
||||
import com.volmit.iris.core.command.studio.CommandIrisStudio;
|
||||
import com.volmit.iris.core.command.what.CommandIrisWhat;
|
||||
import com.volmit.iris.core.command.world.*;
|
||||
import com.volmit.iris.core.command.world.CommandIrisCreate;
|
||||
import com.volmit.iris.core.command.world.CommandIrisFix;
|
||||
import com.volmit.iris.core.command.world.CommandIrisUpdateWorld;
|
||||
import com.volmit.iris.core.command.world.CommandIrisVerify;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.Command;
|
||||
import com.volmit.iris.util.plugin.MortarCommand;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class CommandIrisPregenPause extends MortarCommand {
|
||||
|
||||
@Override
|
||||
public boolean handle(VolmitSender sender, String[] args) {
|
||||
if (PregeneratorJob.pauseResume()){
|
||||
if (PregeneratorJob.pauseResume()) {
|
||||
sender.sendMessage("Paused/unpaused pregeneration task, now: " + (PregeneratorJob.isPaused() ? "Paused" : "Running") + ".");
|
||||
} else {
|
||||
sender.sendMessage("No active pregeneration tasks to pause/unpause.");
|
||||
|
||||
@@ -11,8 +11,6 @@ import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class CommandIrisPregenStart extends MortarCommand {
|
||||
|
||||
@@ -26,12 +24,12 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
Create a new pregeneration task.
|
||||
Command usage:
|
||||
/iris pregen create [radius=<radius>] [x=<centerX>] [z=<centerZ>] [world=<world>] [-here]
|
||||
|
||||
|
||||
Examples:
|
||||
/iris pregen start 5k -here
|
||||
/iris pregen start radius=5000 x=10r z=10r world=IrisWorld
|
||||
/iris pregen start 10k world=WorldName
|
||||
|
||||
|
||||
<radius>: Sets both width and height to a value. (Size is: 2 * radius by 2 * radius)
|
||||
<x> & <z>: Give the center point of the pregen.
|
||||
<world>: Specify a different world name for generation than the one you're currently in.
|
||||
@@ -39,7 +37,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
If you specify this, the `-here` is ignored.
|
||||
-here: If added, the center location is set to your position (player only)
|
||||
This overrides <x> and <z>.
|
||||
|
||||
|
||||
For all numeric values (radius, centerX, etc.) you may use:
|
||||
c => 16, r => 512, k => 1000
|
||||
Example: entering '1000' is the same as '1k' (1 * 1000)
|
||||
@@ -53,7 +51,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
argus.forEach(p -> {
|
||||
boolean hasArg = false;
|
||||
for (String arg : args) {
|
||||
if (!arg.contains("=") || !p.contains("=")){
|
||||
if (!arg.contains("=") || !p.contains("=")) {
|
||||
continue;
|
||||
}
|
||||
if (arg.split("=")[0].equals(p.split("=")[0])) {
|
||||
@@ -61,7 +59,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasArg){
|
||||
if (!hasArg) {
|
||||
list.add(p);
|
||||
}
|
||||
});
|
||||
@@ -74,12 +72,12 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasHere){
|
||||
if (!hasHere) {
|
||||
list.add("-here");
|
||||
}
|
||||
|
||||
// Add Iris worlds
|
||||
if (Bukkit.getWorlds().isEmpty()){
|
||||
if (Bukkit.getWorlds().isEmpty()) {
|
||||
list.add("world=<name>");
|
||||
} else {
|
||||
Bukkit.getWorlds().forEach(w -> {
|
||||
@@ -114,21 +112,21 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
// Check all arguments
|
||||
KList<String> failed = new KList<>();
|
||||
for (String a : args) {
|
||||
if (a.equals("-here")){
|
||||
if (a.equals("-here")) {
|
||||
here = true;
|
||||
} else if (a.contains("=")) {
|
||||
String pre = a.split("=")[0];
|
||||
String val = a.split("=")[1];
|
||||
if (pre.equals("world")){
|
||||
if (pre.equals("world")) {
|
||||
world = Bukkit.getWorld(val);
|
||||
if (world == null){
|
||||
if (world == null) {
|
||||
failed.add(a + " (invalid world)");
|
||||
sender.sendMessage("Entered world is " + val + ", but that world does not exist.");
|
||||
sender.sendMessage("Cancelling the command.");
|
||||
sender.sendMessage(getDescription());
|
||||
return true;
|
||||
}
|
||||
} else if (!isVal(val)){
|
||||
} else if (!isVal(val)) {
|
||||
failed.add(a + " (non-value)");
|
||||
} else {
|
||||
switch (pre) {
|
||||
@@ -152,15 +150,15 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
}
|
||||
|
||||
// Checking if a radius was specified or forgotten
|
||||
if (width == -1 || height == -1){
|
||||
if (width == -1 || height == -1) {
|
||||
sender.sendMessage("Radius not specified! Cancelling...");
|
||||
sender.sendMessage(getDescription());
|
||||
return true;
|
||||
}
|
||||
|
||||
// World specified & cancelling `-here` if it's another world
|
||||
if (world == null){
|
||||
if (sender.isPlayer()){
|
||||
if (world == null) {
|
||||
if (sender.isPlayer()) {
|
||||
world = sender.player().getWorld();
|
||||
} else {
|
||||
sender.sendMessage("Must specify world=<name> if sending from console! Cancelling...");
|
||||
@@ -168,8 +166,8 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (sender.isPlayer()){
|
||||
if (!world.equals(sender.player().getWorld())){
|
||||
if (sender.isPlayer()) {
|
||||
if (!world.equals(sender.player().getWorld())) {
|
||||
if (here) {
|
||||
sender.sendMessage("Ignoring `-here` because `world=` is specified!");
|
||||
here = false;
|
||||
@@ -179,7 +177,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
}
|
||||
|
||||
// Checking if -here is used
|
||||
if (here){
|
||||
if (here) {
|
||||
if (sender.isPlayer()) {
|
||||
x = sender.player().getLocation().getBlockX();
|
||||
z = sender.player().getLocation().getBlockZ();
|
||||
@@ -207,14 +205,14 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
.append(z)
|
||||
.append("\n")
|
||||
|
||||
// Append failed args
|
||||
// Append failed args
|
||||
.append(failed.isEmpty() ? "(No failed arguments)\n" : "FAILED ARGS:\n");
|
||||
for (String s : failed) {
|
||||
details.append(s).append("\n");
|
||||
}
|
||||
|
||||
// Start pregen and append info to details
|
||||
if (pregenerate(world, width, height, x, z)){
|
||||
if (pregenerate(world, width, height, x, z)) {
|
||||
details.append("Successfully started pregen");
|
||||
} else {
|
||||
details.append("Failed to start pregen. Doublecheck your arguments!");
|
||||
@@ -228,14 +226,15 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
|
||||
/**
|
||||
* Pregenerate a
|
||||
* @param world world with a
|
||||
* @param width and
|
||||
*
|
||||
* @param world world with a
|
||||
* @param width and
|
||||
* @param height with center
|
||||
* @param x and
|
||||
* @param z coords
|
||||
* @param x and
|
||||
* @param z coords
|
||||
* @return true if successful
|
||||
*/
|
||||
private boolean pregenerate(World world, int width, int height, int x, int z){
|
||||
private boolean pregenerate(World world, int width, int height, int x, int z) {
|
||||
try {
|
||||
IrisToolbelt.pregenerate(PregenTask
|
||||
.builder()
|
||||
@@ -243,7 +242,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
.width(width >> 9 + 1)
|
||||
.height(height >> 9 + 1)
|
||||
.build(), world);
|
||||
} catch (Throwable e){
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@@ -254,6 +253,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
/**
|
||||
* Get the ingeger value from an argument that may contain `c` `chunks` `r` `regions` or `k`<br>
|
||||
* "5r" returns 5 * 512 = 2560
|
||||
*
|
||||
* @param arg the string argument to parse into a value
|
||||
* @return the integer value result
|
||||
*/
|
||||
@@ -276,6 +276,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
||||
|
||||
/**
|
||||
* Checks if the
|
||||
*
|
||||
* @param arg string value
|
||||
* @return is valid -> true
|
||||
*/
|
||||
|
||||
@@ -2,15 +2,9 @@ package com.volmit.iris.core.command.pregen;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import com.volmit.iris.util.plugin.MortarCommand;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class CommandIrisPregenStop extends MortarCommand {
|
||||
|
||||
@@ -23,7 +17,7 @@ public class CommandIrisPregenStop extends MortarCommand {
|
||||
|
||||
@Override
|
||||
public boolean handle(VolmitSender sender, String[] args) {
|
||||
if (PregeneratorJob.shutdownInstance()){
|
||||
if (PregeneratorJob.shutdownInstance()) {
|
||||
sender.sendMessage("Stopped pregeneration task");
|
||||
} else {
|
||||
sender.sendMessage("No active pregeneration tasks to stop");
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.core.tools.IrisWorlds;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.IrisAccess;
|
||||
import com.volmit.iris.engine.object.common.IrisScript;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.plugin.MortarCommand;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
@@ -61,9 +60,8 @@ public class CommandIrisStudioExecute extends MortarCommand {
|
||||
|
||||
IrisAccess a = IrisToolbelt.access(sender.player().getWorld());
|
||||
|
||||
if(a != null)
|
||||
{
|
||||
((Engine)a.getEngineAccess(0)).getExecution().execute(args[0]);
|
||||
if (a != null) {
|
||||
((Engine) a.getEngineAccess(0)).getExecution().execute(args[0]);
|
||||
Iris.info("Executed. See script output in console.");
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CommandIrisWhatFeatures extends MortarCommand {
|
||||
|
||||
if (IrisWorlds.isIrisWorld(c.getWorld())) {
|
||||
int m = 1;
|
||||
for (IrisFeaturePositional i : ((Engine) IrisWorlds.access(c.getWorld()).getEngineAccess(p.getLocation().getBlockY())).getFramework().getEngineParallax().getFeaturesInChunk(c)) {
|
||||
for (IrisFeaturePositional i : ((Engine) IrisWorlds.access(c.getWorld()).getEngineAccess(p.getLocation().getBlockY())).getEngineParallax().getFeaturesInChunk(c)) {
|
||||
sender.sendMessage("#" + m++ + " " + new JSONObject(new Gson().toJson(i)).toString(4));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -55,13 +55,13 @@ public class CommandIrisFix extends MortarCommand {
|
||||
int viewDistance = args.length > 0 ? Integer.parseInt(args[0]) : -1;
|
||||
if (viewDistance <= 1) {
|
||||
J.a(() -> {
|
||||
int fixed = a.getCompound().getDefaultEngine().getFramework().getEngineParallax().repairChunk(sender.player().getLocation().getChunk());
|
||||
int fixed = a.getCompound().getDefaultEngine().getEngineParallax().repairChunk(sender.player().getLocation().getChunk());
|
||||
sender.sendMessage("Fixed " + Form.f(fixed) + " blocks!");
|
||||
});
|
||||
} else {
|
||||
AtomicInteger v = new AtomicInteger();
|
||||
J.a(() -> {
|
||||
new Spiraler(viewDistance, viewDistance, (x, z) -> v.set(v.get() + a.getCompound().getDefaultEngine().getFramework().getEngineParallax().repairChunk(sender.player().getWorld().getChunkAt(x, z)))).drain();
|
||||
new Spiraler(viewDistance, viewDistance, (x, z) -> v.set(v.get() + a.getCompound().getDefaultEngine().getEngineParallax().repairChunk(sender.player().getWorld().getChunkAt(x, z)))).drain();
|
||||
sender.sendMessage("Fixed " + Form.f(v.get()) + " blocks in " + (viewDistance * viewDistance) + " chunks!");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,12 +191,12 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
|
||||
BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB();
|
||||
|
||||
switch (currentType) {
|
||||
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> engine.getFramework().getComplex().getTrueBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case BIOME_LAND -> colorFunction = (x, z) -> engine.getFramework().getComplex().getLandBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case BIOME_SEA -> colorFunction = (x, z) -> engine.getFramework().getComplex().getSeaBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case REGION -> colorFunction = (x, z) -> engine.getFramework().getComplex().getRegionStream().get(x, z).getColor(engine.getFramework().getComplex(), currentType).getRGB();
|
||||
case CAVE_LAND -> colorFunction = (x, z) -> engine.getFramework().getComplex().getCaveBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(engine.getFramework().getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
|
||||
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> engine.getComplex().getTrueBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case BIOME_LAND -> colorFunction = (x, z) -> engine.getComplex().getLandBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case BIOME_SEA -> colorFunction = (x, z) -> engine.getComplex().getSeaBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case REGION -> colorFunction = (x, z) -> engine.getComplex().getRegionStream().get(x, z).getColor(engine.getComplex(), currentType).getRGB();
|
||||
case CAVE_LAND -> colorFunction = (x, z) -> engine.getComplex().getCaveBiomeStream().get(x, z).getColor(engine, currentType).getRGB();
|
||||
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(engine.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
|
||||
}
|
||||
|
||||
return colorFunction.apply(wx, wz);
|
||||
@@ -629,8 +629,8 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
|
||||
}
|
||||
|
||||
private void renderHoverOverlay(Graphics2D g, boolean detailed) {
|
||||
IrisBiome biome = engine.getFramework().getComplex().getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz));
|
||||
IrisRegion region = engine.getFramework().getComplex().getRegionStream().get(getWorldX(hx), getWorldZ(hz));
|
||||
IrisBiome biome = engine.getComplex().getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz));
|
||||
IrisRegion region = engine.getComplex().getRegionStream().get(getWorldX(hx), getWorldZ(hz));
|
||||
KList<String> l = new KList<>();
|
||||
l.add("Biome: " + biome.getName());
|
||||
l.add("Region: " + region.getName() + "(" + region.getLoadKey() + ")");
|
||||
@@ -692,7 +692,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
|
||||
}
|
||||
|
||||
private void open() {
|
||||
IrisComplex complex = engine.getFramework().getComplex();
|
||||
IrisComplex complex = engine.getComplex();
|
||||
File r = null;
|
||||
switch (currentType) {
|
||||
case BIOME, LAYER_LOAD, DECORATOR_LOAD, OBJECT_LOAD, HEIGHT -> r = complex.getTrueBiomeStream().get(getWorldX(hx), getWorldZ(hz)).openInVSCode();
|
||||
@@ -710,7 +710,7 @@ public class VisionGUI extends JPanel implements MouseWheelListener, KeyListener
|
||||
if (player != null) {
|
||||
int xx = (int) getWorldX(hx);
|
||||
int zz = (int) getWorldZ(hz);
|
||||
double h = engine.getFramework().getComplex().getTrueHeightStream().get(xx, zz);
|
||||
double h = engine.getComplex().getTrueHeightStream().get(xx, zz);
|
||||
player.teleport(new Location(player.getWorld(), xx, h, zz));
|
||||
notify("Teleporting to " + xx + ", " + (int) h + ", " + zz);
|
||||
} else {
|
||||
|
||||
@@ -38,12 +38,12 @@ public class IrisRenderer {
|
||||
BiFunction<Double, Double, Integer> colorFunction = (d, dx) -> Color.black.getRGB();
|
||||
|
||||
switch (currentType) {
|
||||
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> renderer.getFramework().getComplex().getTrueBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case BIOME_LAND -> colorFunction = (x, z) -> renderer.getFramework().getComplex().getLandBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case BIOME_SEA -> colorFunction = (x, z) -> renderer.getFramework().getComplex().getSeaBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case REGION -> colorFunction = (x, z) -> renderer.getFramework().getComplex().getRegionStream().get(x, z).getColor(renderer.getFramework().getComplex(), currentType).getRGB();
|
||||
case CAVE_LAND -> colorFunction = (x, z) -> renderer.getFramework().getComplex().getCaveBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(renderer.getFramework().getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
|
||||
case BIOME, DECORATOR_LOAD, OBJECT_LOAD, LAYER_LOAD -> colorFunction = (x, z) -> renderer.getComplex().getTrueBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case BIOME_LAND -> colorFunction = (x, z) -> renderer.getComplex().getLandBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case BIOME_SEA -> colorFunction = (x, z) -> renderer.getComplex().getSeaBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case REGION -> colorFunction = (x, z) -> renderer.getComplex().getRegionStream().get(x, z).getColor(renderer.getComplex(), currentType).getRGB();
|
||||
case CAVE_LAND -> colorFunction = (x, z) -> renderer.getComplex().getCaveBiomeStream().get(x, z).getColor(renderer, currentType).getRGB();
|
||||
case HEIGHT -> colorFunction = (x, z) -> Color.getHSBColor(renderer.getComplex().getHeightStream().get(x, z).floatValue(), 100, 100).getRGB();
|
||||
}
|
||||
|
||||
double x, z;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class IrisPapiExpansion extends PlaceholderExpansion {
|
||||
} else if (p.equalsIgnoreCase("terrain_slope")) {
|
||||
if (a != null) {
|
||||
return ((Engine) a.getEngineAccess(l.getBlockY()))
|
||||
.getFramework().getComplex().getSlopeStream()
|
||||
.getComplex().getSlopeStream()
|
||||
.get(l.getX(), l.getZ()) + "";
|
||||
}
|
||||
} else if (p.equalsIgnoreCase("terrain_height")) {
|
||||
|
||||
@@ -92,8 +92,7 @@ public class SchemaBuilder {
|
||||
o.put("type", getType(c));
|
||||
JSONArray required = new JSONArray();
|
||||
|
||||
if(c.isAssignableFrom(IrisRegistrant.class) || IrisRegistrant.class.isAssignableFrom(c))
|
||||
{
|
||||
if (c.isAssignableFrom(IrisRegistrant.class) || IrisRegistrant.class.isAssignableFrom(c)) {
|
||||
for (Field k : IrisRegistrant.class.getDeclaredFields()) {
|
||||
k.setAccessible(true);
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.volmit.iris.engine.object.spawners.IrisSpawner;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.context.IrisContext;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -81,49 +80,35 @@ public class IrisData {
|
||||
hotloaded();
|
||||
}
|
||||
|
||||
public void preprocessObject(IrisRegistrant t)
|
||||
{
|
||||
try
|
||||
{
|
||||
public void preprocessObject(IrisRegistrant t) {
|
||||
try {
|
||||
IrisContext ctx = IrisContext.get();
|
||||
Engine engine = this.engine;
|
||||
|
||||
if(engine == null && ctx != null && ctx.getEngine() != null)
|
||||
{
|
||||
if (engine == null && ctx != null && ctx.getEngine() != null) {
|
||||
engine = ctx.getEngine();
|
||||
}
|
||||
|
||||
if(engine == null && t.getPreprocessors().isNotEmpty())
|
||||
{
|
||||
if (engine == null && t.getPreprocessors().isNotEmpty()) {
|
||||
Iris.error("Failed to preprocess object " + t.getLoadKey() + " because there is no engine context here. (See stack below)");
|
||||
try
|
||||
{
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
catch(Throwable ex)
|
||||
{
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(engine != null && t.getPreprocessors().isNotEmpty())
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (engine != null && t.getPreprocessors().isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
engine.getExecution().getAPI().setPreprocessorObject(t);
|
||||
|
||||
for(String i : t.getPreprocessors())
|
||||
{
|
||||
for (String i : t.getPreprocessors()) {
|
||||
engine.getExecution().execute(i);
|
||||
Iris.debug("Loader<" + C.GREEN + t.getTypeName() + C.LIGHT_PURPLE + "> iprocess " + C.YELLOW + t.getLoadKey() + C.LIGHT_PURPLE + " in <rainbow>" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
Iris.error("Failed to preprocess object!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -149,11 +134,9 @@ public class IrisData {
|
||||
ResourceLoader<T> r = null;
|
||||
if (registrant.equals(IrisObject.class)) {
|
||||
r = (ResourceLoader<T>) new ObjectResourceLoader(dataFolder, this, rr.getFolderName(), rr.getTypeName());
|
||||
}
|
||||
else if (registrant.equals(IrisScript.class)) {
|
||||
} else if (registrant.equals(IrisScript.class)) {
|
||||
r = (ResourceLoader<T>) new ScriptResourceLoader(dataFolder, this, rr.getFolderName(), rr.getTypeName());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
r = new ResourceLoader<T>(dataFolder, this, rr.getFolderName(), rr.getTypeName(), registrant);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.common.IrisScript;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimensionIndex;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -20,20 +20,12 @@ package com.volmit.iris.core.project.loader;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.object.common.IrisScript;
|
||||
import com.volmit.iris.engine.object.objects.IrisObject;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import lombok.Data;
|
||||
public class IrisContext {
|
||||
private static ChronoLatch cl = new ChronoLatch(60000);
|
||||
private static KMap<Thread, IrisContext> context = new KMap<>();
|
||||
private final Engine engine;
|
||||
|
||||
public static IrisContext get() {
|
||||
return context.get(Thread.currentThread());
|
||||
@@ -50,8 +51,6 @@ public class IrisContext {
|
||||
}
|
||||
}
|
||||
|
||||
private final Engine engine;
|
||||
|
||||
public void touch() {
|
||||
IrisContext.touch(this);
|
||||
}
|
||||
@@ -61,6 +60,6 @@ public class IrisContext {
|
||||
}
|
||||
|
||||
public IrisComplex getComplex() {
|
||||
return engine.getFramework().getComplex();
|
||||
return engine.getComplex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ReactiveFolder {
|
||||
|
||||
if (checkCycle % 3 == 0 ? fw.checkModified() : fw.checkModifiedFast()) {
|
||||
for (File i : fw.getCreated()) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json")|| i.getName().endsWith(".js")) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) {
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class ReactiveFolder {
|
||||
|
||||
if (!modified) {
|
||||
for (File i : fw.getChanged()) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json")|| i.getName().endsWith(".js")) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) {
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class ReactiveFolder {
|
||||
|
||||
if (!modified) {
|
||||
for (File i : fw.getDeleted()) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json")|| i.getName().endsWith(".js")) {
|
||||
if (i.getName().endsWith(".iob") || i.getName().endsWith(".json") || i.getName().endsWith(".js")) {
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
|
||||
package com.volmit.iris.util.mantle;
|
||||
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.data.Varint;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.matter.IrisMatter;
|
||||
import com.volmit.iris.util.matter.Matter;
|
||||
@@ -63,8 +60,7 @@ public class MantleChunk {
|
||||
int s = din.readByte();
|
||||
int f = din.readByte();
|
||||
|
||||
for(int i = 0; i < f; i++)
|
||||
{
|
||||
for (int i = 0; i < f; i++) {
|
||||
flags.add(din.readUTF());
|
||||
}
|
||||
|
||||
@@ -75,21 +71,15 @@ public class MantleChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public void flag(String s, boolean f)
|
||||
{
|
||||
if(f)
|
||||
{
|
||||
public void flag(String s, boolean f) {
|
||||
if (f) {
|
||||
flags.add(s);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flags.remove(s);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFlagged(String s)
|
||||
{
|
||||
public boolean isFlagged(String s) {
|
||||
return flags.contains(s);
|
||||
}
|
||||
|
||||
@@ -162,8 +152,7 @@ public class MantleChunk {
|
||||
dos.writeByte(sections.length());
|
||||
dos.writeByte(flags.size());
|
||||
|
||||
for(String i : flags)
|
||||
{
|
||||
for (String i : flags) {
|
||||
dos.writeUTF(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,8 @@ public class ZoneMatter extends RawMatter<IrisFeaturePositional> {
|
||||
|
||||
@Override
|
||||
public void setRaw(int x, int y, int z, IrisFeaturePositional t) {
|
||||
for(int i = 0; i < getHeight(); i++)
|
||||
{
|
||||
if(get(x, i, z) == null)
|
||||
{
|
||||
for (int i = 0; i < getHeight(); i++) {
|
||||
if (get(x, i, z) == null) {
|
||||
super.setRaw(x, i, z, t);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user