diff --git a/build.gradle b/build.gradle index cc985d606..efb86de28 100644 --- a/build.gradle +++ b/build.gradle @@ -137,6 +137,7 @@ allprojects { implementation 'net.kyori:adventure-api:4.13.1' //implementation 'org.bytedeco:javacpp:1.5.10' //implementation 'org.bytedeco:cuda-platform:12.3-8.9-1.5.10' + //implementation "org.deeplearning4j:deeplearning4j-core:1.0.0-M2.1" compileOnly 'io.lumine:Mythic-Dist:5.2.1' // Dynamically Loaded diff --git a/core/src/main/java/com/volmit/iris/core/service/BoardSVC.java b/core/src/main/java/com/volmit/iris/core/service/BoardSVC.java index 715a8875a..291dc0b27 100644 --- a/core/src/main/java/com/volmit/iris/core/service/BoardSVC.java +++ b/core/src/main/java/com/volmit/iris/core/service/BoardSVC.java @@ -125,32 +125,18 @@ public class BoardSVC implements IrisService, BoardProvider { int y = player.getLocation().getBlockY() - player.getWorld().getMinHeight(); int z = player.getLocation().getBlockZ(); - if (IrisSettings.get().getGeneral().debug) { - lines.add("&7&m "); - lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0)); - lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize())); - lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount()); - lines.add(C.LIGHT_PURPLE + "Carving" + C.GRAY + ": " + engine.getMantle().isCarved(x, y, z)); - lines.add("&7&m "); - lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); - lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); - lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z))); - lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2)); - lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond())); - lines.add("&7&m "); - } else { - lines.add("&7&m "); - lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0)); - lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize())); - lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount()); - lines.add("&7&m "); - lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); - lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); - lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z))); - lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2)); - lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond())); - lines.add("&7&m "); - } + lines.add("&7&m "); + lines.add(C.GREEN + "Speed" + C.GRAY + ": " + Form.f(engine.getGeneratedPerSecond(), 0) + "/s " + Form.duration(1000D / engine.getGeneratedPerSecond(), 0)); + lines.add(C.AQUA + "Cache" + C.GRAY + ": " + Form.f(IrisData.cacheSize())); + lines.add(C.AQUA + "Mantle" + C.GRAY + ": " + engine.getMantle().getLoadedRegionCount()); + lines.add(C.AQUA + "Energy" + C.GRAY + ": " + C.GOLD + Math.round(engine.getWorldManager().getEnergy())); + lines.add("&7&m "); + lines.add(C.AQUA + "Region" + C.GRAY + ": " + engine.getRegion(x, z).getName()); + lines.add(C.AQUA + "Biome" + C.GRAY + ": " + engine.getBiomeOrMantle(x, y, z).getName()); + lines.add(C.AQUA + "Height" + C.GRAY + ": " + Math.round(engine.getHeight(x, z))); + lines.add(C.AQUA + "Slope" + C.GRAY + ": " + Form.f(engine.getComplex().getSlopeStream().get(x, z), 2)); + lines.add(C.AQUA + "BUD/s" + C.GRAY + ": " + Form.f(engine.getBlockUpdatesPerSecond())); + lines.add("&7&m "); } } } diff --git a/core/src/main/java/com/volmit/iris/engine/IrisWorldManager.java b/core/src/main/java/com/volmit/iris/engine/IrisWorldManager.java index eb03244f8..41a3deb60 100644 --- a/core/src/main/java/com/volmit/iris/engine/IrisWorldManager.java +++ b/core/src/main/java/com/volmit/iris/engine/IrisWorldManager.java @@ -136,7 +136,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } - if (getDimension().isInfiniteEnergy()) { + if (getDimension().getEnergy().isInfiniteEnergy()) { energy += 1000; fixEnergy(); } @@ -287,7 +287,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager { } private void fixEnergy() { - energy = M.clip(energy, 1D, getDimension().getMaximumEnergy()); + energy = M.clip(energy, 1D, getDimension().getEnergy().evaluate(null, getData(), energy)); } private void spawnIn(Chunk c, boolean initial) { diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisBukkitStreamType.java b/core/src/main/java/com/volmit/iris/engine/object/IrisBukkitStreamType.java new file mode 100644 index 000000000..e7c38ae4b --- /dev/null +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisBukkitStreamType.java @@ -0,0 +1,31 @@ +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.util.stream.ProceduralStream; +import org.bukkit.Bukkit; + +import java.util.function.Function; + +@Desc("Represents a stream from the engine") +public enum IrisBukkitStreamType { + + @Desc("Gets the online player count.") + MAX_ONLINE_PLAYERS((f) -> Bukkit.getMaxPlayers()), + + @Desc("Gets the online player count.") + ONLINE_PLAYERS((f) -> Bukkit.getOnlinePlayers().size()), + + @Desc("Gets the online player count on the running world.") + WORLD_PLAYERS((f) -> f.getWorld().getPlayers().size()),; + + private final Function getter; + + IrisBukkitStreamType(Function getter) { + this.getter = getter; + } + + public Integer get(Engine engine) { + return getter.apply(engine); + } +} diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java b/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java index eff9fc558..3621caaf8 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisDimension.java @@ -206,11 +206,7 @@ public class IrisDimension extends IrisRegistrant { @Desc("Overlay additional noise on top of the interoplated terrain.") private KList overlayNoise = new KList<>(); @Desc("If true, the spawner system has infinite energy. This is NOT recommended because it would allow for mobs to keep spawning over and over without a rate limit") - private boolean infiniteEnergy = false; - @MinNumber(0) - @MaxNumber(10000) - @Desc("This is the maximum energy you can have in a dimension") - private double maximumEnergy = 1000; + private IrisEnergy energy = new IrisEnergy(); @MinNumber(0.0001) @MaxNumber(512) @Desc("The rock zoom mostly for zooming in on a wispy palette") diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisEnergy.java b/core/src/main/java/com/volmit/iris/engine/object/IrisEnergy.java new file mode 100644 index 000000000..82caa59fd --- /dev/null +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisEnergy.java @@ -0,0 +1,101 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2024 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 . + */ + +package com.volmit.iris.engine.object; + +import com.dfsek.paralithic.Expression; +import com.dfsek.paralithic.eval.parser.Parser; +import com.dfsek.paralithic.eval.parser.Scope; +import com.volmit.iris.Iris; +import com.volmit.iris.core.loader.IrisData; +import com.volmit.iris.engine.data.cache.AtomicCache; +import com.volmit.iris.engine.object.annotations.*; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.math.RNG; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@SuppressWarnings("ALL") +@Snippet("energy") +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor + +@Desc("Represents an iris entity.") +@Data +public class IrisEnergy { + @Desc("If true, the spawner system has infinite energy. This is NOT recommended because it would allow for mobs to keep spawning over and over without a rate limit") + private boolean infiniteEnergy = false; + @MinNumber(0) + @MaxNumber(10000) +// @Desc("This is the maximum energy you can have in a dimension") +// private double maximumEnergy = 1000; + @Desc("The expression. For your energy scaling, Inherited variables are me ( maximum energy ), ce ( current energy ). Avoid using those variable names. ") + private String expression = null; + @ArrayType(type = IrisEnergyExpressionLoad.class, min = 1) + @Desc("Variables to use in this expression") + private KList variables = new KList<>(); + + private static final Parser parser = new Parser(); + private transient AtomicCache expressionCache = new AtomicCache<>(); + + private Expression expression() { + return expressionCache.aquire(() -> { + Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables. + + try { + for (IrisEnergyExpressionLoad i : variables) { + scope.addInvocationVariable(i.getName()); + } + + scope.addInvocationVariable("ce"); + } catch (Throwable e) { + e.printStackTrace(); + Iris.error("Script Variable load error in Energy Expression"); + } + + try { + if (expression != null) { + return parser.parse(getExpression(), scope); + } + return parser.parse("1000", scope); + } catch (Throwable e) { + e.printStackTrace(); + Iris.error("Script load error in Energy Expression"); + } + + return null; + }); + } + + public double evaluate(RNG rng, IrisData data, Double ce) { + double[] g = new double[3 + getVariables().size()]; + int m = 0; + for (IrisEnergyExpressionLoad i : getVariables()) { + g[m++] = i.getValue(rng, data, ce); + } + + g[m++] = ce; + g[m] = -1; + + return expression().evaluate(g); + } + +} diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisEnergyExpressionLoad.java b/core/src/main/java/com/volmit/iris/engine/object/IrisEnergyExpressionLoad.java new file mode 100644 index 000000000..046c4c5fb --- /dev/null +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisEnergyExpressionLoad.java @@ -0,0 +1,67 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2024 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 . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.core.loader.IrisData; +import com.volmit.iris.engine.data.cache.AtomicCache; +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.Required; +import com.volmit.iris.engine.object.annotations.Snippet; +import com.volmit.iris.util.math.RNG; +import com.volmit.iris.util.stream.ProceduralStream; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Snippet("expression-load") +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("Represents a variable to use in your expression. Do not set the name to x, y, or z, also don't duplicate names.") +@Data +@EqualsAndHashCode(callSuper = false) +public class IrisEnergyExpressionLoad { + @Required + @Desc("The variable to assign this value to. Do not set the name to x, y, or z") + private String name = ""; + + @Desc("If the style value is not defined, this value will be used") + private double staticValue = -1; + + @Desc("If defined, bukkit will stream some selected values.") + private IrisBukkitStreamType bukkitStreamValue = null; + + + // todo: Unknown: This may fuck up and provide fake values, unsure. + private transient AtomicCache streamCache = new AtomicCache<>(); + private transient AtomicCache valueCache = new AtomicCache<>(); + + + public double getValue(RNG rng, IrisData data, Double ce) { + + if (bukkitStreamValue != null) { + return streamCache.aquire(() -> bukkitStreamValue.get(data.getEngine())); + } + + return staticValue; + } + +} diff --git a/core/src/main/java/com/volmit/iris/engine/service/EngineMobHandlerSVC.java b/core/src/main/java/com/volmit/iris/engine/service/EngineMobHandlerSVC.java new file mode 100644 index 000000000..9042096f4 --- /dev/null +++ b/core/src/main/java/com/volmit/iris/engine/service/EngineMobHandlerSVC.java @@ -0,0 +1,24 @@ +package com.volmit.iris.engine.service; + +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.object.IrisEngineService; + +public class EngineMobHandlerSVC extends IrisEngineService { + + public EngineMobHandlerSVC(Engine engine) { + super(engine); + } + + + + + @Override + public void onEnable(boolean hotload) { + + } + + @Override + public void onDisable(boolean hotload) { + + } +}