Totally stable optimizations that wont cause any problems at all.

This commit is contained in:
Daniel Mills 2021-07-14 16:40:20 -04:00
parent 886553a923
commit 7d423fa49d
260 changed files with 2329 additions and 3058 deletions

View File

@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen.
**Screenshots or Video Recordings**
If applicable, add screenshots or video recordings to help explain your problem.
**Server and Plugin Informations**
**Server and Plugin Information**
- Installed plugins:
- Iris Version:
- Server Platform and Version [eg: PaperSpigot 1.16.3 #240]:

View File

@ -41,14 +41,15 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.Callable;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
public static KList<GroupedExecutor> executors = new KList<>();
public static Iris instance;
@ -142,7 +143,7 @@ public class Iris extends VolmitPlugin implements Listener {
if (tc <= 0) {
int p = Runtime.getRuntime().availableProcessors();
return p > 16 ? 16 : p < 4 ? 4 : p;
return p > 16 ? 16 : Math.max(p, 4);
}
return tc;
@ -153,7 +154,7 @@ public class Iris extends VolmitPlugin implements Listener {
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -165,7 +166,7 @@ public class Iris extends VolmitPlugin implements Listener {
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 14;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -177,7 +178,7 @@ public class Iris extends VolmitPlugin implements Listener {
int v = Integer.parseInt(Bukkit.getBukkitVersion().split("\\Q-\\E")[0].split("\\Q.\\E")[1]);
return v >= 15;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -287,19 +288,9 @@ public class Iris extends VolmitPlugin implements Listener {
J.s(() -> {
Metrics m = new Metrics(Iris.instance, 8757);
m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return ProjectManager.countUniqueDimensions();
}
}));
m.addCustomChart(new Metrics.SingleLineChart("custom_dimensions", ProjectManager::countUniqueDimensions));
m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", new Callable<String>() {
@Override
public String call() throws Exception {
return ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects";
}
}));
m.addCustomChart(new Metrics.SimplePie("using_custom_dimensions", () -> ProjectManager.countUniqueDimensions() > 0 ? "Active Projects" : "No Projects"));
});
}
}
@ -319,7 +310,7 @@ public class Iris extends VolmitPlugin implements Listener {
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) {
String dimension = IrisSettings.get().getGenerator().getDefaultWorldType();
if (id != null && !id.isEmpty()) {

View File

@ -25,6 +25,7 @@ import lombok.Data;
import java.io.File;
import java.io.IOException;
@SuppressWarnings("SynchronizeOnNonFinalField")
@Data
public class IrisSettings {
public static transient IrisSettings settings;
@ -43,6 +44,7 @@ public class IrisSettings {
return getStudio().isStudio();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isUseServerLaunchedGuis() {
return getGui().isUseServerLaunchedGuis();
}

View File

@ -127,7 +127,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
});
}
});
} catch (Throwable xe) {
} catch (Throwable ignored) {
}
}

View File

