mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 08:16:31 +00:00
Cleanup
This commit is contained in:
@@ -77,20 +77,17 @@ public class IrisCarveLayer {
|
||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||
}
|
||||
|
||||
public ProceduralStream<Boolean> stream(RNG rng)
|
||||
{
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x,y,z) -> isCarved(rng, x,y,z), Interpolated.BOOLEAN));
|
||||
public ProceduralStream<Boolean> stream(RNG rng) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x, y, z) -> isCarved(rng, x, y, z), Interpolated.BOOLEAN));
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> rawStream(RNG rng)
|
||||
{
|
||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x,y,z) -> {
|
||||
public ProceduralStream<Double> rawStream(RNG rng) {
|
||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> {
|
||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||
}, Interpolated.DOUBLE));
|
||||
}
|
||||
|
||||
public CNG getCng(RNG rng)
|
||||
{
|
||||
public CNG getCng(RNG rng) {
|
||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight())));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
@@ -31,9 +30,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@@ -53,18 +49,16 @@ public class IrisCavernZone implements IRare {
|
||||
private AtomicCache<ProceduralStream<Boolean>> carveCache = new AtomicCache<>();
|
||||
|
||||
public boolean isCarved(RNG rng, double xx, double yy, double zz) {
|
||||
if(carver != null)
|
||||
{
|
||||
return carver.isCarved(rng, xx,yy,zz);
|
||||
if (carver != null) {
|
||||
return carver.isCarved(rng, xx, yy, zz);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getCarved(RNG rng, double xx, double yy, double zz) {
|
||||
if(carver != null)
|
||||
{
|
||||
return carver.rawStream(rng).get(xx,yy,zz) / (carver.getThreshold() * 2);
|
||||
if (carver != null) {
|
||||
return carver.rawStream(rng).get(xx, yy, zz) / (carver.getThreshold() * 2);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
import com.volmit.iris.engine.stream.interpolation.Interpolated;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
@@ -59,40 +58,35 @@ public class IrisCaverns {
|
||||
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
|
||||
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
||||
|
||||
public IrisCavernZone getZone(double x, double y, double z, RNG rng)
|
||||
{
|
||||
public IrisCavernZone getZone(double x, double y, double z, RNG rng) {
|
||||
return zonesRarity.aquire(() -> zoneStyle.create(rng)
|
||||
.stream().selectRarity(getZones())).get(x,y,z);
|
||||
.stream().selectRarity(getZones())).get(x, y, z);
|
||||
}
|
||||
|
||||
private double threshold(double y)
|
||||
{
|
||||
private double threshold(double y) {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng)
|
||||
{
|
||||
if(preThresholdInterpolation)
|
||||
{
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx,yy,zz)
|
||||
public ProceduralStream<Double> stream(RNG rng) {
|
||||
if (preThresholdInterpolation) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||
-> (getZone(xx, yy, zz, rng)
|
||||
.getCarved(rng, xx,yy,zz)), Interpolated.DOUBLE)
|
||||
.getCarved(rng, xx, yy, zz)), Interpolated.DOUBLE)
|
||||
.cache3D(65535));
|
||||
}
|
||||
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx,yy,zz)
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||
-> (getZone(xx, yy, zz, rng)
|
||||
.isCarved(rng, xx,yy,zz) ? 1D : 0D), Interpolated.DOUBLE)
|
||||
.isCarved(rng, xx, yy, zz) ? 1D : 0D), Interpolated.DOUBLE)
|
||||
.cache3D(65535));
|
||||
}
|
||||
|
||||
public boolean isCavern(RNG rng, double x, double y, double z, double height) {
|
||||
if(zones.isEmpty())
|
||||
{
|
||||
if (zones.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getInterpolator().interpolate(x, y, z, (xx, yy, zz)
|
||||
-> stream(rng).get(xx,yy,zz)) > threshold(height);
|
||||
-> stream(rng).get(xx, yy, zz)) > threshold(height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ package com.volmit.iris.engine.object;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -58,13 +57,11 @@ public class IrisDuration {
|
||||
@Desc("REAL (not minecraft) Days")
|
||||
private int days = 0;
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return Form.duration((double) toMilliseconds(), 2);
|
||||
}
|
||||
|
||||
public long toMilliseconds()
|
||||
{
|
||||
public long toMilliseconds() {
|
||||
return getMilliseconds()
|
||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||
|
||||
@@ -273,7 +273,7 @@ public class IrisEffect {
|
||||
}
|
||||
|
||||
if (particleEffect != null) {
|
||||
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1,1,1).multiply(RNG.r.d())).subtract(new Vector(1,1,1).multiply(RNG.r.d()));
|
||||
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1, 1, 1).multiply(RNG.r.d())).subtract(new Vector(1, 1, 1).multiply(RNG.r.d()));
|
||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||
if (extra != 0) {
|
||||
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
|
||||
|
||||
@@ -259,8 +259,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
m.setAware(isAware());
|
||||
}
|
||||
|
||||
if(spawnEffect != null)
|
||||
{
|
||||
if (spawnEffect != null) {
|
||||
spawnEffect.apply(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -29,7 +28,6 @@ import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -102,8 +100,7 @@ public class IrisEntitySpawn implements IRare {
|
||||
try {
|
||||
Location l = at.clone().add(0.5, 1, 0.5);
|
||||
Entity e = getRealEntity(g).spawn(g, l, rng.aquire(() -> new RNG(g.getTarget().getWorld().seed() + 4)));
|
||||
if(e != null)
|
||||
{
|
||||
if (e != null) {
|
||||
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,10 @@ 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.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -57,36 +54,26 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
||||
|
||||
private transient AtomicCache<Expression> expressionCache = new AtomicCache<>();
|
||||
|
||||
private Expression expression()
|
||||
{
|
||||
private Expression expression() {
|
||||
return expressionCache.aquire(() -> {
|
||||
Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables.
|
||||
|
||||
try
|
||||
{
|
||||
for(IrisExpressionLoad i : variables)
|
||||
{
|
||||
try {
|
||||
for (IrisExpressionLoad i : variables) {
|
||||
scope.addInvocationVariable(i.getName());
|
||||
}
|
||||
|
||||
scope.addInvocationVariable("x");
|
||||
scope.addInvocationVariable("y");
|
||||
scope.addInvocationVariable("z");
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("Script Variable load error in " + getLoadFile().getPath());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
return parser.parse(getExpression(), scope);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("Script load error in " + getLoadFile().getPath());
|
||||
}
|
||||
@@ -95,12 +82,10 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
||||
});
|
||||
}
|
||||
|
||||
public double evaluate(RNG rng, double x, double z)
|
||||
{
|
||||
public double evaluate(RNG rng, double x, double z) {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for(IrisExpressionLoad i : getVariables())
|
||||
{
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, x, z);
|
||||
}
|
||||
|
||||
@@ -111,12 +96,10 @@ public class IrisExpressionGenerator extends IrisRegistrant {
|
||||
return expression().evaluate(g);
|
||||
}
|
||||
|
||||
public double evaluate(RNG rng, double x, double y, double z)
|
||||
{
|
||||
public double evaluate(RNG rng, double x, double y, double z) {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for(IrisExpressionLoad i : getVariables())
|
||||
{
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ public class IrisExpressionLoad {
|
||||
private IrisGeneratorStyle styleValue = null;
|
||||
|
||||
public double getValue(RNG rng, double x, double z) {
|
||||
if(styleValue != null)
|
||||
{
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng).noise(x, z);
|
||||
}
|
||||
|
||||
@@ -55,8 +54,7 @@ public class IrisExpressionLoad {
|
||||
}
|
||||
|
||||
public double getValue(RNG rng, double x, double y, double z) {
|
||||
if(styleValue != null)
|
||||
{
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng).noise(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.interpolation.InterpolationMethod3D;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -52,6 +51,6 @@ public class IrisInterpolator3D {
|
||||
}
|
||||
|
||||
public double interpolate(int x, int y, int z, NoiseProvider3 provider) {
|
||||
return IrisInterpolation.getNoise3D(getFunction(), x,y, z, getScale(), provider);
|
||||
return IrisInterpolation.getNoise3D(getFunction(), x, y, z, getScale(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,10 +216,8 @@ public class IrisObjectPlacement {
|
||||
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
for(IrisTree i : getTrees())
|
||||
{
|
||||
if(i.matches(size, type))
|
||||
{
|
||||
for (IrisTree i : getTrees()) {
|
||||
if (i.matches(size, type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,19 +36,16 @@ public class IrisRate {
|
||||
@Desc("The time interval. Leave blank for infinite 0 (meaning always spawn all the time)")
|
||||
private IrisDuration per = new IrisDuration();
|
||||
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return Form.f(amount) + "/" + per;
|
||||
}
|
||||
|
||||
public long getInterval()
|
||||
{
|
||||
public long getInterval() {
|
||||
long t = per.getMilliseconds() / (amount == 0 ? 1 : amount);
|
||||
return Math.abs(t <= 0 ? 1 : t);
|
||||
}
|
||||
|
||||
public ChronoLatch toChronoLatch()
|
||||
{
|
||||
public ChronoLatch toChronoLatch() {
|
||||
return new ChronoLatch(getInterval());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,14 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
import com.volmit.iris.engine.stream.convert.SelectionStream;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.reflect.V;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -56,8 +48,7 @@ public class IrisSpawner extends IrisRegistrant {
|
||||
@Desc("The maximum rate this spawner can fire")
|
||||
private IrisRate maximumRate = new IrisRate();
|
||||
|
||||
public boolean isValid(World world)
|
||||
{
|
||||
public boolean isValid(World world) {
|
||||
return timeBlock.isWithin(world) && weather.is(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.math.CDou;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -33,20 +31,16 @@ public class IrisTimeBlock {
|
||||
@Desc("The ending hour. Set both to the same number for any time. If they are both set to -1, it will always be not allowed.")
|
||||
private double endHour = 0;
|
||||
|
||||
public boolean isWithin(World world)
|
||||
{
|
||||
return isWithin(((world.getTime() / 1000D)+6)%24);
|
||||
public boolean isWithin(World world) {
|
||||
return isWithin(((world.getTime() / 1000D) + 6) % 24);
|
||||
}
|
||||
|
||||
public boolean isWithin(double hour)
|
||||
{
|
||||
if(startHour == endHour)
|
||||
{
|
||||
public boolean isWithin(double hour) {
|
||||
if (startHour == endHour) {
|
||||
return endHour != -1;
|
||||
}
|
||||
|
||||
if(startHour > endHour)
|
||||
{
|
||||
if (startHour > endHour) {
|
||||
return hour >= startHour || hour <= endHour;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ public class IrisTree {
|
||||
private boolean anySize;
|
||||
|
||||
public boolean matches(IrisTreeSize size, TreeType type) {
|
||||
if(!matchesSize(size))
|
||||
{
|
||||
if (!matchesSize(size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,10 +60,8 @@ public class IrisTree {
|
||||
}
|
||||
|
||||
private boolean matchesSize(IrisTreeSize size) {
|
||||
for(IrisTreeSize i : getSizes())
|
||||
{
|
||||
if((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth()))
|
||||
{
|
||||
for (IrisTreeSize i : getSizes()) {
|
||||
if ((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
@Desc("Represents a weather type")
|
||||
@@ -36,10 +35,8 @@ public enum IrisWeather {
|
||||
@Desc("Any weather")
|
||||
ANY;
|
||||
|
||||
public boolean is(World world)
|
||||
{
|
||||
return switch(this)
|
||||
{
|
||||
public boolean is(World world) {
|
||||
return switch (this) {
|
||||
case NONE -> world.isClearWeather();
|
||||
case DOWNFALL -> world.hasStorm();
|
||||
case DOWNFALL_WITH_THUNDER -> world.hasStorm() && world.isThundering();
|
||||
|
||||
@@ -22,8 +22,7 @@ import com.volmit.iris.util.collection.KList;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IrisEngineData
|
||||
{
|
||||
public class IrisEngineData {
|
||||
private IrisEngineStatistics statistics = new IrisEngineStatistics();
|
||||
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ import com.volmit.iris.util.math.M;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class IrisEngineSpawnerCooldown
|
||||
{
|
||||
public class IrisEngineSpawnerCooldown {
|
||||
private long lastSpawn;
|
||||
private String spawner;
|
||||
|
||||
public void spawn(Engine engine)
|
||||
{
|
||||
public void spawn(Engine engine) {
|
||||
lastSpawn = M.ms();
|
||||
}
|
||||
|
||||
public boolean canSpawn(IrisRate s)
|
||||
{
|
||||
public boolean canSpawn(IrisRate s) {
|
||||
return M.ms() - lastSpawn > s.getInterval();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user