9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00
This commit is contained in:
cyberpwn
2021-08-24 22:28:33 -04:00
parent 432e95e4ec
commit 8df789ae34
84 changed files with 404 additions and 786 deletions

View File

@@ -49,12 +49,10 @@ public class IrisContext {
}
public static void dereference() {
synchronized (context)
{
synchronized (context) {
for (Thread i : context.k()) {
if (!i.isAlive() || context.get(i).engine.isClosed()) {
if(context.get(i).engine.isClosed())
{
if (context.get(i).engine.isClosed()) {
Iris.debug("Dereferenced Context<Engine> " + i.getName() + " " + i.getId());
}

View File

@@ -21,7 +21,6 @@ package com.volmit.iris.util.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.scheduling.ChronoLatch;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
@@ -284,8 +283,7 @@ public class B {
return Material.valueOf(bdx.trim().toUpperCase());
} catch (Throwable e) {
Iris.reportError(e);
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Material: " + bdx);
}
return null;
@@ -295,8 +293,7 @@ public class B {
public static Material getMaterial(String bdx) {
Material m = getMaterialOrNull(bdx);
if(m == null)
{
if (m == null) {
return AIR_MATERIAL;
}
@@ -313,8 +310,7 @@ public class B {
BlockData bdx = parseBlockData(bd);
if (bdx == null) {
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data '" + bd + "'");
}
return AIR;
@@ -324,8 +320,7 @@ public class B {
} catch (Throwable e) {
Iris.reportError(e);
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data '" + bdxf + "'");
}
}
@@ -363,8 +358,7 @@ public class B {
return bx;
} catch (Throwable e) {
if(clw.flip())
{
if (clw.flip()) {
Iris.warn("Unknown Block Data: " + ix);
}

View File

@@ -20,11 +20,9 @@ package com.volmit.iris.util.data;
import com.volmit.iris.Iris;
import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.jobs.DownloadJob;
import com.volmit.iris.util.scheduling.jobs.Job;
import com.volmit.iris.util.scheduling.jobs.JobCollection;
import com.volmit.iris.util.scheduling.jobs.SingleJob;
import lombok.Builder;
@@ -111,8 +109,7 @@ public class IrisPackRepository {
public void install(VolmitSender sender) throws MalformedURLException {
File pack = Iris.instance.getDataFolder(StudioSVC.WORKSPACE_NAME, getRepo());
if(!pack.exists())
{
if (!pack.exists()) {
File dl = new File(Iris.getTemp(), "dltk-" + UUID.randomUUID() + ".zip");
File work = new File(Iris.getTemp(), "extk-" + UUID.randomUUID());
new JobCollection(Form.capitalize(getRepo()),

View File

@@ -44,18 +44,13 @@ public class DecreeParameter {
public DecreeParameterHandler<?> getHandler() {
return handlerCache.aquire(() -> {
try
{
if(param.customHandler().equals(DummyHandler.class))
{
try {
if (param.customHandler().equals(DummyHandler.class)) {
return DecreeSystem.getHandler(getType());
}
return param.customHandler().getConstructor().newInstance();
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@@ -32,8 +32,7 @@ public interface DecreeParameterHandler<T> {
*/
KList<T> getPossibilities();
default boolean isDummy()
{
default boolean isDummy() {
return false;
}

View File

@@ -25,7 +25,6 @@ import com.volmit.iris.util.decree.DecreeSystem;
import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.VolmitSender;
import org.bukkit.FluidCollisionMode;
import org.bukkit.entity.Player;

View File

@@ -29,8 +29,7 @@ public class DummyHandler implements DecreeParameterHandler<Object> {
return null;
}
public boolean isDummy()
{
public boolean isDummy() {
return true;
}

View File

@@ -27,7 +27,6 @@ import com.volmit.iris.util.interpolation.InterpolationMethod;
import com.volmit.iris.util.interpolation.InterpolationMethod3D;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.nbt.tag.ByteArrayTag;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.stream.interpolation.Interpolated;
@@ -37,9 +36,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
@@ -1437,8 +1434,7 @@ public interface Hunk<T> {
return false;
}
default boolean contains(int x, int y, int z)
{
default boolean contains(int x, int y, int z) {
return x < getWidth() && x >= 0 && y < getHeight() && y >= 0 && z < getDepth() && z >= 0;
}
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.hunk.storage;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.function.Consumer4IO;
import com.volmit.iris.util.hunk.Hunk;
@@ -49,15 +48,14 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
}
public boolean isEmpty() {
synchronized(data)
{
synchronized (data) {
return data.isEmpty();
}
}
@Override
public void setRaw(int x, int y, int z, T t) {
synchronized(data) {
synchronized (data) {
if (t == null) {
data.remove(index(x, y, z));
return;
@@ -73,8 +71,7 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
synchronized(data)
{
synchronized (data) {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
@@ -90,8 +87,7 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public synchronized Hunk<T> iterateSyncIO(Consumer4IO<Integer, Integer, Integer, T> c) throws IOException {
synchronized(data)
{
synchronized (data) {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
@@ -107,16 +103,14 @@ public class MappedSyncHunk<T> extends StorageHunk<T> implements Hunk<T> {
@Override
public void empty(T b) {
synchronized(data)
{
synchronized (data) {
data.clear();
}
}
@Override
public T getRaw(int x, int y, int z) {
synchronized(data)
{
synchronized (data) {
return data.get(index(x, y, z));
}
}

View File

@@ -45,7 +45,6 @@ import org.bukkit.util.Vector;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -90,10 +89,11 @@ public class Mantle {
/**
* Raise a flag if it is lowered currently, If the flag was raised, execute the runnable
* @param x the chunk x
* @param z the chunk z
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag to raise
* @param r the runnable to fire if the flag is now raised (and was previously lowered)
* @param r the runnable to fire if the flag is now raised (and was previously lowered)
*/
@ChunkCoordinates
public void raiseFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -106,23 +106,24 @@ public class Mantle {
/**
* Obtain a cached writer which only contains cached chunks.
* This avoids locking on regions when writing to lots of chunks
* @param x the x chunk
* @param z the z chunk
*
* @param x the x chunk
* @param z the z chunk
* @param radius the radius chunks
* @return the writer
*/
@ChunkCoordinates
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius)
{
public MantleWriter write(EngineMantle engineMantle, int x, int z, int radius) {
return new MantleWriter(engineMantle, this, x, z, radius);
}
/**
* Lower a flag if it is raised. If the flag was lowered (meaning it was previously raised), execute the runnable
* @param x the chunk x
* @param z the chunk z
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag to lower
* @param r the runnable that is fired if the flag was raised but is now lowered
* @param r the runnable that is fired if the flag was raised but is now lowered
*/
@ChunkCoordinates
public void lowerFlag(int x, int z, MantleFlag flag, Runnable r) {
@@ -133,16 +134,16 @@ public class Mantle {
}
@ChunkCoordinates
public MantleChunk getChunk(int x, int z)
{
return get(x>>5, z>>5).getOrCreate(x & 31, z & 31);
public MantleChunk getChunk(int x, int z) {
return get(x >> 5, z >> 5).getOrCreate(x & 31, z & 31);
}
/**
* Flag or unflag a chunk
* @param x the chunk x
* @param z the chunk z
* @param flag the flag
*
* @param x the chunk x
* @param z the chunk z
* @param flag the flag
* @param flagged should it be set to flagged or not
*/
@ChunkCoordinates
@@ -152,29 +153,29 @@ public class Mantle {
/**
* Check very quickly if a tectonic plate exists via cached or the file system
*
* @param x the x region coordinate
* @param z the z region coordinate
* @return true if it exists
*/
@RegionCoordinates
public boolean hasTectonicPlate(int x, int z)
{
public boolean hasTectonicPlate(int x, int z) {
Long k = key(x, z);
return loadedRegions.containsKey(k) || fileForRegion(dataFolder, k).exists();
}
/**
* Iterate data in a chunk
* @param x the chunk x
* @param z the chunk z
* @param type the type of data to iterate
*
* @param x the chunk x
* @param z the chunk z
* @param type the type of data to iterate
* @param iterator the iterator (x,y,z,data) -> do stuff
* @param <T> the type of data to iterate
* @param <T> the type of data to iterate
*/
@ChunkCoordinates
public <T> void iterateChunk(int x, int z, Class<T> type, Consumer4<Integer, Integer, Integer, T> iterator) {
if(!hasTectonicPlate(x >> 5, z >> 5))
{
if (!hasTectonicPlate(x >> 5, z >> 5)) {
return;
}
@@ -183,15 +184,15 @@ public class Mantle {
/**
* Does this chunk have a flag on it?
* @param x the x
* @param z the z
*
* @param x the x
* @param z the z
* @param flag the flag to test
* @return true if it's flagged
*/
@ChunkCoordinates
public boolean hasFlag(int x, int z, MantleFlag flag) {
if(!hasTectonicPlate(x >> 5, z >> 5))
{
if (!hasTectonicPlate(x >> 5, z >> 5)) {
return false;
}
@@ -222,14 +223,10 @@ public class Mantle {
return;
}
if(t instanceof IrisFeaturePositional)
{
if (t instanceof IrisFeaturePositional) {
get((x >> 4) >> 5, (z >> 4) >> 5)
.getOrCreate((x >> 4) & 31, (z >> 4) & 31).addFeature((IrisFeaturePositional) t);
}
else
{
} else {
Matter matter = get((x >> 4) >> 5, (z >> 4) >> 5)
.getOrCreate((x >> 4) & 31, (z >> 4) & 31)
.getOrCreate(y >> 4);
@@ -260,8 +257,7 @@ public class Mantle {
throw new RuntimeException("The Mantle is closed");
}
if(!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5))
{
if (!hasTectonicPlate((x >> 4) >> 5, (z >> 4) >> 5)) {
return null;
}
@@ -277,10 +273,10 @@ public class Mantle {
/**
* Is this mantle closed
*
* @return true if it is
*/
public boolean isClosed()
{
public boolean isClosed() {
return closed.get();
}
@@ -307,13 +303,9 @@ public class Mantle {
});
}
try
{
try {
b.complete();
}
catch(Throwable e)
{
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -457,9 +449,10 @@ public class Mantle {
/**
* Get the file for a region
*
* @param folder the folder
* @param x the x coord
* @param z the z coord
* @param x the x coord
* @param z the z coord
* @return the file
*/
public static File fileForRegion(File folder, int x, int z) {
@@ -468,14 +461,14 @@ public class Mantle {
/**
* Get the file for the given region
*
* @param folder the data folder
* @param key the region key
* @param key the region key
* @return the file
*/
public static File fileForRegion(File folder, Long key) {
File f = new File(folder, "p." + key + ".ttp");
if(!f.getParentFile().exists())
{
if (!f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
return f;
@@ -483,6 +476,7 @@ public class Mantle {
/**
* Get the long value representing a chunk or region coordinate
*
* @param x the x
* @param z the z
* @return the value
@@ -497,33 +491,33 @@ public class Mantle {
/**
* Set a sphere into the mantle
* @param cx the center x
* @param cy the center y
* @param cz the center z
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param radius the radius of this sphere
* @param fill should it be filled? or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param fill should it be filled? or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data)
{
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) {
setElipsoid(cx, cy, cz, radius, radius, radius, fill, data);
}
/**
* Set an elipsoid into the mantle
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param rx the x radius
* @param ry the y radius
* @param rz the z radius
*
* @param cx the center x
* @param cy the center y
* @param cz the center z
* @param rx the x radius
* @param ry the y radius
* @param rz the z radius
* @param fill should it be filled or just the outer shell?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
public <T> void setElipsoid(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data)
{
public <T> void setElipsoid(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, T data) {
rx += 0.5;
ry += 0.5;
rz += 0.5;
@@ -535,11 +529,13 @@ public class Mantle {
final int ceilRadiusZ = (int) Math.ceil(rz);
double nextXn = 0;
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
forX:
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextYn = 0;
forY: for (int y = 0; y <= ceilRadiusY; ++y) {
forY:
for (int y = 0; y <= ceilRadiusY; ++y) {
final double yn = nextYn;
nextYn = (y + 1) * invRadiusY;
double nextZn = 0;
@@ -564,15 +560,15 @@ public class Mantle {
}
}
set(x + cx,y + cy,z + cz, data);
set(-x + cx,y + cy,z + cz, data);
set(x + cx,-y + cy,z + cz, data);
set(x + cx,y + cy,-z + cz, data);
set(-x + cx,y + cy,-z + cz, data);
set(-x + cx,-y + cy,z + cz, data);
set(x + cx,-y + cy,-z + cz, data);
set(-x + cx,y + cy,-z + cz, data);
set(-x + cx,-y + cy,-z + cz, data);
set(x + cx, y + cy, z + cz, data);
set(-x + cx, y + cy, z + cz, data);
set(x + cx, -y + cy, z + cz, data);
set(x + cx, y + cy, -z + cz, data);
set(-x + cx, y + cy, -z + cz, data);
set(-x + cx, -y + cy, z + cz, data);
set(x + cx, -y + cy, -z + cz, data);
set(-x + cx, y + cy, -z + cz, data);
set(-x + cx, -y + cy, -z + cz, data);
}
}
}
@@ -580,26 +576,23 @@ public class Mantle {
/**
* Set a cuboid of data in the mantle
* @param x1 the min x
* @param y1 the min y
* @param z1 the min z
* @param x2 the max x
* @param y2 the max y
* @param z2 the max z
*
* @param x1 the min x
* @param y1 the min y
* @param z1 the min z
* @param x2 the max x
* @param y2 the max y
* @param z2 the max z
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data)
{
int j,k;
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) {
int j, k;
for(int i = x1; i <= x2; i++)
{
for(j = x1; j <= x2; j++)
{
for(k = x1; k <= x2; k++)
{
set(i,j,k,data);
for (int i = x1; i <= x2; i++) {
for (j = x1; j <= x2; j++) {
for (k = x1; k <= x2; k++) {
set(i, j, k, data);
}
}
}
@@ -607,13 +600,14 @@ public class Mantle {
/**
* Set a pyramid of data in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param size the size of the pyramid (width of base & height)
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param size the size of the pyramid (width of base & height)
* @param filled should it be filled or hollow
* @param <T> the type of data to apply to the mantle
* @param <T> the type of data to apply to the mantle
*/
@SuppressWarnings("ConstantConditions")
public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) {
@@ -636,10 +630,11 @@ public class Mantle {
/**
* Set a 3d tube spline interpolated with Kochanek Bartels
*
* @param nodevectors the vector points
* @param radius the radius
* @param filled if it should be filled or hollow
* @param data the data to set
* @param radius the radius
* @param filled if it should be filled or hollow
* @param data the data to set
*/
public <T> void setSpline(List<Vector> nodevectors, double radius, boolean filled, T data) {
setSpline(nodevectors, 0, 0, 0, 10, radius, filled, data);
@@ -647,15 +642,16 @@ public class Mantle {
/**
* Set a 3d tube spline interpolated with Kochanek Bartels
*
* @param nodevectors the spline points
* @param tension the tension 0
* @param bias the bias 0
* @param continuity the continuity 0
* @param quality the quality 10
* @param radius the radius
* @param filled filled or hollow
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param tension the tension 0
* @param bias the bias 0
* @param continuity the continuity 0
* @param quality the quality 10
* @param radius the radius
* @param filled filled or hollow
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setSpline(List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled, T data) {
Set<IrisPosition> vset = new KSet<>();
@@ -687,25 +683,26 @@ public class Mantle {
/**
* Set a 3d line
* @param a the first point
* @param b the second point
*
* @param a the first point
* @param b the second point
* @param radius the radius
* @param filled hollow or filled?
* @param data the data
* @param <T> the type of data to apply to the mantle
* @param data the data
* @param <T> the type of data to apply to the mantle
*/
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data)
{
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) {
setLine(ImmutableList.of(a, b), radius, filled, data);
}
/**
* Set lines for points
*
* @param vectors the points
* @param radius the radius
* @param filled hollow or filled?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
* @param radius the radius
* @param filled hollow or filled?
* @param data the data to set
* @param <T> the type of data to apply to the mantle
*/
public <T> void setLine(List<IrisPosition> vectors, double radius, boolean filled, T data) {
Set<IrisPosition> vset = new KSet<>();
@@ -770,28 +767,30 @@ public class Mantle {
/**
* Set a cylinder in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radius the radius
* @param height the height of the cyl
* @param filled filled or not
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled){
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) {
setCylinder(cx, cy, cz, data, radius, radius, height, filled);
}
/**
* Set a cylinder in the mantle
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
*
* @param cx the center x
* @param cy the base y
* @param cz the center z
* @param data the data to set
* @param radiusX the x radius
* @param radiusZ the z radius
* @param height the height of this cyl
* @param filled filled or hollow?
* @param height the height of this cyl
* @param filled filled or hollow?
*/
public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) {
int affected = 0;
@@ -817,7 +816,8 @@ public class Mantle {
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
double nextXn = 0;
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
forX:
for (int x = 0; x <= ceilRadiusX; ++x) {
final double xn = nextXn;
nextXn = (x + 1) * invRadiusX;
double nextZn = 0;
@@ -850,23 +850,18 @@ public class Mantle {
}
}
public <T> void set(IrisPosition pos, T data)
{
public <T> void set(IrisPosition pos, T data) {
set(pos.getX(), pos.getY(), pos.getZ(), data);
}
public <T> void set(List<IrisPosition> positions, T data)
{
for(IrisPosition i : positions)
{
public <T> void set(List<IrisPosition> positions, T data) {
for (IrisPosition i : positions) {
set(i, data);
}
}
public <T> void set(Set<IrisPosition> positions, T data)
{
for(IrisPosition i : positions)
{
public <T> void set(Set<IrisPosition> positions, T data) {
for (IrisPosition i : positions) {
set(i, data);
}
}

View File

@@ -19,15 +19,12 @@
package com.volmit.iris.util.mantle;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.function.Consumer4;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.MatterSlice;
import com.volmit.iris.util.matter.slices.ZoneMatter;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -87,8 +84,7 @@ public class MantleChunk {
short v = din.readShort();
for(int i = 0; i < v; i++)
{
for (int i = 0; i < v; i++) {
features.add(zm.readNode(din));
}
}
@@ -187,8 +183,7 @@ public class MantleChunk {
dos.writeShort(features.size());
for(IrisFeaturePositional i : features)
{
for (IrisFeaturePositional i : features) {
zm.writeNode(i, dos);
}
}

View File

@@ -23,7 +23,6 @@ import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.hunk.storage.ArrayHunk;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import java.io.*;

View File

@@ -30,7 +30,7 @@ public class INode {
private double continuity;
public INode() {
this(new Vector(0,0,0));
this(new Vector(0, 0, 0));
}
public INode(INode other) {

View File

@@ -89,15 +89,15 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
* Returns the linear combination of the given coefficients with the nodes adjacent to baseIndex.
*
* @param baseIndex node index
* @param f1 coefficient for baseIndex-1
* @param f2 coefficient for baseIndex
* @param f3 coefficient for baseIndex+1
* @param f4 coefficient for baseIndex+2
* @param f1 coefficient for baseIndex-1
* @param f2 coefficient for baseIndex
* @param f3 coefficient for baseIndex+1
* @param f4 coefficient for baseIndex+2
* @return linear combination of nodes[n-1..n+2] with f1..4
*/
private Vector linearCombination(int baseIndex, double f1, double f2, double f3, double f4) {
final Vector r1 = retrieve(baseIndex - 1).multiply(f1);
final Vector r2 = retrieve(baseIndex ).multiply(f2);
final Vector r2 = retrieve(baseIndex).multiply(f2);
final Vector r3 = retrieve(baseIndex + 1).multiply(f3);
final Vector r4 = retrieve(baseIndex + 2).multiply(f4);
@@ -108,7 +108,7 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
* Retrieves a node. Indexes are clamped to the valid range.
*
* @param index node index to retrieve
* @return nodes[clamp(0, nodes.length-1)]
* @return nodes[clamp(0, nodes.length - 1)]
*/
private Vector retrieve(int index) {
if (index < 0) {
@@ -204,11 +204,11 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
case 1:
// This case is merely a speed-up for a very common case
return arcLengthRecursive(indexLeft, remainderLeft, 1.0)
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
default:
return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0)
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
}
}

View File

@@ -18,16 +18,13 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.math.BlockPosition;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_17_R1.block.data.type.CraftLeaves;
import org.bukkit.entity.Entity;
import java.io.*;
@@ -190,13 +187,9 @@ public interface Matter {
slice = (MatterSlice<T>) createSlice(c, this);
if (slice == null) {
try
{
try {
throw new RuntimeException("Bad slice " + c.getCanonicalName());
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.util.matter.Sliced;

View File

@@ -32,7 +32,6 @@ import org.bukkit.NamespacedKey;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import javax.management.RuntimeErrorException;
import java.io.File;
import java.io.IOException;
import java.util.Map;
@@ -236,8 +235,7 @@ public class NBTWorld {
getChunkSection(x >> 4, y >> 4, z >> 4).setBlockStateAt(x & 15, y & 15, z & 15, getCompound(data), false);
}
public int getBiomeId(Biome b)
{
public int getBiomeId(Biome b) {
return biomeIds.get(b);
}
@@ -257,8 +255,7 @@ public class NBTWorld {
return s;
}
public Chunk getChunk(int x, int z)
{
public Chunk getChunk(int x, int z) {
return getChunk(getMCA(x >> 5, z >> 5), x, z);
}
@@ -281,10 +278,10 @@ public class NBTWorld {
}
public long getIdleDuration(int x, int z) {
return hyperLock.withResult(x, z, () -> {
Long l = lastUse.get(Cache.key(x, z));
return l == null ? 0 : (M.ms() - l);
});
return hyperLock.withResult(x, z, () -> {
Long l = lastUse.get(Cache.key(x, z));
return l == null ? 0 : (M.ms() - l);
});
}
public MCAFile getMCA(int x, int z) {

View File

@@ -43,8 +43,7 @@ public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<
super(createEmptyValue(3));
}
public ListTag<T> makeAtomic()
{
public ListTag<T> makeAtomic() {
setValue(new CopyOnWriteArrayList<>(getValue()));
return this;
}

View File

@@ -25,19 +25,16 @@ public class Worm {
private double position;
private double velocity;
public Worm(double startPosition, double startVelocity)
{
public Worm(double startPosition, double startVelocity) {
this.position = startPosition;
this.velocity = startVelocity;
}
public void unstep()
{
public void unstep() {
position -= velocity;
}
public void step()
{
public void step() {
position += velocity;
}
}

View File

@@ -18,34 +18,28 @@
package com.volmit.iris.util.noise;
import com.volmit.iris.util.math.Position2;
import lombok.Data;
@Data
public class Worm2
{
public class Worm2 {
private final Worm x;
private final Worm z;
public Worm2(Worm x, Worm z)
{
public Worm2(Worm x, Worm z) {
this.x = x;
this.z = z;
}
public Worm2(int x, int z, int vx, int vz)
{
public Worm2(int x, int z, int vx, int vz) {
this(new Worm(x, vx), new Worm(z, vz));
}
public void step()
{
public void step() {
x.step();
z.step();
}
public void unstep()
{
public void unstep() {
x.unstep();
z.unstep();
}

View File

@@ -21,33 +21,28 @@ package com.volmit.iris.util.noise;
import lombok.Data;
@Data
public class Worm3
{
public class Worm3 {
private final Worm x;
private final Worm y;
private final Worm z;
public Worm3(Worm x,Worm y, Worm z)
{
public Worm3(Worm x, Worm y, Worm z) {
this.x = x;
this.y = y;
this.z = z;
}
public Worm3(int x, int y, int z, int vx, int vy, int vz)
{
public Worm3(int x, int y, int z, int vx, int vy, int vz) {
this(new Worm(x, vx), new Worm(y, vy), new Worm(z, vz));
}
public void step()
{
public void step() {
x.step();
y.step();
z.step();
}
public void unstep()
{
public void unstep() {
x.unstep();
y.unstep();
z.unstep();

View File

@@ -32,18 +32,15 @@ public class WormIterator2 {
private int maxDistance;
private int maxIterations;
public boolean hasNext()
{
public boolean hasNext() {
double dist = maxDistance - (Math.max(Math.abs(worm.getX().getVelocity()), Math.abs(worm.getZ().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm2 next()
{
if(worm == null)
{
public Worm2 next() {
if (worm == null) {
worm = new Worm2(x, z, 0, 0);
return worm;
}

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.util.function.NoiseProvider;
import lombok.Builder;
import lombok.Data;
@@ -34,28 +33,24 @@ public class WormIterator3 {
private int maxDistance;
private int maxIterations;
public boolean hasNext()
{
if(worm == null)
{
public boolean hasNext() {
if (worm == null) {
return true;
}
double dist = maxDistance - (Math.max(Math.max(Math.abs(worm.getX().getVelocity()),
Math.abs(worm.getZ().getVelocity())),
Math.abs(worm.getZ().getVelocity())),
Math.abs(worm.getY().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((y * y) - (worm.getY().getPosition() * worm.getY().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
+ ((y * y) - (worm.getY().getPosition() * worm.getY().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm3 next()
{
public Worm3 next() {
maxIterations--;
if(worm == null)
{
if (worm == null) {
worm = new Worm3(x, y, z, 0, 0, 0);
return worm;
}

View File

@@ -23,7 +23,9 @@ import com.volmit.iris.util.collection.KList;
import lombok.Setter;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@SuppressWarnings("ALL")
public class BurstExecutor {
@@ -48,10 +50,8 @@ public class BurstExecutor {
}
public BurstExecutor queue(List<Runnable> r) {
if(!multicore)
{
for(Runnable i : new KList<>(r))
{
if (!multicore) {
for (Runnable i : new KList<>(r)) {
i.run();
}
@@ -68,10 +68,8 @@ public class BurstExecutor {
}
public BurstExecutor queue(Runnable[] r) {
if(!multicore)
{
for(Runnable i : new KList<>(r))
{
if (!multicore) {
for (Runnable i : new KList<>(r)) {
i.run();
}
@@ -88,8 +86,7 @@ public class BurstExecutor {
}
public void complete() {
if(!multicore)
{
if (!multicore) {
return;
}
@@ -99,8 +96,7 @@ public class BurstExecutor {
}
try {
for(Future<?> i : futures)
{
for (Future<?> i : futures) {
i.get();
}

View File

@@ -23,12 +23,10 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.service.PreservationSVC;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
public class MultiBurst {
public static final MultiBurst burst = new MultiBurst();
@@ -74,13 +72,9 @@ public class MultiBurst {
}
public void burst(boolean multicore, Runnable... r) {
if(multicore)
{
if (multicore) {
burst(r);
}
else
{
} else {
sync(r);
}
}
@@ -90,19 +84,15 @@ public class MultiBurst {
}
public void burst(boolean multicore, List<Runnable> r) {
if(multicore)
{
if (multicore) {
burst(r);
}
else {
} else {
sync(r);
}
}
private void sync(List<Runnable> r) {
for(Runnable i : new KList<>(r))
{
for (Runnable i : new KList<>(r)) {
i.run();
}
}

View File

@@ -26,8 +26,7 @@ public interface IrisService extends Listener {
void onDisable();
default void postShutdown(Runnable r)
{
default void postShutdown(Runnable r) {
Iris.instance.postShutdown(r);
}
}

View File

@@ -424,11 +424,11 @@ public class VolmitSender implements CommandSender {
}
}
public void sendDecreeHelpNode(VirtualDecreeCommand i){
public void sendDecreeHelpNode(VirtualDecreeCommand i) {
if (isPlayer()) {
//@builder
String s = (
"<hover:show_text:'"+
"<hover:show_text:'" +
i.getNames().copy().reverse().convert((f) -> "<#42ecf5>" + f).toString(", ") + "\n"
+ "<#3fe05a>✎ <#6ad97d><font:minecraft:uniform>" + i.getDescription() + "<reset>\n"
+ "<#bbe03f>✒ <#a8e0a2>" + (i.isNode()
@@ -458,7 +458,7 @@ public class VolmitSender implements CommandSender {
+ (f.isRequired()
? "<#db4321>⚠ <#faa796><font:minecraft:uniform>This parameter is required."
: (f.hasDefault()
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \""+f.getParam().defaultValue()+"\" if undefined."
? "<#2181db>✔ <#78dcf0><font:minecraft:uniform>Defaults to \"" + f.getParam().defaultValue() + "\" if undefined."
: "<#a73abd>✔ <#78dcf0><font:minecraft:uniform>This parameter is optional.")) + "<reset>\n"
+ (f.isContextual() ? "<#ff9900>➱ <#ffcc00><font:minecraft:uniform>The value may be derived from environment context <reset>\n" : "")
+ "<#cc00ff>✢ <#ff33cc><font:minecraft:uniform>This parameter is of type " + f.getType().getSimpleName()

View File

@@ -29,8 +29,7 @@ public abstract class ParallelQueueJob<T> extends QueueJob<T> {
BurstExecutor b = MultiBurst.burst.burst(queue.size());
KList<T> q = queue.copy();
queue.clear();
for(T i : q)
{
for (T i : q) {
b.queue(() -> {
execute(i);
completeWork();

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.scheduling.jobs;
import com.sun.jna.platform.unix.X11;
import com.volmit.iris.util.collection.KList;
import java.util.concurrent.atomic.AtomicInteger;