@ -43,16 +43,14 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
private boolean injectBiome(Hunk<Biome> h, int x, int y, int z, Object bb) {
try {
if (h instanceof BiomeGridHunkView) {
BiomeGridHunkView hh = (BiomeGridHunkView) h;
if (h instanceof BiomeGridHunkView hh) {
ChunkGenerator.BiomeGrid g = hh.getChunk();
if (g instanceof TerrainChunk) {
((TerrainChunk) g).getBiomeBaseInjector().setBiome(x, y, z, bb);
return true;
} else {
hh.forceBiomeBaseInto(x, y, z, bb);
return true;
}
return true;
}
} catch (Throwable e) {
e.printStackTrace();

View File

@ -41,7 +41,7 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem
public IrisEngineDecorator(Engine engine, String name, DecorationPart part) {
super(engine, name + " Decorator");
this.part = part;
this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677));
this.rng = new RNG(getSeed() + 29356788 - (part.ordinal() * 10439677L));
}
protected IrisDecorator getDecorator(IrisBiome biome, double realX, double realZ) {

View File

@ -59,7 +59,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
((Bisected) bd).setHalf(Bisected.Half.TOP);
try {
data.set(x, height + 2, z, bd);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
bd = bd.clone();

View File

@ -60,6 +60,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
getEngine().getMetrics().getPost().put(p.getMilliseconds());
}
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
private void post(int currentPostX, int currentPostZ, Hunk<BlockData> currentData, int x, int z) {
int h = getFramework().getEngineParallax().trueHeight(x, z);

View File

@ -27,6 +27,7 @@ import com.volmit.iris.util.*;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
@SuppressWarnings("ALL")
public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
private static final BlockData CAVE_AIR = B.get("CAVE_AIR");
private static final BlockData LAVA = B.get("LAVA");
@ -70,7 +71,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
private final float[] ravineCache = new float[1024];
private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, int n3, int n4, double d4, RNG bbx, Hunk<BlockData> terrain) {
private void doRavine(long seed, int tx, int tz, ChunkPosition pos, double sx, double sy, double sz, float f, float f2, float f3, @SuppressWarnings("SameParameterValue") int n3, @SuppressWarnings("SameParameterValue") int n4, @SuppressWarnings("SameParameterValue") double d4, RNG bbx, Hunk<BlockData> terrain) {
int n5;
RNG random = new RNG(seed);
double x = tx * 16 + 8;
@ -214,7 +215,7 @@ public class IrisRavineModifier extends EngineAssignedModifier<BlockData> {
}
}
private BlockPosition cSet(BlockPosition bb, double var0, double var2, double var4) {
private BlockPosition cSet(BlockPosition bb, double var0, @SuppressWarnings("SameParameterValue") double var2, double var4) {
bb.setX(MathHelper.floor(var0));
bb.setY(MathHelper.floor(var2));
bb.setZ(MathHelper.floor(var4));

View File

@ -66,7 +66,7 @@ public class CNG {
}
public ProceduralStream<Double> stream(double min, double max) {
return new FittedStream<Double>(stream(), min, max);
return new FittedStream<>(stream(), min, max);
}
public static CNG signature(RNG rng) {
@ -304,7 +304,7 @@ public class CNG {
try {
return v.get(fit(0, v.size() - 1, dim));
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@ -183,6 +183,7 @@ public class FastNoiseDouble {
m_gradientPerturbAmp = gradientPerturbAmp / 0.45;
}
@SuppressWarnings("ClassCanBeRecord")
private static class Double2 {
public final double x, y;
@ -192,6 +193,7 @@ public class FastNoiseDouble {
}
}
@SuppressWarnings("ClassCanBeRecord")
private static class Double3 {
public final double x, y, z;
@ -358,21 +360,21 @@ public class FastNoiseDouble {
hash &= 31;
double a = yd, b = zd, c = wd; // X,Y,Z
switch ((int) hash >> 3) { // OR, DEPENDING ON HIGH ORDER 2 BITS:
case 1:
case 1 -> {
a = wd;
b = xd;
c = yd;
break; // W,X,Y
case 2:
} // W,X,Y
case 2 -> {
a = zd;
b = wd;
c = xd;
break; // Z,W,X
case 3:
} // Z,W,X
case 3 -> {
a = yd;
b = zd;
c = wd;
break; // Y,Z,W
} // Y,Z,W
}
return ((hash & 4) == 0 ? -a : a) + ((hash & 2) == 0 ? -b : b) + ((hash & 1) == 0 ? -c : c);
}
@ -386,66 +388,42 @@ public class FastNoiseDouble {
case Value:
return SingleValue(m_seed, x, y, z);
case ValueFractal:
switch (m_fractalType) {
case FBM:
return SingleValueFractalFBM(x, y, z);
case Billow:
return SingleValueFractalBillow(x, y, z);
case RigidMulti:
return SingleValueFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleValueFractalFBM(x, y, z);
case Billow -> SingleValueFractalBillow(x, y, z);
case RigidMulti -> SingleValueFractalRigidMulti(x, y, z);
};
case Perlin:
return SinglePerlin(m_seed, x, y, z);
case PerlinFractal:
switch (m_fractalType) {
case FBM:
return SinglePerlinFractalFBM(x, y, z);
case Billow:
return SinglePerlinFractalBillow(x, y, z);
case RigidMulti:
return SinglePerlinFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SinglePerlinFractalFBM(x, y, z);
case Billow -> SinglePerlinFractalBillow(x, y, z);
case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z);
};
case Simplex:
return SingleSimplex(m_seed, x, y, z);
case SimplexFractal:
switch (m_fractalType) {
case FBM:
return SingleSimplexFractalFBM(x, y, z);
case Billow:
return SingleSimplexFractalBillow(x, y, z);
case RigidMulti:
return SingleSimplexFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleSimplexFractalFBM(x, y, z);
case Billow -> SingleSimplexFractalBillow(x, y, z);
case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z);
};
case Cellular:
switch (m_cellularReturnType) {
case CellValue:
case NoiseLookup:
case Distance:
return SingleCellular(x, y, z);
default:
return SingleCellular2Edge(x, y, z);
}
return switch (m_cellularReturnType) {
case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z);
default -> SingleCellular2Edge(x, y, z);
};
case WhiteNoise:
return GetWhiteNoise(x, y, z);
case Cubic:
return SingleCubic(m_seed, x, y, z);
case CubicFractal:
switch (m_fractalType) {
case FBM:
return SingleCubicFractalFBM(x, y, z);
case Billow:
return SingleCubicFractalBillow(x, y, z);
case RigidMulti:
return SingleCubicFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleCubicFractalFBM(x, y, z);
case Billow -> SingleCubicFractalBillow(x, y, z);
case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z);
};
default:
return 0;
}
@ -459,66 +437,42 @@ public class FastNoiseDouble {
case Value:
return SingleValue(m_seed, x, y);
case ValueFractal:
switch (m_fractalType) {
case FBM:
return SingleValueFractalFBM(x, y);
case Billow:
return SingleValueFractalBillow(x, y);
case RigidMulti:
return SingleValueFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleValueFractalFBM(x, y);
case Billow -> SingleValueFractalBillow(x, y);
case RigidMulti -> SingleValueFractalRigidMulti(x, y);
};
case Perlin:
return SinglePerlin(m_seed, x, y);
case PerlinFractal:
switch (m_fractalType) {
case FBM:
return SinglePerlinFractalFBM(x, y);
case Billow:
return SinglePerlinFractalBillow(x, y);
case RigidMulti:
return SinglePerlinFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SinglePerlinFractalFBM(x, y);
case Billow -> SinglePerlinFractalBillow(x, y);
case RigidMulti -> SinglePerlinFractalRigidMulti(x, y);
};
case Simplex:
return SingleSimplex(m_seed, x, y);
case SimplexFractal:
switch (m_fractalType) {
case FBM:
return SingleSimplexFractalFBM(x, y);
case Billow:
return SingleSimplexFractalBillow(x, y);
case RigidMulti:
return SingleSimplexFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleSimplexFractalFBM(x, y);
case Billow -> SingleSimplexFractalBillow(x, y);
case RigidMulti -> SingleSimplexFractalRigidMulti(x, y);
};
case Cellular:
switch (m_cellularReturnType) {
case CellValue:
case NoiseLookup:
case Distance:
return SingleCellular(x, y);
default:
return SingleCellular2Edge(x, y);
}
return switch (m_cellularReturnType) {
case CellValue, NoiseLookup, Distance -> SingleCellular(x, y);
default -> SingleCellular2Edge(x, y);
};
case WhiteNoise:
return GetWhiteNoise(x, y);
case Cubic:
return SingleCubic(m_seed, x, y);
case CubicFractal:
switch (m_fractalType) {
case FBM:
return SingleCubicFractalFBM(x, y);
case Billow:
return SingleCubicFractalBillow(x, y);
case RigidMulti:
return SingleCubicFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleCubicFractalFBM(x, y);
case Billow -> SingleCubicFractalBillow(x, y);
case RigidMulti -> SingleCubicFractalRigidMulti(x, y);
};
default:
return 0;
}
@ -574,16 +528,11 @@ public class FastNoiseDouble {
y *= m_frequency;
z *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleValueFractalFBM(x, y, z);
case Billow:
return SingleValueFractalBillow(x, y, z);
case RigidMulti:
return SingleValueFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleValueFractalFBM(x, y, z);
case Billow -> SingleValueFractalBillow(x, y, z);
case RigidMulti -> SingleValueFractalRigidMulti(x, y, z);
};
}
private double SingleValueFractalFBM(double x, double y, double z) {
@ -651,22 +600,21 @@ public class FastNoiseDouble {
double xs, ys, zs;
switch (m_longerp) {
default:
case Linear:
case Linear -> {
xs = x - x0;
ys = y - y0;
zs = z - z0;
break;
case Hermite:
}
case Hermite -> {
xs = longerpHermiteFunc(x - x0);
ys = longerpHermiteFunc(y - y0);
zs = longerpHermiteFunc(z - z0);
break;
case Qulongic:
}
case Qulongic -> {
xs = longerpQulongicFunc(x - x0);
ys = longerpQulongicFunc(y - y0);
zs = longerpQulongicFunc(z - z0);
break;
}
}
double xf00 = lerp(valCoord3D(seed, x0, y0, z0), valCoord3D(seed, x1, y0, z0), xs);
@ -684,16 +632,11 @@ public class FastNoiseDouble {
x *= m_frequency;
y *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleValueFractalFBM(x, y);
case Billow:
return SingleValueFractalBillow(x, y);
case RigidMulti:
return SingleValueFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleValueFractalFBM(x, y);
case Billow -> SingleValueFractalBillow(x, y);
case RigidMulti -> SingleValueFractalRigidMulti(x, y);
};
}
private double SingleValueFractalFBM(double x, double y) {
@ -755,19 +698,18 @@ public class FastNoiseDouble {
double xs, ys;
switch (m_longerp) {
default:
case Linear:
case Linear -> {
xs = x - x0;
ys = y - y0;
break;
case Hermite:
}
case Hermite -> {
xs = longerpHermiteFunc(x - x0);
ys = longerpHermiteFunc(y - y0);
break;
case Qulongic:
}
case Qulongic -> {
xs = longerpQulongicFunc(x - x0);
ys = longerpQulongicFunc(y - y0);
break;
}
}
double xf0 = lerp(valCoord2D(seed, x0, y0), valCoord2D(seed, x1, y0), xs);
@ -782,16 +724,11 @@ public class FastNoiseDouble {
y *= m_frequency;
z *= m_frequency;
switch (m_fractalType) {
case FBM:
return SinglePerlinFractalFBM(x, y, z);
case Billow:
return SinglePerlinFractalBillow(x, y, z);
case RigidMulti:
return SinglePerlinFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SinglePerlinFractalFBM(x, y, z);
case Billow -> SinglePerlinFractalBillow(x, y, z);
case RigidMulti -> SinglePerlinFractalRigidMulti(x, y, z);
};
}
private double SinglePerlinFractalFBM(double x, double y, double z) {
@ -859,22 +796,21 @@ public class FastNoiseDouble {
double xs, ys, zs;
switch (m_longerp) {
default:
case Linear:
case Linear -> {
xs = x - x0;
ys = y - y0;
zs = z - z0;
break;
case Hermite:
}
case Hermite -> {
xs = longerpHermiteFunc(x - x0);
ys = longerpHermiteFunc(y - y0);
zs = longerpHermiteFunc(z - z0);
break;
case Qulongic:
}
case Qulongic -> {
xs = longerpQulongicFunc(x - x0);
ys = longerpQulongicFunc(y - y0);
zs = longerpQulongicFunc(z - z0);
break;
}
}
double xd0 = x - x0;
@ -899,16 +835,11 @@ public class FastNoiseDouble {
x *= m_frequency;
y *= m_frequency;
switch (m_fractalType) {
case FBM:
return SinglePerlinFractalFBM(x, y);
case Billow:
return SinglePerlinFractalBillow(x, y);
case RigidMulti:
return SinglePerlinFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SinglePerlinFractalFBM(x, y);
case Billow -> SinglePerlinFractalBillow(x, y);
case RigidMulti -> SinglePerlinFractalRigidMulti(x, y);
};
}
private double SinglePerlinFractalFBM(double x, double y) {
@ -1002,16 +933,11 @@ public class FastNoiseDouble {
y *= m_frequency;
z *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleSimplexFractalFBM(x, y, z);
case Billow:
return SingleSimplexFractalBillow(x, y, z);
case RigidMulti:
return SingleSimplexFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleSimplexFractalFBM(x, y, z);
case Billow -> SingleSimplexFractalBillow(x, y, z);
case RigidMulti -> SingleSimplexFractalRigidMulti(x, y, z);
};
}
private double SingleSimplexFractalFBM(double x, double y, double z) {
@ -1189,16 +1115,11 @@ public class FastNoiseDouble {
x *= m_frequency;
y *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleSimplexFractalFBM(x, y);
case Billow:
return SingleSimplexFractalBillow(x, y);
case RigidMulti:
return SingleSimplexFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleSimplexFractalFBM(x, y);
case Billow -> SingleSimplexFractalBillow(x, y);
case RigidMulti -> SingleSimplexFractalRigidMulti(x, y);
};
}
private double SingleSimplexFractalFBM(double x, double y) {
@ -1421,16 +1342,11 @@ public class FastNoiseDouble {
y *= m_frequency;
z *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleCubicFractalFBM(x, y, z);
case Billow:
return SingleCubicFractalBillow(x, y, z);
case RigidMulti:
return SingleCubicFractalRigidMulti(x, y, z);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleCubicFractalFBM(x, y, z);
case Billow -> SingleCubicFractalBillow(x, y, z);
case RigidMulti -> SingleCubicFractalRigidMulti(x, y, z);
};
}
private double SingleCubicFractalFBM(double x, double y, double z) {
@ -1519,16 +1435,11 @@ public class FastNoiseDouble {
x *= m_frequency;
y *= m_frequency;
switch (m_fractalType) {
case FBM:
return SingleCubicFractalFBM(x, y);
case Billow:
return SingleCubicFractalBillow(x, y);
case RigidMulti:
return SingleCubicFractalRigidMulti(x, y);
default:
return 0;
}
return switch (m_fractalType) {
case FBM -> SingleCubicFractalFBM(x, y);
case Billow -> SingleCubicFractalBillow(x, y);
case RigidMulti -> SingleCubicFractalRigidMulti(x, y);
};
}
private double SingleCubicFractalFBM(double x, double y) {
@ -1614,14 +1525,10 @@ public class FastNoiseDouble {
y *= m_frequency;
z *= m_frequency;
switch (m_cellularReturnType) {
case CellValue:
case NoiseLookup:
case Distance:
return SingleCellular(x, y, z);
default:
return SingleCellular2Edge(x, y, z);
}
return switch (m_cellularReturnType) {
case CellValue, NoiseLookup, Distance -> SingleCellular(x, y, z);
default -> SingleCellular2Edge(x, y, z);
};
}
private double SingleCellular(double x, double y, double z) {
@ -1783,34 +1690,24 @@ public class FastNoiseDouble {
break;
}
switch (m_cellularReturnType) {
case Distance2:
return distance2 - 1;
case Distance2Add:
return distance2 + distance - 1;
case Distance2Sub:
return distance2 - distance - 1;
case Distance2Mul:
return distance2 * distance - 1;
case Distance2Div:
return distance / distance2 - 1;
default:
return 0;
}
return switch (m_cellularReturnType) {
case Distance2 -> distance2 - 1;
case Distance2Add -> distance2 + distance - 1;
case Distance2Sub -> distance2 - distance - 1;
case Distance2Mul -> distance2 * distance - 1;
case Distance2Div -> distance / distance2 - 1;
default -> 0;
};
}
public double GetCellular(double x, double y) {
x *= m_frequency;
y *= m_frequency;
switch (m_cellularReturnType) {
case CellValue:
case NoiseLookup:
case Distance:
return SingleCellular(x, y);
default:
return SingleCellular2Edge(x, y);
}
return switch (m_cellularReturnType) {
case CellValue, NoiseLookup, Distance -> SingleCellular(x, y);
default -> SingleCellular2Edge(x, y);
};
}
private double SingleCellular(double x, double y) {
@ -1949,20 +1846,14 @@ public class FastNoiseDouble {
break;
}
switch (m_cellularReturnType) {
case Distance2:
return distance2 - 1;
case Distance2Add:
return distance2 + distance - 1;
case Distance2Sub:
return distance2 - distance - 1;
case Distance2Mul:
return distance2 * distance - 1;
case Distance2Div:
return distance / distance2 - 1;
default:
return 0;
}
return switch (m_cellularReturnType) {
case Distance2 -> distance2 - 1;
case Distance2Add -> distance2 + distance - 1;
case Distance2Sub -> distance2 - distance - 1;
case Distance2Mul -> distance2 * distance - 1;
case Distance2Div -> distance / distance2 - 1;
default -> 0;
};
}
public void GradientPerturb(Vector3f v3) {
@ -1997,22 +1888,21 @@ public class FastNoiseDouble {
double xs, ys, zs;
switch (m_longerp) {
default:
case Linear:
case Linear -> {
xs = xf - x0;
ys = yf - y0;
zs = zf - z0;
break;
case Hermite:
}
case Hermite -> {
xs = longerpHermiteFunc(xf - x0);
ys = longerpHermiteFunc(yf - y0);
zs = longerpHermiteFunc(zf - z0);
break;
case Qulongic:
}
case Qulongic -> {
xs = longerpQulongicFunc(xf - x0);
ys = longerpQulongicFunc(yf - y0);
zs = longerpQulongicFunc(zf - z0);
break;
}
}
Double3 vec0 = CELL_3D[(int) hash3D(seed, x0, y0, z0) & 255];
@ -2081,19 +1971,18 @@ public class FastNoiseDouble {
double xs, ys;
switch (m_longerp) {
default:
case Linear:
case Linear -> {
xs = xf - x0;
ys = yf - y0;
break;
case Hermite:
}
case Hermite -> {
xs = longerpHermiteFunc(xf - x0);
ys = longerpHermiteFunc(yf - y0);
break;
case Qulongic:
}
case Qulongic -> {
xs = longerpQulongicFunc(xf - x0);
ys = longerpQulongicFunc(yf - y0);
break;
}
}
Double2 vec0 = CELL_2D[(int) hash2D(seed, x0, y0) & 255];

View File

@ -46,46 +46,44 @@ public class ConversionManager {
converters = new KList<>();
J.s(() ->
{
J.attemptAsync(() ->
{
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
converters.add(new Converter() {
@Override
public String getOutExtension() {
return "iob";
}
J.attemptAsync(() ->
{
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
converters.add(new Converter() {
@Override
public String getOutExtension() {
return "iob";
}
@Override
public String getInExtension() {
return "schem";
}
@Override
public String getInExtension() {
return "schem";
}
@Override
public void convert(File in, File out) {
SKConversion.convertSchematic(in, out);
}
});
@Override
public void convert(File in, File out) {
SKConversion.convertSchematic(in, out);
}
});
converters.add(new Converter() {
@Override
public String getOutExtension() {
return "iob";
}
converters.add(new Converter() {
@Override
public String getOutExtension() {
return "iob";
}
@Override
public String getInExtension() {
return "schematic";
}
@Override
public String getInExtension() {
return "schematic";
}
@Override
public void convert(File in, File out) {
SKConversion.convertSchematic(in, out);
}
});
}
});
}, 5);
@Override
public void convert(File in, File out) {
SKConversion.convertSchematic(in, out);
}
});
}
}), 5);
}
private String toPoolName(String poolReference) {
@ -136,22 +134,22 @@ public class ConversionManager {
if (compound.containsKey("blocks") && compound.containsKey("palette") && compound.containsKey("size")) {
String id = in.toURI().relativize(folder.toURI()).getPath() + file.getName().split("\\Q.\\E")[0];
ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size");
@SuppressWarnings("unchecked") ListTag<IntTag> size = (ListTag<IntTag>) compound.getListTag("size");
int w = size.get(0).asInt();
int h = size.get(1).asInt();
int d = size.get(2).asInt();
KList<BlockData> palette = new KList<>();
ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) compound.getListTag("palette");
@SuppressWarnings("unchecked") ListTag<CompoundTag> paletteList = (ListTag<CompoundTag>) compound.getListTag("palette");
for (int i = 0; i < paletteList.size(); i++) {
CompoundTag cp = paletteList.get(i);
palette.add(DirectWorldWriter.getBlockData(cp));
}
IrisJigsawPiece piece = new IrisJigsawPiece();
IrisObject object = new IrisObject(w, h, d);
ListTag<CompoundTag> blockList = (ListTag<CompoundTag>) compound.getListTag("blocks");
@SuppressWarnings("unchecked") ListTag<CompoundTag> blockList = (ListTag<CompoundTag>) compound.getListTag("blocks");
for (int i = 0; i < blockList.size(); i++) {
CompoundTag cp = blockList.get(i);
ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos");
@SuppressWarnings("unchecked") ListTag<IntTag> pos = (ListTag<IntTag>) cp.getListTag("pos");
int x = pos.get(0).asInt();
int y = pos.get(1).asInt();
int z = pos.get(2).asInt();

View File

@ -35,8 +35,8 @@ public class IrisBoardManager implements BoardProvider, Listener {
private final BoardManager manager;
private String mem = "...";
public RollingSequence hits = new RollingSequence(20);
public RollingSequence tp = new RollingSequence(100);
public final RollingSequence hits = new RollingSequence(20);
public final RollingSequence tp = new RollingSequence(100);
private final ChronoLatch cl = new ChronoLatch(1000);
@ -105,9 +105,9 @@ public class IrisBoardManager implements BoardProvider, Listener {
parallaxRegions += g.getCompound().getEngine(i).getParallax().getRegionCount();
parallaxChunks += g.getCompound().getEngine(i).getParallax().getChunkCount();
loadedObjects += g.getCompound().getData().getObjectLoader().getSize();
memoryGuess += g.getCompound().getData().getObjectLoader().getTotalStorage() * 225;
memoryGuess += parallaxChunks * 3500;
memoryGuess += parallaxRegions * 1700000;
memoryGuess += g.getCompound().getData().getObjectLoader().getTotalStorage() * 225L;
memoryGuess += parallaxChunks * 3500L;
memoryGuess += parallaxRegions * 1700000L;
}
tp.put(0); // TODO: CHUNK SPEED

View File

@ -41,6 +41,7 @@ import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
@SuppressWarnings("ALL")
@Data
public class IrisProject {
private File path;
@ -122,21 +123,18 @@ public class IrisProject {
}
private KList<Report> scanForErrors(IrisBiome biome, IrisObjectPlacement i) {
KList<Report> reports = new KList<>();
return reports;
return new KList<>();
}
private KList<Report> scanForErrors(IrisBiome biome, IrisBiomePaletteLayer i) {
KList<Report> reports = new KList<>();
return reports;
return new KList<>();
}
private KList<Report> scanForErrorsSeaLayers(IrisBiome biome, IrisBiomePaletteLayer i) {
KList<Report> reports = new KList<>();
return reports;
return new KList<>();
}
public boolean isOpen() {

View File

@ -30,7 +30,6 @@ import org.zeroturnaround.zip.ZipUtil;
import org.zeroturnaround.zip.commons.FileUtils;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.UUID;
@ -53,7 +52,7 @@ public class ProjectManager {
if (m != null) {
try {
IO.copyFile(m, ignore);
} catch (IOException e) {
} catch (IOException ignored) {
}
}
@ -63,7 +62,8 @@ public class ProjectManager {
}
public static int countUniqueDimensions() {
int vv = counter.aquire(() -> {
return counter.aquire(() -> {
int v = 0;
try {
@ -82,8 +82,6 @@ public class ProjectManager {
return v;
});
return vv;
}
public IrisDimension installIntoWorld(MortarSender sender, String type, File folder) {
@ -106,7 +104,7 @@ public class ProjectManager {
try {
FileUtils.copyDirectory(f, irispack);
} catch (IOException e) {
} catch (IOException ignored) {
}
}
@ -192,12 +190,13 @@ public class ProjectManager {
} catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(
"Issue when unpacking. Please check/do the following:" +
"\n1. Do you have a functioning internet connection?" +
"\n2. Did the download corrupt?" +
"\n3. Try deleting the */plugins/iris/packs folder and re-download." +
"\n4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld" +
"\n5. Contact support (if all other options do not help)"
"""
Issue when unpacking. Please check/do the following:
1. Do you have a functioning internet connection?
2. Did the download corrupt?
3. Try deleting the */plugins/iris/packs folder and re-download.
4. Download the pack from the GitHub repo: https://github.com/IrisDimensions/overworld
5. Contact support (if all other options do not help)"""
);
}
File dir = null;
@ -352,12 +351,7 @@ public class ProjectManager {
}
try {
FileUtils.copyDirectory(importPack, newPack, new FileFilter() {
@Override
public boolean accept(File pathname) {
return !pathname.getAbsolutePath().contains(".git");
}
}, false);
FileUtils.copyDirectory(importPack, newPack, pathname -> !pathname.getAbsolutePath().contains(".git"), false);
} catch (IOException e) {
e.printStackTrace();
}

File diff suppressed because it is too large Load Diff

View File

@ -127,7 +127,7 @@ public class WandManager implements Listener {
}
Location lv = new Location(d[0].getWorld(), j, k, l).clone().add(0.5, 0.5, 0.5).clone().add(push);
Color color = Color.getHSBColor((float) (0.5f + (Math.sin((j + k + l + (p.getTicksLived() / 2)) / 20f) / 2)), 1, 1);
Color color = Color.getHSBColor((float) (0.5f + (Math.sin((j + k + l + (p.getTicksLived() / 2f)) / 20f) / 2)), 1, 1);
int r = color.getRed();
int g = color.getGreen();
int b = color.getBlue();

View File

@ -47,6 +47,7 @@ public class CommandIrisDownload extends MortarCommand {
for (String i : args) {
if (i.equals("-t") || i.equals("--trim")) {
trim = true;
break;
}
}

View File

@ -59,7 +59,7 @@ public class CommandIrisObjectContract extends MortarCommand {
return true;
}
int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1;
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();

View File

@ -59,7 +59,7 @@ public class CommandIrisObjectExpand extends MortarCommand {
return true;
}
int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1;
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();

View File

@ -79,6 +79,7 @@ public class CommandIrisObjectPaste extends MortarCommand {
for (String i : args) {
if (i.equalsIgnoreCase("-edit")) {
intoWand = true;
break;
}
}

View File

@ -69,6 +69,7 @@ public class CommandIrisObjectSave extends MortarCommand {
for (String i : args) {
if (i.equals("-o")) {
overwrite = true;
break;
}
}

View File

@ -59,7 +59,7 @@ public class CommandIrisObjectShift extends MortarCommand {
return true;
}
int amt = args.length == 1 ? Integer.valueOf(args[0]) : 1;
int amt = args.length == 1 ? Integer.parseInt(args[0]) : 1;
Location[] b = WandManager.getCuboid(p.getInventory().getItemInMainHand());
Location a1 = b[0].clone();
Location a2 = b[1].clone();

View File

@ -90,7 +90,7 @@ public class CommandIrisStudioLoot extends MortarCommand {
boolean fast = ffast;
boolean add = fadd;
O<Integer> ta = new O<Integer>();
O<Integer> ta = new O<>();
ta.set(-1);
ta.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () ->

View File

@ -58,6 +58,7 @@ public class CommandIrisStudioPackage extends MortarCommand {
for (String i : args) {
if (i.equalsIgnoreCase("-o")) {
o = true;
break;
}
}

View File

@ -113,12 +113,7 @@ public class CommandIrisStudioProfile extends MortarCommand {
in.setFunction(i);
in.setHorizontalScale(8);
NoiseProvider np = new NoiseProvider() {
@Override
public double noise(double x, double z) {
return Math.random();
}
};
NoiseProvider np = (x, z) -> Math.random();
for (int j = 0; j < 3000; j++) {
in.interpolate(j, -j, np);

View File

@ -63,7 +63,7 @@ public class CommandIrisWhatBiome extends MortarCommand {
if (p.getLocation().getBlock().getBiome().equals(Biome.CUSTOM)) {
try {
sender.sendMessage("Data Pack Biome: " + INMS.get().getTrueBiomeBaseKey(p.getLocation()) + " (ID: " + INMS.get().getTrueBiomeBaseId(INMS.get().getTrueBiomeBase(p.getLocation())) + ")");
} catch (Throwable ex) {
} catch (Throwable ignored) {
}
}

View File

@ -54,6 +54,7 @@ public class CommandIrisWhatObjects extends MortarCommand {
}
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
@Override
public boolean handle(MortarSender sender, String[] args) {
if (sender.isPlayer()) {
@ -78,7 +79,7 @@ public class CommandIrisWhatObjects extends MortarCommand {
int cz = l.getChunk().getZ();
new Spiraler(3, 3, (x, z) -> chunks.addIfMissing(world.getChunkAt(x + cx, z + cz))).drain();
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -218,6 +219,7 @@ public class CommandIrisWhatObjects extends MortarCommand {
objects.compute(n1, (k1, v1) ->
{
//noinspection ReplaceNullCheck
if (v1 == null) {
return new KMap<>();
}

View File

@ -60,24 +60,28 @@ public class CommandIrisCreate extends MortarCommand {
String pre = split[0].toLowerCase();
if (pre.equals("type")) {
for (String s : Iris.proj.getListing(true).keySet()) {
list.add("type=" + s);
switch (pre) {
case "type" -> {
for (String s : Iris.proj.getListing(true).keySet()) {
list.add("type=" + s);
}
if (!list.contains("type=overworld")) {
list.contains("type=overworld");
}
}
if (!list.contains("type=overworld")) {
list.contains("type=overworld");
case "seed" -> {
list.add("seed=1337");
list.add("seed=" + new Random().nextInt());
list.add("seed=random");
}
case "pregen" -> {
list.add("500");
list.add("1000");
list.add("2000");
list.add("5k");
list.add("10k");
list.add("25k");
}
} else if (pre.equals("seed")) {
list.add("seed=1337");
list.add("seed=" + new Random().nextInt());
list.add("seed=random");
} else if (pre.equals("pregen")) {
list.add("500");
list.add("1000");
list.add("2000");
list.add("5k");
list.add("10k");
list.add("25k");
}
}
@ -129,13 +133,13 @@ public class CommandIrisCreate extends MortarCommand {
sender.sendMessage("You must remember to either have multiverse installed or use the Bukkit method, otherwise the world will go corrupt!");
sender.sendMessage("Wiki: https://volmitsoftware.gitbook.io/iris/getting-started");
O<Boolean> b = new O<Boolean>();
O<Boolean> b = new O<>();
b.set(true);
if (sender.isPlayer()) {
try {
sender.player().teleport(world.get().getSpawnLocation());
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@ -148,9 +152,7 @@ public class CommandIrisCreate extends MortarCommand {
sender.sendMessage("Expect server lag during this time. Use '/iris pregen stop' to cancel");
new Pregenerator(world.get(), size, () ->
{
b.set(true);
});
b.set(true));
}
World ww = world.get();

View File

@ -47,7 +47,7 @@ public class CommandIrisFix extends MortarCommand {
return true;
}
int viewDistance = args.length > 0 ? Integer.valueOf(args[0]) : -1;
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());

View File

@ -33,10 +33,11 @@ public class CommandIrisPregen extends MortarCommand {
public CommandIrisPregen() {
super("pregen", "preg", "p");
setDescription(
"Pregen this world with optional parameters: " +
"\n'1k' = 1000 by 1000 blocks, '1c' = 1 by 1 chunks, and '1r' = 32 by 32 chunks." +
"\nIf you are using the console or want to pregen a world you're not in:" +
"\nalso specify the name of the world. E.g. /ir pregen 5k world"
"""
Pregen this world with optional parameters:\s
'1k' = 1000 by 1000 blocks, '1c' = 1 by 1 chunks, and '1r' = 32 by 32 chunks.
If you are using the console or want to pregen a world you're not in:
also specify the name of the world. E.g. /ir pregen 5k world"""
);
requiresPermission(Iris.perm.studio);
setCategory("Pregen");

View File

@ -48,6 +48,7 @@ public class CommandIrisUpdateWorld extends MortarCommand {
for (String i : args) {
if (i.equalsIgnoreCase("--fresh-download")) {
fresh = true;
break;
}
}

View File

@ -31,7 +31,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import java.util.Arrays;
public class CommandLocate extends MortarCommand implements Listener {
CommandLocate instance;
final CommandLocate instance;
@EventHandler
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) {

View File

@ -28,6 +28,7 @@ import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@SuppressWarnings("InstantiationOfUtilityClass")
public class BlockSignal {
public static void of(Block block, int ticks) {
new BlockSignal(block, ticks);

View File

@ -23,6 +23,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
@SuppressWarnings("ClassCanBeRecord")
public class BukkitBlockEditor implements BlockEditor {
private final World world;

View File

@ -26,6 +26,7 @@ import lombok.Data;
import org.bukkit.World;
import org.bukkit.block.Block;
@SuppressWarnings("ALL")
@Data
public class DustRevealer {
private final ParallaxAccess parallax;

View File

@ -62,7 +62,6 @@ public class WEBlockEditor implements BlockEditor {
@Override
public void close() {
es.close();
return;
}
@Override

View File

@ -24,6 +24,7 @@ import org.bukkit.Material;
import java.awt.image.BufferedImage;
@SuppressWarnings("ClassCanBeRecord")
public class IrisRenderer {
private final Renderer renderer;

View File

@ -32,12 +32,10 @@ import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class IrisVision extends JPanel implements MouseWheelListener {
private static final long serialVersionUID = 2094606939770332040L;
@ -63,38 +61,32 @@ public class IrisVision extends JPanel implements MouseWheelListener {
private final KMap<BlockPosition, BufferedImage> fastpositions = new KMap<>();
private final KSet<BlockPosition> working = new KSet<>();
private final KSet<BlockPosition> workingfast = new KSet<>();
private final ExecutorService e = Executors.newFixedThreadPool(8, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
tid++;
Thread t = new Thread(r);
t.setName("Iris HD Renderer " + tid);
t.setPriority(Thread.MIN_PRIORITY);
t.setUncaughtExceptionHandler((et, e) ->
{
Iris.info("Exception encountered in " + et.getName());
e.printStackTrace();
});
private final ExecutorService e = Executors.newFixedThreadPool(8, r -> {
tid++;
Thread t = new Thread(r);
t.setName("Iris HD Renderer " + tid);
t.setPriority(Thread.MIN_PRIORITY);
t.setUncaughtExceptionHandler((et, e) ->
{
Iris.info("Exception encountered in " + et.getName());
e.printStackTrace();
});
return t;
}
return t;
});
private final ExecutorService eh = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
tid++;
Thread t = new Thread(r);
t.setName("Iris Renderer " + tid);
t.setPriority(Thread.NORM_PRIORITY);
t.setUncaughtExceptionHandler((et, e) ->
{
Iris.info("Exception encountered in " + et.getName());
e.printStackTrace();
});
private final ExecutorService eh = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), r -> {
tid++;
Thread t = new Thread(r);
t.setName("Iris Renderer " + tid);
t.setPriority(Thread.NORM_PRIORITY);
t.setUncaughtExceptionHandler((et, e) ->
{
Iris.info("Exception encountered in " + et.getName());
e.printStackTrace();
});
return t;
}
return t;
});
public IrisVision() {
@ -241,12 +233,7 @@ public class IrisVision extends JPanel implements MouseWheelListener {
BufferedImage t = getTile(gg, iscale, Math.floorDiv((posX / iscale) + i, iscale) * iscale, Math.floorDiv((posZ / iscale) + j, iscale) * iscale, m);
if (t != null) {
g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), iscale, iscale, new ImageObserver() {
@Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
return true;
}
});
g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), iscale, iscale, (img, infoflags, x, y, width, height) -> true);
}
}
}
@ -298,7 +285,7 @@ public class IrisVision extends JPanel implements MouseWheelListener {
if (file != null) {
try {
frame.setIconImage(ImageIO.read(file));
} catch (IOException e) {
} catch (IOException ignored) {
}
}
@ -306,9 +293,7 @@ public class IrisVision extends JPanel implements MouseWheelListener {
public static void launch(IrisAccess g, int i) {
J.a(() ->
{
createAndShowGUI((x, z) -> g.getEngineAccess(i).draw(x, z), i, g.getCompound().getWorld());
});
createAndShowGUI((x, z) -> g.getEngineAccess(i).draw(x, z), i, g.getCompound().getWorld()));
}
public void mouseWheelMoved(MouseWheelEvent e) {
@ -321,6 +306,6 @@ public class IrisVision extends JPanel implements MouseWheelListener {
positions.clear();
fastpositions.clear();
mscale = mscale + ((0.044 * mscale) * notches);
mscale = mscale < 0.00001 ? 0.00001 : mscale;
mscale = Math.max(mscale, 0.00001);
}
}

View File

@ -37,12 +37,16 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener {
private static final long serialVersionUID = 2094606939770332040L;
static JComboBox<String> combo;
@SuppressWarnings("CanBeFinal")
RollingSequence r = new RollingSequence(90);
@SuppressWarnings("CanBeFinal")
boolean colorMode = true;
double scale = 1;
@SuppressWarnings("CanBeFinal")
static boolean hd = false;
static double ascale = 10;
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
@SuppressWarnings("CanBeFinal")
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer");
ReentrantLock l = new ReentrantLock();
int[][] co;
@ -57,6 +61,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener {
double mz = 0;
static double mxx = 0;
static double mzz = 0;
@SuppressWarnings("CanBeFinal")
static boolean down = false;
double lx = Double.MAX_VALUE; //MouseX
double lz = Double.MAX_VALUE; //MouseY
@ -154,8 +159,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener {
accuracy = down ? accuracy * 4 : accuracy;
int v = 1000;
if (g instanceof Graphics2D) {
Graphics2D gg = (Graphics2D) g;
if (g instanceof Graphics2D gg) {
if (getParent().getWidth() != w || getParent().getHeight() != h) {
w = getParent().getWidth();
@ -250,8 +254,8 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener {
JFrame frame = new JFrame("Noise Explorer");
NoiseExplorer nv = new NoiseExplorer();
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
KList<String> li = new KList<NoiseStyle>(NoiseStyle.values()).toStringList();
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
KList<String> li = new KList<>(NoiseStyle.values()).toStringList();
combo = new JComboBox<>(li.toArray(new String[0]));
combo.setSelectedItem("STATIC");
combo.setFocusable(false);
combo.addActionListener(e -> {
@ -284,7 +288,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener {
}
public static void launch() {
EventQueue.invokeLater(() -> createAndShowGUI());
EventQueue.invokeLater(NoiseExplorer::createAndShowGUI);
}
static class HandScrollListener extends MouseAdapter {

View File

@ -40,8 +40,7 @@ public class BKLink {
}
public Plugin getBK() {
Plugin p = Bukkit.getPluginManager().getPlugin("BKCommonLib");
return p;
return Bukkit.getPluginManager().getPlugin("BKCommonLib");
}
}

View File

@ -30,21 +30,8 @@ public class CitizensLink {
return getCitizens() != null;
}
// public Entity spawn(EntityType type, String npcType, Location a)
// {
// if(!supported())
// {
// return null;
// }
//
// NPC npc = CitizensAPI.getNPCRegistry().createNPC(type, "");
// npc.spawn(a);
// return npc.getEntity();
// }
public Plugin getCitizens() {
Plugin p = Bukkit.getPluginManager().getPlugin("Citizens");
return p;
return Bukkit.getPluginManager().getPlugin("Citizens");
}
}

View File

@ -118,9 +118,8 @@ public class MultiverseCoreLink {
}
public Plugin getMultiverse() {
Plugin p = Bukkit.getPluginManager().getPlugin("Multiverse-Core");
return p;
return Bukkit.getPluginManager().getPlugin("Multiverse-Core");
}
public String envName(World.Environment environment) {
@ -128,15 +127,12 @@ public class MultiverseCoreLink {
return "normal";
}
switch (environment) {
case NORMAL:
return "normal";
case NETHER:
return "nether";
case THE_END:
return "end";
}
return switch (environment) {
case NORMAL -> "normal";
case NETHER -> "nether";
case THE_END -> "end";
default -> environment.toString().toLowerCase();
};
return environment.toString().toLowerCase();
}
}

View File

@ -55,12 +55,11 @@ public class MythicMobsLink {
}
}
return v.toArray(new String[v.size()]);
return v.toArray(new String[0]);
}
public Plugin getMythicMobs() {
Plugin p = Bukkit.getPluginManager().getPlugin("MythicMobs");
return p;
return Bukkit.getPluginManager().getPlugin("MythicMobs");
}
}

View File

@ -102,6 +102,7 @@ public class NMSBinding17_1 implements INMSBinding {
return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.aO, new MinecraftKey(mckey)));
}
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Override
public String getKeyForBiomeBase(Object biomeBase) {
return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString();
@ -125,6 +126,7 @@ public class NMSBinding17_1 implements INMSBinding {
try {
Method f = from.getClass().getDeclaredMethod(name, classify(par));
f.setAccessible(true);
//noinspection unchecked
return (T) f.invoke(from, par);
} catch (Throwable e) {
e.printStackTrace();
@ -137,6 +139,7 @@ public class NMSBinding17_1 implements INMSBinding {
try {
Method f = from.getDeclaredMethod(name, classify(par));
f.setAccessible(true);
//noinspection unchecked
return (T) f.invoke(null, par);
} catch (Throwable e) {
e.printStackTrace();
@ -149,6 +152,7 @@ public class NMSBinding17_1 implements INMSBinding {
try {
Field f = from.getClass().getDeclaredField(name);
f.setAccessible(true);
//noinspection unchecked
return (T) f.get(from);
} catch (Throwable e) {
e.printStackTrace();
@ -161,6 +165,7 @@ public class NMSBinding17_1 implements INMSBinding {
try {
Field f = t.getDeclaredField(name);
f.setAccessible(true);
//noinspection unchecked
return (T) f.get(null);
} catch (Throwable e) {
e.printStackTrace();
@ -176,11 +181,13 @@ public class NMSBinding17_1 implements INMSBinding {
if (v != null) {
return v;
}
//noinspection unchecked
v = org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry<BiomeBase>) registry, biome);
if (v == null) {
// Ok so there is this new biome name called "CUSTOM" in Paper's new releases.
// But, this does NOT exist within CraftBukkit which makes it return an error.
// So, we will just return the ID that the plains biome returns instead.
//noinspection unchecked
return org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock.biomeToBiomeBase((IRegistry<BiomeBase>) registry, Biome.PLAINS);
}
baseBiomeCache.put(biome, v);
@ -204,7 +211,7 @@ public class NMSBinding17_1 implements INMSBinding {
@Override
public int countCustomBiomes() {
AtomicInteger a = new AtomicInteger(0);
getCustomBiomeRegistry().d().stream().forEach((i) -> {
getCustomBiomeRegistry().d().forEach((i) -> {
MinecraftKey k = i.getKey().a();
if (k.getNamespace().equals("minecraft")) {

View File

@ -34,10 +34,12 @@ public enum CarvingMode {
ANYWHERE;
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean supportsCarving() {
return this.equals(ANYWHERE) || this.equals(CARVING_ONLY);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean supportsSurface() {
return this.equals(ANYWHERE) || this.equals(SURFACE_ONLY);
}

View File

@ -35,6 +35,7 @@ import org.bukkit.block.data.BlockData;
import java.awt.*;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@ -166,15 +167,15 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@ArrayType(min = 1, type = IrisBiomePaletteLayer.class)
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
private KList<IrisBiomePaletteLayer> seaLayers = new KList<IrisBiomePaletteLayer>();
private KList<IrisBiomePaletteLayer> seaLayers = new KList<>();
@ArrayType(min = 1, type = IrisDecorator.class)
@Desc("Decorators are used for things like tall grass, bisected flowers, and even kelp or cactus (random heights)")
private KList<IrisDecorator> decorators = new KList<IrisDecorator>();
private KList<IrisDecorator> decorators = new KList<>();
@ArrayType(min = 1, type = IrisObjectPlacement.class)
@Desc("Objects define what schematics (iob files) iris will place in this biome")
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
private KList<IrisObjectPlacement> objects = new KList<>();
@Required
@ArrayType(min = 1, type = IrisBiomeGeneratorLink.class)
@ -307,9 +308,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public CNG getBiomeGenerator(RNG random) {
return biomeGenerator.aquire(() ->
{
return biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()));
});
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())));
}
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
@ -403,7 +402,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
for (int i = 0; i < maxDepth; i++) {
int offset = (255 - height) - i;
int index = offset % data.size();
real.add(data.get(index < 0 ? 0 : index));
real.add(data.get(Math.max(index, 0)));
}
return real;
@ -521,6 +520,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return isSea() || isLake() || isRiver();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isShore() {
if (inferredType == null) {
return false;
@ -569,12 +569,11 @@ public class IrisBiome extends IrisRegistrant implements IRare {
if (limit > 0) {
for (String i : getChildren()) {
IrisBiome b = g.getData().getBiomeLoader().load(i);
int l = limit;
m.addAll(b.getAllChildren(g, l));
m.addAll(b.getAllChildren(g, limit));
}
}
return new KList<String>(m);
return new KList<>(m);
}
//TODO: Test

View File

@ -60,7 +60,7 @@ public class IrisBiomeMutation {
@RegistryListObject
@ArrayType(min = 1, type = IrisObjectPlacement.class)
@Desc("Objects define what schematics (iob files) iris will place in this biome mutation")
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
private KList<IrisObjectPlacement> objects = new KList<>();
private final transient AtomicCache<KList<String>> sideACache = new AtomicCache<>();
private final transient AtomicCache<KList<String>> sideBCache = new AtomicCache<>();
@ -77,24 +77,26 @@ public class IrisBiomeMutation {
KSet<String> r = new KSet<>();
for (String i : s) {
String q = i;
if (q.startsWith("^")) {
r.addAll(xg.getData().getRegionLoader().load(q.substring(1)).getLandBiomes());
continue;
} else if (q.startsWith("*")) {
String name = q.substring(1);
if (i.startsWith("^")) {
r.addAll(xg.getData().getRegionLoader().load(i.substring(1)).getLandBiomes());
} else if (i.startsWith("*")) {
String name = i.substring(1);
r.addAll(xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7));
} else if (q.startsWith("!")) {
r.remove(q.substring(1));
} else if (q.startsWith("!*")) {
String name = q.substring(2);
r.removeAll(xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7));
} else if (i.startsWith("!")) {
r.remove(i.substring(1));
} else if (i.startsWith("!*")) {
String name = i.substring(2);
for(String g : xg.getData().getBiomeLoader().load(name).getAllChildren(xg, 7))
{
r.remove(g);
}
} else {
r.add(q);
r.add(i);
}
}
return new KList<String>(r);
return new KList<>(r);
}
}

View File

@ -29,6 +29,9 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import java.util.Map;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@ -77,8 +80,8 @@ public class IrisBlockData extends IrisRegistrant {
KList<String> r = new KList<>();
for (String i : data.keySet()) {
r.add(i + "=" + filter(data.get(i).toString()));
for (Map.Entry<String, Object> entry : data.entrySet()) {
r.add(entry.getKey() + "=" + filter(entry.getValue().toString()));
}
return "[" + r.toString(",") + "]";
@ -194,13 +197,13 @@ public class IrisBlockData extends IrisRegistrant {
try {
return Integer.valueOf(string);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
try {
return Double.valueOf(string).intValue();
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@ -37,7 +37,7 @@ public class IrisBlockDrops {
@Required
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The blocks that drop loot")
private KList<IrisBlockData> blocks = new KList<IrisBlockData>();
private KList<IrisBlockData> blocks = new KList<>();
@Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.")

View File

@ -65,7 +65,7 @@ public class IrisColor {
String v = (hex.startsWith("#") ? hex : "#" + hex).trim();
try {
return Color.decode(v);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@ -89,8 +89,8 @@ public class IrisColor {
int g = 0;
int b = 0;
for (int i = 0; i < c.length; i++) {
int rgb = c[i].getRGB();
for (Color value : c) {
int rgb = value.getRGB();
int a1 = (rgb >> 24 & 0xff);
int r1 = ((rgb & 0xff0000) >> 16);
int g1 = ((rgb & 0xff00) >> 8);

View File

@ -167,8 +167,6 @@ public class IrisCompat {
}
} catch (JsonSyntaxException e) {
e.printStackTrace();
} catch (IOException e) {
throw e;
}
return def;

View File

@ -83,7 +83,7 @@ public class IrisDecorator {
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The palette of blocks used at the very top of a 'stackMax' of higher than 1. For example, bamboo tops.")
private KList<IrisBlockData> topPalette = new KList<IrisBlockData>();
private KList<IrisBlockData> topPalette = new KList<>();
@DependsOn("topPalette")
@MinNumber(0.01)
@ -107,9 +107,7 @@ public class IrisDecorator {
public CNG getHeightGenerator(RNG rng, IrisDataManager data) {
return heightGenerator.aquire(() ->
{
return heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin));
});
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin)));
}
public CNG getGenerator(RNG rng, IrisDataManager data) {
@ -223,6 +221,7 @@ public class IrisDecorator {
});
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isStacking() {
return getStackMax() > 1;
}

View File

@ -75,7 +75,7 @@ public class IrisDepositGenerator {
@Required
@ArrayType(min = 1, type = IrisBlockData.class)
@Desc("The palette of blocks to be used in this deposit generator")
private KList<IrisBlockData> palette = new KList<IrisBlockData>();
private KList<IrisBlockData> palette = new KList<>();
@MinNumber(1)
@MaxNumber(64)

View File

@ -36,6 +36,7 @@ import org.bukkit.block.data.BlockData;
import java.io.File;
import java.io.IOException;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@ -483,12 +484,14 @@ public class IrisDimension extends IrisRegistrant {
if (write) {
File mcm = new File(datapacks, "iris/pack.mcmeta");
try {
IO.writeAll(mcm, "{\n" +
" \"pack\": {\n" +
" \"description\": \"Iris Data Pack. This pack contains all installed Iris Packs' resources.\",\n" +
" \"pack_format\": 7\n" +
" }\n" +
"}\n");
IO.writeAll(mcm, """
{
"pack": {
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
"pack_format": 7
}
}
""");
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -28,6 +28,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -25,6 +25,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Jigsaw;
import org.bukkit.util.Vector;
import java.util.Map;
/**
* Directions
*
@ -47,35 +49,15 @@ public enum IrisDirection {
private final CuboidDirection f;
public static IrisDirection getDirection(BlockFace f) {
switch (f) {
case DOWN:
return DOWN_NEGATIVE_Y;
case EAST:
case EAST_NORTH_EAST:
case EAST_SOUTH_EAST:
return EAST_POSITIVE_X;
case NORTH:
case NORTH_NORTH_WEST:
case NORTH_EAST:
case NORTH_NORTH_EAST:
case NORTH_WEST:
return NORTH_NEGATIVE_Z;
case SELF:
case UP:
return UP_POSITIVE_Y;
case SOUTH:
case SOUTH_EAST:
case SOUTH_SOUTH_EAST:
case SOUTH_SOUTH_WEST:
case SOUTH_WEST:
return SOUTH_POSITIVE_Z;
case WEST:
case WEST_NORTH_WEST:
case WEST_SOUTH_WEST:
return WEST_NEGATIVE_X;
}
return switch (f) {
case DOWN -> DOWN_NEGATIVE_Y;
case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X;
case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z;
case SELF, UP -> UP_POSITIVE_Y;
case SOUTH, SOUTH_EAST, SOUTH_SOUTH_EAST, SOUTH_SOUTH_WEST, SOUTH_WEST -> SOUTH_POSITIVE_Z;
case WEST, WEST_NORTH_WEST, WEST_SOUTH_WEST -> WEST_NEGATIVE_X;
};
return DOWN_NEGATIVE_Y;
}
public static IrisDirection fromJigsawBlock(String direction) {
@ -90,46 +72,26 @@ public enum IrisDirection {
}
public static IrisDirection getDirection(Jigsaw.Orientation orientation) {
switch (orientation) {
case DOWN_EAST:
case UP_EAST:
case EAST_UP:
return EAST_POSITIVE_X;
case DOWN_NORTH:
case UP_NORTH:
case NORTH_UP:
return NORTH_NEGATIVE_Z;
case DOWN_SOUTH:
case UP_SOUTH:
case SOUTH_UP:
return SOUTH_POSITIVE_Z;
case DOWN_WEST:
case UP_WEST:
case WEST_UP:
return WEST_NEGATIVE_X;
}
return switch (orientation) {
case DOWN_EAST, UP_EAST, EAST_UP -> EAST_POSITIVE_X;
case DOWN_NORTH, UP_NORTH, NORTH_UP -> NORTH_NEGATIVE_Z;
case DOWN_SOUTH, UP_SOUTH, SOUTH_UP -> SOUTH_POSITIVE_Z;
case DOWN_WEST, UP_WEST, WEST_UP -> WEST_NEGATIVE_X;
};
return null;
}
@Override
public String toString() {
switch (this) {
case DOWN_NEGATIVE_Y:
return "Down";
case EAST_POSITIVE_X:
return "East";
case NORTH_NEGATIVE_Z:
return "North";
case SOUTH_POSITIVE_Z:
return "South";
case UP_POSITIVE_Y:
return "Up";
case WEST_NEGATIVE_X:
return "West";
}
return switch (this) {
case DOWN_NEGATIVE_Y -> "Down";
case EAST_POSITIVE_X -> "East";
case NORTH_NEGATIVE_Z -> "North";
case SOUTH_POSITIVE_Z -> "South";
case UP_POSITIVE_Y -> "Up";
case WEST_NEGATIVE_X -> "West";
};
return "?";
}
public boolean isVertical() {
@ -209,9 +171,10 @@ public enum IrisDirection {
public Vector angle(Vector initial, IrisDirection d) {
calculatePermutations();
for (GBiset<IrisDirection, IrisDirection> i : permute.keySet()) {
for (Map.Entry<GBiset<IrisDirection, IrisDirection>, DOP> entry : permute.entrySet()) {
GBiset<IrisDirection, IrisDirection> i = entry.getKey();
if (i.getA().equals(this) && i.getB().equals(d)) {
return permute.get(i).op(initial);
return entry.getValue().op(initial);
}
}
@ -334,11 +297,11 @@ public enum IrisDirection {
return;
}
permute = new KMap<GBiset<IrisDirection, IrisDirection>, DOP>();
permute = new KMap<>();
for (IrisDirection i : udnews()) {
for (IrisDirection j : udnews()) {
GBiset<IrisDirection, IrisDirection> b = new GBiset<IrisDirection, IrisDirection>(i, j);
GBiset<IrisDirection, IrisDirection> b = new GBiset<>(i, j);
if (i.equals(j)) {
permute.put(b, new DOP("DIRECT") {
@ -418,37 +381,23 @@ public enum IrisDirection {
}
public BlockFace getFace() {
switch (this) {
case DOWN_NEGATIVE_Y:
return BlockFace.DOWN;
case EAST_POSITIVE_X:
return BlockFace.EAST;
case NORTH_NEGATIVE_Z:
return BlockFace.NORTH;
case SOUTH_POSITIVE_Z:
return BlockFace.SOUTH;
case UP_POSITIVE_Y:
return BlockFace.UP;
case WEST_NEGATIVE_X:
return BlockFace.WEST;
}
return switch (this) {
case DOWN_NEGATIVE_Y -> BlockFace.DOWN;
case EAST_POSITIVE_X -> BlockFace.EAST;
case NORTH_NEGATIVE_Z -> BlockFace.NORTH;
case SOUTH_POSITIVE_Z -> BlockFace.SOUTH;
case UP_POSITIVE_Y -> BlockFace.UP;
case WEST_NEGATIVE_X -> BlockFace.WEST;
};
return null;
}
public Axis getAxis() {
switch (this) {
case DOWN_NEGATIVE_Y:
case UP_POSITIVE_Y:
return Axis.Y;
case EAST_POSITIVE_X:
case WEST_NEGATIVE_X:
return Axis.X;
case NORTH_NEGATIVE_Z:
case SOUTH_POSITIVE_Z:
return Axis.Z;
}
return switch (this) {
case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y;
case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X;
case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z;
};
return null;
}
}

View File

@ -190,7 +190,7 @@ public class IrisEffect {
return t;
}
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -212,9 +212,7 @@ public class IrisEffect {
if (sound != null) {
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
J.s(() -> {
p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch));
});
J.s(() -> p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)));
}
if (particleEffect != null) {
@ -223,23 +221,19 @@ public class IrisEffect {
part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1);
part.add(RNG.r.d(), 0, RNG.r.d());
if (extra != 0) {
J.s(() -> {
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra);
});
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
extra));
} else {
J.s(() -> {
p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ);
});
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
particleCount,
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
}
}
@ -250,18 +244,14 @@ public class IrisEffect {
return;
}
J.s(() -> {
p.removePotionEffect(getRealType());
});
J.s(() -> p.removePotionEffect(getRealType()));
}
J.s(() -> {
p.addPotionEffect(new PotionEffect(getRealType(),
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
Math.max(potionTicksMax, potionTicksMin)),
getPotionStrength(),
true, false, false));
});
J.s(() -> p.addPotionEffect(new PotionEffect(getRealType(),
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
Math.max(potionTicksMax, potionTicksMin)),
getPotionStrength(),
true, false, false)));
}
}
}

View File

@ -63,7 +63,7 @@ public class IrisEnchantment {
}
meta.addEnchant(getEnchant(), getLevel(rng), true);
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}

View File

@ -42,6 +42,7 @@ import java.util.Collection;
import java.util.Random;
import java.util.concurrent.atomic.AtomicReference;
@SuppressWarnings("ALL")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@ -286,7 +287,7 @@ public class IrisEntity extends IrisRegistrant {
J.s(() -> ae.set(doSpawn(at)));
PrecisionStopwatch p = PrecisionStopwatch.start();
while (ae == null) {
while (ae.get() == null) {
J.sleep(3);
}

View File

@ -30,6 +30,7 @@ import lombok.experimental.Accessors;
import java.util.List;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@ -96,7 +97,7 @@ public class IrisGenerator extends IrisRegistrant {
@ArrayType(min = 1, type = IrisNoiseGenerator.class)
@Desc("The list of noise gens this gen contains.")
private KList<IrisNoiseGenerator> composite = new KList<IrisNoiseGenerator>();
private KList<IrisNoiseGenerator> composite = new KList<>();
@Desc("The noise gen for cliff height.")

View File

@ -62,7 +62,7 @@ public class IrisGeneratorStyle {
@Desc("The exponent")
private double exponent = 1;
private final transient AtomicCache<CNG> cng = new AtomicCache<CNG>();
private final transient AtomicCache<CNG> cng = new AtomicCache<>();
public IrisGeneratorStyle(NoiseStyle s) {
this.style = s;
@ -87,6 +87,7 @@ public class IrisGeneratorStyle {
});
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isFlat() {
return style.equals(NoiseStyle.FLAT);
}

View File

@ -29,6 +29,7 @@ import org.bukkit.util.BlockVector;
import java.io.IOException;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -25,6 +25,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -25,6 +25,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -27,6 +27,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -27,6 +27,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -124,8 +124,7 @@ public class IrisLoot {
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if (getType().getMaxDurability() > 0 && m instanceof Damageable) {
Damageable d = (Damageable) m;
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
int max = getType().getMaxDurability();
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
}
@ -186,7 +185,7 @@ public class IrisLoot {
is.setItemMeta(m);
return is;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -208,8 +207,7 @@ public class IrisLoot {
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
ItemMeta m = is.getItemMeta();
if (getType().getMaxDurability() > 0 && m instanceof Damageable) {
Damageable d = (Damageable) m;
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
int max = getType().getMaxDurability();
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
}
@ -261,7 +259,7 @@ public class IrisLoot {
m.setLore(lore);
is.setItemMeta(m);
return is;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}

View File

@ -27,6 +27,7 @@ import lombok.experimental.Accessors;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -138,7 +138,7 @@ public class IrisNoiseGenerator {
}
public KList<IrisNoiseGenerator> getAllComposites() {
KList<IrisNoiseGenerator> g = new KList<IrisNoiseGenerator>();
KList<IrisNoiseGenerator> g = new KList<>();
g.add(this);

View File

@ -38,12 +38,10 @@ import org.bukkit.util.BlockVector;
import org.bukkit.util.Vector;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.function.Consumer;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@Data
@EqualsAndHashCode(callSuper = false)
@ -214,7 +212,7 @@ public class IrisObject extends IrisRegistrant {
center = new BlockVector(w / 2, h / 2, d / 2);
}
@SuppressWarnings("resource")
@SuppressWarnings({"resource", "RedundantSuppression"})
public static BlockVector sampleSize(File file) throws IOException {
FileInputStream in = new FileInputStream(file);
DataInputStream din = new DataInputStream(in);
@ -811,23 +809,24 @@ public class IrisObject extends IrisRegistrant {
if (getD() == 2) {
center = center.setZ(center.getBlockZ() + 0.5);
}
HashMap<BlockVector, BlockData> placeBlock = new HashMap();
@SuppressWarnings({"unchecked", "rawtypes"}) HashMap<BlockVector, BlockData> placeBlock = new HashMap();
IrisObject oo = new IrisObject((int) Math.ceil((w * scale) + (scale * 2)), (int) Math.ceil((h * scale) + (scale * 2)), (int) Math.ceil((d * scale) + (scale * 2)));
for (BlockVector i : blocks.keySet()) {
BlockData bd = blocks.get(i);
placeBlock.put(i.clone().add(HALF).subtract(center)
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
BlockData bd = entry.getValue();
placeBlock.put(entry.getKey().clone().add(HALF).subtract(center)
.multiply(scale).toBlockVector(), bd);
}
for (BlockVector v : placeBlock.keySet()) {
for (Map.Entry<BlockVector, BlockData> entry : placeBlock.entrySet()) {
BlockVector v = entry.getKey();
if (scale > 1) {
for (BlockVector vec : blocksBetweenTwoPoints(v.clone().add(center), v.clone().add(center).add(sm1))) {
oo.getBlocks().put(vec, placeBlock.get(v));
oo.getBlocks().put(vec, entry.getValue());
}
} else {
oo.setUnsigned(v.getBlockX(), v.getBlockY(), v.getBlockZ(), placeBlock.get(v));
oo.setUnsigned(v.getBlockX(), v.getBlockY(), v.getBlockZ(), entry.getValue());
}
}
@ -943,14 +942,14 @@ public class IrisObject extends IrisRegistrant {
double d = Double.MAX_VALUE;
for (BlockVector i : blocks.keySet()) {
BlockData dat = blocks.get(i);
for (Map.Entry<BlockVector, BlockData> entry : blocks.entrySet()) {
BlockData dat = entry.getValue();
if (dat.getMaterial().isAir()) {
continue;
}
double dx = i.distanceSquared(vv);
double dx = entry.getKey().distanceSquared(vv);
if (dx < d) {
d = dx;

View File

@ -177,9 +177,7 @@ public class IrisObjectPlacement {
public CNG getSurfaceWarp(RNG rng) {
return surfaceWarp.aquire(() ->
{
return getWarp().create(rng);
});
getWarp().create(rng));
}
public double warp(RNG rng, double x, double y, double z) {
@ -212,10 +210,10 @@ public class IrisObjectPlacement {
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
private class TableCache {
transient WeightedRandom<IrisLootTable> global = new WeightedRandom<>();
transient KMap<Material, WeightedRandom<IrisLootTable>> basic = new KMap<>();
transient KMap<Material, KMap<BlockData, WeightedRandom<IrisLootTable>>> exact = new KMap<>();
private static class TableCache {
final transient WeightedRandom<IrisLootTable> global = new WeightedRandom<>();
final transient KMap<Material, WeightedRandom<IrisLootTable>> basic = new KMap<>();
final transient KMap<Material, KMap<BlockData, WeightedRandom<IrisLootTable>>> exact = new KMap<>();
}
private TableCache getCache(IrisDataManager manager) {

View File

@ -190,47 +190,29 @@ public class IrisObjectRotation {
}
public BlockFace faceForAxis(Axis axis) {
switch (axis) {
case X:
return BlockFace.EAST;
case Y:
return BlockFace.UP;
case Z:
return BlockFace.NORTH;
}
return switch (axis) {
case X -> BlockFace.EAST;
case Y -> BlockFace.UP;
case Z -> BlockFace.NORTH;
};
return BlockFace.NORTH;
}
public Axis axisFor(BlockFace f) {
switch (f) {
case NORTH:
case SOUTH:
return Axis.Z;
case EAST:
case WEST:
return Axis.X;
case UP:
case DOWN:
return Axis.Y;
}
return switch (f) {
case NORTH, SOUTH -> Axis.Z;
case EAST, WEST -> Axis.X;
default -> Axis.Y;
};
return Axis.Y;
}
public Axis axisFor2D(BlockFace f) {
switch (f) {
case NORTH:
case SOUTH:
return Axis.Z;
case EAST:
case WEST:
case UP:
case DOWN:
return Axis.X;
}
return switch (f) {
case EAST, WEST, UP, DOWN -> Axis.X;
default -> Axis.Z;
};
return Axis.Z;
}
public BlockData rotate(BlockData dd, int spinxx, int spinyy, int spinzz) {
@ -244,8 +226,7 @@ public class IrisObjectRotation {
return d;
}
if (d instanceof Directional) {
Directional g = ((Directional) d);
if (d instanceof Directional g) {
BlockFace f = g.getFacing();
BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ());
bv = rotate(bv.clone(), spinx, spiny, spinz);
@ -256,8 +237,7 @@ public class IrisObjectRotation {
} else if (!g.getMaterial().isSolid()) {
d = null;
}
} else if (d instanceof Rotatable) {
Rotatable g = ((Rotatable) d);
} else if (d instanceof Rotatable g) {
BlockFace f = g.getRotation();
BlockVector bv = new BlockVector(f.getModX(), 0, f.getModZ());
@ -275,9 +255,8 @@ public class IrisObjectRotation {
if (!a.equals(((Orientable) d).getAxis()) && ((Orientable) d).getAxes().contains(a)) {
((Orientable) d).setAxis(a);
}
} else if (d instanceof MultipleFacing) {
} else if (d instanceof MultipleFacing g) {
List<BlockFace> faces = new KList<>();
MultipleFacing g = (MultipleFacing) d;
for (BlockFace i : g.getFaces()) {
BlockVector bv = new BlockVector(i.getModX(), i.getModY(), i.getModZ());
@ -296,9 +275,8 @@ public class IrisObjectRotation {
for (BlockFace i : faces) {
g.setFace(i, true);
}
} else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable) {
} else if (d.getMaterial().equals(Material.NETHER_PORTAL) && d instanceof Orientable g) {
//TODO: Fucks up logs
Orientable g = ((Orientable) d);
BlockFace f = faceForAxis(g.getAxis());
BlockVector bv = new BlockVector(f.getModX(), f.getModY(), f.getModZ());
bv = rotate(bv.clone(), spinx, spiny, spinz);
@ -306,7 +284,7 @@ public class IrisObjectRotation {
Axis a = !g.getAxes().contains(Axis.Y) ? axisFor(t) : axisFor2D(t);
((Orientable) d).setAxis(a);
}
} catch (Throwable throwable) {
} catch (Throwable ignored) {
}
@ -431,6 +409,7 @@ public class IrisObjectRotation {
return enabled && zAxis.isEnabled();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean canRotate() {
return canRotateX() || canRotateY() || canRotateZ();
}

View File

@ -83,7 +83,7 @@ public class IrisPotionEffect {
return t;
}
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@ -28,6 +28,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor

View File

@ -29,6 +29,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@SuppressWarnings("DefaultAnnotationParam")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@ -81,7 +82,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
@ArrayType(min = 1, type = IrisObjectPlacement.class)
@Desc("Objects define what schematics (iob files) iris will place in this region")
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
private KList<IrisObjectPlacement> objects = new KList<>();
@MinNumber(0)
@Desc("The min shore height")
@ -311,7 +312,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
public KList<String> getRidgeBiomeKeys() {
return cacheRidge.aquire(() ->
{
KList<String> cacheRidge = new KList<String>();
KList<String> cacheRidge = new KList<>();
ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome()));
return cacheRidge;
@ -321,7 +322,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
public KList<String> getSpotBiomeKeys() {
return cacheSpot.aquire(() ->
{
KList<String> cacheSpot = new KList<String>();
KList<String> cacheSpot = new KList<>();
spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome()));
return cacheSpot;
});
@ -329,9 +330,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
public CNG getShoreHeightGenerator() {
return shoreHeightGenerator.aquire(() ->
{
return CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
});
CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))));
}
public double getShoreHeight(double x, double z) {

View File

@ -46,6 +46,7 @@ public class IrisSlopeClip {
return minimumSlope <= 0 && maximumSlope >= 10;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isValid(double slope) {
if (isDefault()) {
return true;

View File

@ -38,7 +38,7 @@ import java.util.List;
public class TileBanner implements TileData<Banner> {
public static final int id = 2;
private List<Pattern> patterns = new ArrayList<Pattern>();
private List<Pattern> patterns = new ArrayList<>();
private DyeColor baseColor;
@Override
@ -65,6 +65,7 @@ public class TileBanner implements TileData<Banner> {
@Override
public TileBanner clone() {
TileBanner tileBanner = (TileBanner) super.clone();
TileBanner ts = new TileBanner();
ts.setBaseColor(getBaseColor());
ts.setPatterns(getPatterns());
@ -95,9 +96,10 @@ public class TileBanner implements TileData<Banner> {
}
}
@SuppressWarnings("deprecation")
@Override
public void toNBT(CompoundTag tag) {
ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
@SuppressWarnings("unchecked") ListTag<CompoundTag> listTag = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
for (Pattern p : patterns) {
CompoundTag pattern = new CompoundTag();
pattern.putString("Pattern", p.getPattern().getIdentifier());
@ -108,43 +110,9 @@ public class TileBanner implements TileData<Banner> {
}
public boolean isBanner(Material material) {
switch (material) {
case RED_BANNER:
case RED_WALL_BANNER:
case ORANGE_BANNER:
case ORANGE_WALL_BANNER:
case YELLOW_BANNER:
case YELLOW_WALL_BANNER:
case LIME_BANNER:
case LIME_WALL_BANNER:
case GREEN_BANNER:
case GREEN_WALL_BANNER:
case CYAN_BANNER:
case CYAN_WALL_BANNER:
case LIGHT_BLUE_BANNER:
case LIGHT_BLUE_WALL_BANNER:
case BLUE_BANNER:
case BLUE_WALL_BANNER:
case PURPLE_BANNER:
case PURPLE_WALL_BANNER:
case MAGENTA_BANNER:
case MAGENTA_WALL_BANNER:
case PINK_BANNER:
case PINK_WALL_BANNER:
case WHITE_BANNER:
case WHITE_WALL_BANNER:
case LIGHT_GRAY_BANNER:
case LIGHT_GRAY_WALL_BANNER:
case GRAY_BANNER:
case GRAY_WALL_BANNER:
case BLACK_BANNER:
case BLACK_WALL_BANNER:
case BROWN_BANNER:
case BROWN_WALL_BANNER:
return true;
default:
return false;
}
return switch (material) {
case RED_BANNER, RED_WALL_BANNER, ORANGE_BANNER, ORANGE_WALL_BANNER, YELLOW_BANNER, YELLOW_WALL_BANNER, LIME_BANNER, LIME_WALL_BANNER, GREEN_BANNER, GREEN_WALL_BANNER, CYAN_BANNER, CYAN_WALL_BANNER, LIGHT_BLUE_BANNER, LIGHT_BLUE_WALL_BANNER, BLUE_BANNER, BLUE_WALL_BANNER, PURPLE_BANNER, PURPLE_WALL_BANNER, MAGENTA_BANNER, MAGENTA_WALL_BANNER, PINK_BANNER, PINK_WALL_BANNER, WHITE_BANNER, WHITE_WALL_BANNER, LIGHT_GRAY_BANNER, LIGHT_GRAY_WALL_BANNER, GRAY_BANNER, GRAY_WALL_BANNER, BLACK_BANNER, BLACK_WALL_BANNER, BROWN_BANNER, BROWN_WALL_BANNER -> true;
default -> false;
};
}
}

View File

@ -29,6 +29,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@SuppressWarnings("ALL")
public interface TileData<T extends TileState> extends Cloneable {
KList<TileData<? extends TileState>> registry = setup();
@ -45,7 +46,7 @@ public interface TileData<T extends TileState> extends Cloneable {
static TileData<? extends TileState> read(DataInputStream s) throws Throwable {
int id = s.readShort();
TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
@SuppressWarnings("unchecked") TileData<? extends TileState> d = registry.get(id).getClass().getConstructor().newInstance();
d.fromBinary(s);
return d;
}
@ -62,7 +63,7 @@ public interface TileData<T extends TileState> extends Cloneable {
if (i.isApplicable(data)) {
try {
TileData<? extends TileState> s = i.getClass().getConstructor().newInstance();
@SuppressWarnings("unchecked") TileData<? extends TileState> s = i.getClass().getConstructor().newInstance();
s.fromBukkitTry(block.getState());
return s;
} catch (Throwable e) {
@ -84,6 +85,7 @@ public interface TileData<T extends TileState> extends Cloneable {
default boolean toBukkitTry(BlockState t) {
try {
//noinspection unchecked
toBukkit((T) t);
return true;
} catch (Throwable e) {
@ -95,6 +97,7 @@ public interface TileData<T extends TileState> extends Cloneable {
default boolean fromBukkitTry(BlockState t) {
try {
//noinspection unchecked
fromBukkit((T) t);
return true;
} catch (Throwable e) {

View File

@ -68,6 +68,7 @@ public class TileSign implements TileData<Sign> {
@Override
public TileSign clone() {
TileSign tileSign = (TileSign) super.clone();
TileSign ts = new TileSign();
ts.setDyeColor(getDyeColor());
ts.setLine1(getLine1());

View File

@ -57,6 +57,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
@Override
public TileSpawner clone() {
TileSpawner tileSpawner = (TileSpawner) super.clone();
TileSpawner ts = new TileSpawner();
ts.setEntityType(getEntityType());
return ts;
@ -75,7 +76,7 @@ public class TileSpawner implements TileData<CreatureSpawner> {
@Override
public void toNBT(CompoundTag tag) {
ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
@SuppressWarnings("unchecked") ListTag<CompoundTag> potentials = (ListTag<CompoundTag>) ListTag.createUnchecked(CompoundTag.class);
CompoundTag t = new CompoundTag();
CompoundTag ent = new CompoundTag();
ent.putString("id", entityType.getKey().toString());

View File

@ -39,6 +39,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Map;
@SuppressWarnings("EmptyMethod")
public class DirectWorldWriter {
private final File worldFolder;
private final Map<Long, MCAFile> writeBuffer;
@ -156,7 +157,7 @@ public class DirectWorldWriter {
}
return getBlockData(tag);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
return B.get("AIR");

View File

@ -39,7 +39,6 @@ import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@ -295,44 +294,40 @@ public class Pregenerator implements Listener {
int mcaoz = z << 5;
if (PaperLib.isPaper()) {
method.set("PaperAsync (Slow)");
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> {
e.queue(() -> {
try {
CompletableFuture<Chunk> cc = PaperLib.getChunkAtAsync(world, ii, jj);
draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC);
cc.join();
draw(ii, jj, COLOR_MCA_GENERATED);
generated.getAndIncrement();
vcax.set(ii);
vcaz.set(jj);
} catch (Throwable ex) {
draw(ii, jj, COLOR_ERROR);
ChunkPosition pos = new ChunkPosition(ii, jj);
errors.add(pos);
totalChunks.addAndGet(1024);
mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5));
Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")");
}
});
});
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> e.queue(() -> {
try {
CompletableFuture<Chunk> cc = PaperLib.getChunkAtAsync(world, ii, jj);
draw(ii, jj, COLOR_MCA_GENERATE_SLOW_ASYNC);
cc.join();
draw(ii, jj, COLOR_MCA_GENERATED);
generated.getAndIncrement();
vcax.set(ii);
vcaz.set(jj);
} catch (Throwable ex) {
draw(ii, jj, COLOR_ERROR);
ChunkPosition pos = new ChunkPosition(ii, jj);
errors.add(pos);
totalChunks.addAndGet(1024);
mcaDefer.add(new ChunkPosition(pos.getX() >> 5, pos.getZ() >> 5));
Iris.warn("Hole Detected in Chunk: " + pos.getX() + ", " + pos.getZ() + " (at block " + (pos.getX() << 4) + ", " + lowestBedrock + ", " + (pos.getZ() << 4) + ")");
}
}));
e.complete();
} else {
AtomicInteger m = new AtomicInteger();
method.set("Spigot (Very Slow)");
KList<Runnable> q = new KList<>();
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> {
q.add(() -> {
draw(ii, jj, COLOR_MCA_GENERATE_SLOW);
world.getChunkAt(ii, jj).load(true);
Chunk c = world.getChunkAt(ii, jj);
draw(ii, jj, COLOR_MCA_GENERATED);
checkForError(c);
m.getAndIncrement();
generated.getAndIncrement();
vcax.set(ii);
vcaz.set(jj);
});
});
mcaIteration.accept(mcaox, mcaoz, (ii, jj) -> q.add(() -> {
draw(ii, jj, COLOR_MCA_GENERATE_SLOW);
world.getChunkAt(ii, jj).load(true);
Chunk c = world.getChunkAt(ii, jj);
draw(ii, jj, COLOR_MCA_GENERATED);
checkForError(c);
m.getAndIncrement();
generated.getAndIncrement();
vcax.set(ii);
vcaz.set(jj);
}));
ChronoLatch tick = new ChronoLatch(1000);
new SR(0) {
@Override
@ -348,7 +343,7 @@ public class Pregenerator implements Listener {
try {
q.pop().run();
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@ -524,18 +519,13 @@ public class Pregenerator implements Listener {
while (order.isNotEmpty()) {
try {
order.pop().run();
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
l.unlock();
g.drawImage(image, 0, 0, getParent().getWidth(), getParent().getHeight(), new ImageObserver() {
@Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
return true;
}
});
g.drawImage(image, 0, 0, getParent().getWidth(), getParent().getHeight(), (img, infoflags, x, y, width, height) -> true);
g.setColor(Color.WHITE);
g.setFont(new Font("Hevetica", Font.BOLD, 28));
@ -575,11 +565,7 @@ public class Pregenerator implements Listener {
@SuppressWarnings("deprecation")
private static MCAPregenGui createAndShowGUI(Pregenerator j) throws HeadlessException {
JFrame frame;
try {
frame = new JFrame("Pregen View");
} catch (HeadlessException e) {
throw e;
}
frame = new JFrame("Pregen View");
MCAPregenGui nv = new MCAPregenGui();
frame.addKeyListener(nv);
nv.l = new ReentrantLock();
@ -602,7 +588,7 @@ public class Pregenerator implements Listener {
if (file != null) {
try {
frame.setIconImage(ImageIO.read(file));
} catch (IOException e) {
} catch (IOException ignored) {
}
}

View File

@ -27,6 +27,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@SuppressWarnings("ALL")
public class IrisWorlds {
private static final KMap<String, IrisAccess> provisioned = new KMap<>();

View File

@ -68,6 +68,7 @@ public class AtomicCache<T> {
if (this.t != null && M.ms() - a > 1000) {
if (this.t != null) {
//noinspection NonAtomicOperationOnVolatileField
validations++;
}
@ -100,6 +101,7 @@ public class AtomicCache<T> {
}
if (M.ms() - a > 1000) {
//noinspection NonAtomicOperationOnVolatileField
validations++;
return this.t;
}

View File

@ -19,10 +19,8 @@
package com.volmit.iris.scaffold.cache;
public interface Multicache {
@SuppressWarnings("hiding")
<V> Cache<V> getCache(int id);
@SuppressWarnings("hiding")
<V> Cache<V> createCache();
}

View File

@ -58,8 +58,8 @@ public class DataPalette<T> {
synchronized (palette) {
dos.writeShort(getPalette().size() + Short.MIN_VALUE);
for (int i = 0; i < palette.size(); i++) {
adapter.write(palette.get(i), dos);
for (T t : palette) {
adapter.write(t, dos);
}
}
}

View File

@ -20,23 +20,23 @@ package com.volmit.iris.scaffold.data.mca;
public class LoadFlags {
public static long BIOMES = 0x0001;
public static long HEIGHTMAPS = 0x0002;
public static long CARVING_MASKS = 0x0004;
public static long ENTITIES = 0x0008;
public static long TILE_ENTITIES = 0x0010;
public static long TILE_TICKS = 0x0040;
public static long LIQUID_TICKS = 0x0080;
public static long TO_BE_TICKED = 0x0100;
public static long POST_PROCESSING = 0x0200;
public static long STRUCTURES = 0x0400;
public static long BLOCK_LIGHTS = 0x0800;
public static long BLOCK_STATES = 0x1000;
public static long SKY_LIGHT = 0x2000;
public static long LIGHTS = 0x4000;
public static long LIQUIDS_TO_BE_TICKED = 0x8000;
public static final long BIOMES = 0x0001;
public static final long HEIGHTMAPS = 0x0002;
public static final long CARVING_MASKS = 0x0004;
public static final long ENTITIES = 0x0008;
public static final long TILE_ENTITIES = 0x0010;
public static final long TILE_TICKS = 0x0040;
public static final long LIQUID_TICKS = 0x0080;
public static final long TO_BE_TICKED = 0x0100;
public static final long POST_PROCESSING = 0x0200;
public static final long STRUCTURES = 0x0400;
public static final long BLOCK_LIGHTS = 0x0800;
public static final long BLOCK_STATES = 0x1000;
public static final long SKY_LIGHT = 0x2000;
public static final long LIGHTS = 0x4000;
public static final long LIQUIDS_TO_BE_TICKED = 0x8000;
public static long ALL_DATA = 0xffffffffffffffffL;
public static final long ALL_DATA = 0xffffffffffffffffL;
}

View File

@ -23,6 +23,7 @@ import com.volmit.iris.scaffold.data.nbt.tag.CompoundTag;
import java.io.IOException;
import java.io.RandomAccessFile;
@SuppressWarnings("ALL")
public class MCAFile {
/**
@ -80,7 +81,7 @@ public class MCAFile {
raf.seek(4096 + i * 4);
int timestamp = raf.readInt();
Chunk chunk = new Chunk(timestamp);
raf.seek(4096 * offset + 4); //+4: skip data size
raf.seek(4096L * offset + 4); //+4: skip data size
chunk.deserialize(raf, loadFlags);
chunks[i] = chunk;
}
@ -131,7 +132,7 @@ public class MCAFile {
if (chunk == null) {
continue;
}
raf.seek(4096 * globalOffset);
raf.seek(4096L * globalOffset);
lastWritten = chunk.serialize(raf, chunkXOffset + cx, chunkZOffset + cz);
if (lastWritten == 0) {
@ -142,14 +143,14 @@ public class MCAFile {
int sectors = (lastWritten >> 12) + (lastWritten % 4096 == 0 ? 0 : 1);
raf.seek(index * 4);
raf.seek(index * 4L);
raf.writeByte(globalOffset >>> 16);
raf.writeByte(globalOffset >> 8 & 0xFF);
raf.writeByte(globalOffset & 0xFF);
raf.writeByte(sectors);
// write timestamp
raf.seek(index * 4 + 4096);
raf.seek(index * 4L + 4096);
raf.writeInt(changeLastUpdate ? timestamp : chunk.getLastMCAUpdate());
globalOffset += sectors;
@ -158,7 +159,7 @@ public class MCAFile {
// padding
if (lastWritten % 4096 != 0) {
raf.seek(globalOffset * 4096 - 1);
raf.seek(globalOffset * 4096L - 1);
raf.write(0);
}
return chunksWritten;

View File

@ -105,10 +105,11 @@ public class Section {
return null;
}
@SuppressWarnings("ClassCanBeRecord")
private static class PaletteIndex {
CompoundTag data;
int index;
final CompoundTag data;
final int index;
PaletteIndex(CompoundTag data, int index) {
this.data = data;
@ -139,7 +140,7 @@ public class Section {
int index = getBlockIndex(blockX, blockY, blockZ);
int paletteIndex = getPaletteIndex(index);
return palette.get(paletteIndex);
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@ -30,6 +30,7 @@ import java.util.regex.Pattern;
/**
* SNBTWriter creates an SNBT String.
*/
@SuppressWarnings("ClassCanBeRecord")
public final class SNBTWriter implements MaxDepthIO {
private static final Pattern NON_QUOTE_PATTERN = Pattern.compile("[a-zA-Z_.+\\-]+");

View File

@ -66,6 +66,7 @@ public class StringPointer {
throw parseException("missing end quote");
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean nextArrayElement() {
skipWhitespace();
if (hasNext() && currentChar() == ',') {

View File

@ -54,7 +54,7 @@ public abstract class ArrayTag<T> extends Tag<T> {
return arrayToString("", "");
}
protected String arrayToString(String prefix, String suffix) {
protected String arrayToString(@SuppressWarnings("SameParameterValue") String prefix, @SuppressWarnings("SameParameterValue") String suffix) {
StringBuilder sb = new StringBuilder("[").append(prefix).append("".equals(prefix) ? "" : ";");
for (int i = 0; i < length(); i++) {
sb.append(i == 0 ? "" : ",").append(Array.get(getValue(), i)).append(suffix);

View File

@ -24,6 +24,7 @@ import com.volmit.iris.util.KMap;
import java.util.*;
import java.util.function.BiConsumer;
@SuppressWarnings("ALL")
public class CompoundTag extends Tag<Map<String, Tag<?>>> implements Iterable<Map.Entry<String, Tag<?>>>, Comparable<CompoundTag>, MaxDepthIO {
public static final byte ID = 10;

View File

@ -31,6 +31,7 @@ import java.util.function.Consumer;
* The type of an empty untyped {@link ListTag} can be set by using any of the {@code add()}
* methods or any of the {@code as...List()} methods.
*/
@SuppressWarnings("ALL")
public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<T>, Comparable<ListTag<T>>, MaxDepthIO {
public static final byte ID = 9;
@ -68,7 +69,7 @@ public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<
* @param initialCapacity The initial capacity of the returned List
* @return An instance of {@link List} with an initial capacity of 3
*/
private static <T> List<T> createEmptyValue(int initialCapacity) {
private static <T> List<T> createEmptyValue(@SuppressWarnings("SameParameterValue") int initialCapacity) {
return new KList<>(initialCapacity);
}

View File

@ -18,6 +18,8 @@
package com.volmit.iris.scaffold.data.nbt.tag;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@ -27,6 +29,7 @@ import java.util.Set;
* A decorator for the Set returned by CompoundTag#entrySet()
* that disallows setting null values.
*/
@SuppressWarnings("ClassCanBeRecord")
class NonNullEntrySet<K, V> implements Set<Map.Entry<K, V>> {
private final Set<Map.Entry<K, V>> set;
@ -61,7 +64,7 @@ class NonNullEntrySet<K, V> implements Set<Map.Entry<K, V>> {
}
@Override
public <T> T[] toArray(T[] a) {
public <T> T[] toArray(@NotNull T[] a) {
return set.toArray(a);
}
@ -76,22 +79,22 @@ class NonNullEntrySet<K, V> implements Set<Map.Entry<K, V>> {
}
@Override
public boolean containsAll(Collection<?> c) {
public boolean containsAll(@NotNull Collection<?> c) {
return set.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends Map.Entry<K, V>> c) {
public boolean addAll(@NotNull Collection<? extends Map.Entry<K, V>> c) {
return set.addAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
public boolean retainAll(@NotNull Collection<?> c) {
return set.retainAll(c);
}
@Override
public boolean removeAll(Collection<?> c) {
public boolean removeAll(@NotNull Collection<?> c) {
return set.removeAll(c);
}
@ -145,6 +148,7 @@ class NonNullEntrySet<K, V> implements Set<Map.Entry<K, V>> {
return entry.setValue(value);
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return entry.equals(o);

View File

@ -67,6 +67,7 @@ public abstract class Tag<T> implements Cloneable {
temp.put("\t", "\\\\t");
temp.put("\r", "\\\\r");
temp.put("\"", "\\\\\"");
//noinspection Java9CollectionFactory
ESCAPE_CHARACTERS = Collections.unmodifiableMap(temp);
}
@ -190,7 +191,6 @@ public abstract class Tag<T> implements Cloneable {
*
* @return A clone of this Tag.
*/
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
public abstract Tag<T> clone();
/**
@ -202,7 +202,8 @@ public abstract class Tag<T> implements Cloneable {
* the end of the string.
* @return The escaped string.
*/
protected static String escapeString(String s, boolean lenient) {
@SuppressWarnings("StringBufferMayBeStringBuilder")
protected static String escapeString(String s, @SuppressWarnings("SameParameterValue") boolean lenient) {
StringBuffer sb = new StringBuffer();
Matcher m = ESCAPE_PATTERN.matcher(s);
while (m.find()) {

View File

@ -113,9 +113,8 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
IrisColor ibc = biome.getColor();
Color rc = irc != null ? irc.getColor() : Color.GREEN.darker();
Color bc = ibc != null ? ibc.getColor() : biome.isAquatic() ? Color.BLUE : Color.YELLOW;
Color f = IrisColor.blend(rc, bc, bc, Color.getHSBColor(0, 0, (float) heightFactor));
return f;
return IrisColor.blend(rc, bc, bc, Color.getHSBColor(0, 0, (float) heightFactor));
}
@Override
@ -213,11 +212,10 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
if (slot != null) {
KList<IrisLootTable> tables = getLootTables(rx, block);
InventorySlotType slott = slot;
try {
InventoryHolder m = (InventoryHolder) block.getState();
addItems(false, m.getInventory(), rx, tables, slott, x, y, z, 15);
addItems(false, m.getInventory(), rx, tables, slot, x, y, z, 15);
} catch (Throwable ignored) {
}
@ -256,7 +254,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
try {
Arrays.parallelSort(nitems, (a, b) -> rng.nextInt());
break;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}

View File

@ -109,7 +109,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
new MortarSender(i, Iris.instance.getTag()).sendMessage("Dimension Hotloaded");
i.playSound(i.getLocation(), Sound.ITEM_BOTTLE_FILL, 1f, 1.25f);
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}
});
@ -131,7 +131,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
J.a(() -> hotloader.check());
getComposite().clean();
}
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@ -315,7 +315,6 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
/**
* Place strongholds in the world
*
* @param world
*/
public void placeStrongholds(World world) {
EngineData metadata = getComposite().getEngineMetadata();
@ -330,7 +329,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
Class<?> clazz = Class.forName("net.minecraft.world.level.chunk.ChunkGenerator");
Class<?> clazzSG = Class.forName("net.minecraft.world.level.levelgen.feature.StructureGenerator");
Class<?> clazzBP = Class.forName("net.minecraft.core.BlockPosition");
Constructor bpCon = clazzBP.getConstructor(int.class, int.class, int.class);
@SuppressWarnings("rawtypes") Constructor bpCon = clazzBP.getConstructor(int.class, int.class, int.class);
//By default, we place 9 strongholds. One near 0,0 and 8 all around it at about 10_000 blocks out
int[][] coords = {{0, 0}, {7000, -7000}, {10000, 0}, {7000, 7000}, {0, 10000}, {-7000, 7000}, {-10000, 0}, {-7000, -7000}, {0, -10000}};
@ -358,7 +357,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
});
}
CompletableFuture<Void> all = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
CompletableFuture<Void> all = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
all.thenAccept((_void) -> { //Once all futures for all 9 strongholds have completed
for (CompletableFuture<Object> future : futures) {
try {
@ -407,7 +406,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
/**
* Get BlockPosition for nearest stronghold from the provided position
*/
private Object getBP(Class<?> clazz, Class<?> clazzSG, Class<?> clazzBP, Object nmsWorld, Object pos, Object chunkGenerator) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
private Object getBP(Class<?> clazz, Class<?> clazzSG, Class<?> clazzBP, Object nmsWorld, Object pos, Object chunkGenerator) throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final String stronghold = "k"; //1.17_01 mapping
Object structureGeneratorStronghold = clazzSG.getDeclaredField(stronghold).get(null);
@ -418,14 +417,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
int.class,
boolean.class
);
Object nearestPOS = getNearestGeneratedFeature.invoke(chunkGenerator,
return getNearestGeneratedFeature.invoke(chunkGenerator,
nmsWorld,
structureGeneratorStronghold,
pos,
100,
false
);
return nearestPOS;
}
private File getDataFolder(World world) {
@ -466,6 +464,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
int oz = z << 4;
com.volmit.iris.scaffold.data.mca.Chunk cc = writer.getChunk(x, z);
BiomeBaseInjector injector = (xx, yy, zz, biomeBase) -> cc.setBiomeAt(ox + xx, yy, oz + zz, INMS.get().getTrueBiomeBaseId(biomeBase));
//noinspection deprecation
generateChunkRawData(w, x, z, new TerrainChunk() {
@Override
public BiomeBaseInjector getBiomeBaseInjector() {
@ -477,11 +476,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
return Biome.THE_VOID;
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
return Biome.THE_VOID;
@ -519,6 +520,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
cc.setBlockStateAt(xx, y, zz, DirectWorldWriter.getCompound(blockData), false);
}
@NotNull
@Override
public BlockData getBlockData(int x, int y, int z) {
if (y > getMaxHeight()) {
@ -772,6 +774,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
int zz = z * 16;
BiomeBaseInjector inj = (a, b, c, d) -> {
};
//noinspection deprecation
generateChunkRawData(getComposite().getWorld(), x, z, new TerrainChunk() {
@Override
public BiomeBaseInjector getBiomeBaseInjector() {
@ -783,11 +786,13 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
return Biome.THE_VOID;
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
return Biome.THE_VOID;
@ -820,6 +825,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
}
}
@NotNull
@Override
public BlockData getBlockData(int x, int y, int z) {
return Iris.edit.get(compound.getWorld(), x + xx, y, z + zz);
@ -949,7 +955,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
try {
dim.getDimensionalComposite().forEach((m) -> IrisDataManager.loadAnyDimension(m.getDimension()).getAllAnyBiomes().forEach((i) -> v.put(i.getLoadKey(), i)));
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@ -140,7 +140,7 @@ public interface EngineCompound extends Listener, Hotloadable, DataProvider {
try {
dim.getDimensionalComposite().forEach((m) -> getData().getDimensionLoader().load(m.getDimension()).getAllBiomes(this).forEach((i) -> v.put(i.getLoadKey(), i)));
} catch (Throwable e) {
} catch (Throwable ignored) {
}

Some files were not shown because too many files have changed in this diff Show More