mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Cleanup
This commit is contained in:
parent
44d75d9955
commit
2aa240337c
@ -125,12 +125,10 @@ public class PregeneratorJob implements PregenListener {
|
||||
}
|
||||
|
||||
public void drawRegion(int x, int z, Color color) {
|
||||
J.a(() -> {
|
||||
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
||||
J.a(() -> PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
||||
draw(xx, zz, color);
|
||||
J.sleep(3);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public void draw(int x, int z, Color color) {
|
||||
|
@ -36,7 +36,7 @@ public class INMS {
|
||||
return binding;
|
||||
}
|
||||
|
||||
public static final String getNMSTag() {
|
||||
public static String getNMSTag() {
|
||||
if (IrisSettings.get().getGeneral().isDisableNMS()) {
|
||||
return "BUKKIT";
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class INMS {
|
||||
return "BUKKIT";
|
||||
}
|
||||
|
||||
private static final INMSBinding bind() {
|
||||
private static INMSBinding bind() {
|
||||
String code = getNMSTag();
|
||||
Iris.info("Locating NMS Binding for " + code);
|
||||
|
||||
|
@ -23,18 +23,11 @@ import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.util.data.IrisPackRepository;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
@Data
|
||||
public class IrisPack {
|
||||
private final File folder;
|
||||
|
||||
public IrisPack(File folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
public record IrisPack(File folder) {
|
||||
|
||||
public void delete() {
|
||||
IO.delete(folder);
|
||||
|
@ -124,8 +124,8 @@ public class IrisData {
|
||||
IrisContext ctx = IrisContext.get();
|
||||
Engine engine = this.engine;
|
||||
|
||||
if (engine == null && ctx != null && ctx.getEngine() != null) {
|
||||
engine = ctx.getEngine();
|
||||
if (engine == null && ctx != null && ctx.engine() != null) {
|
||||
engine = ctx.engine();
|
||||
}
|
||||
|
||||
if (engine == null && t.getPreprocessors().isNotEmpty()) {
|
||||
@ -196,8 +196,7 @@ public class IrisData {
|
||||
}
|
||||
|
||||
loaders.clear();
|
||||
File packs = dataFolder;
|
||||
packs.mkdirs();
|
||||
dataFolder.mkdirs();
|
||||
this.lootLoader = registerLoader(IrisLootTable.class);
|
||||
this.spawnerLoader = registerLoader(IrisSpawner.class);
|
||||
this.entityLoader = registerLoader(IrisEntity.class);
|
||||
@ -324,7 +323,7 @@ public class IrisData {
|
||||
if (f.getPath().startsWith(getDataFolder().getPath())) {
|
||||
String[] full = f.getPath().split("\\Q" + File.separator + "\\E");
|
||||
String[] df = getDataFolder().getPath().split("\\Q" + File.separator + "\\E");
|
||||
String g = "";
|
||||
StringBuilder g = new StringBuilder();
|
||||
boolean m = true;
|
||||
for (int i = 0; i < full.length; i++) {
|
||||
if (i >= df.length) {
|
||||
@ -333,12 +332,11 @@ public class IrisData {
|
||||
continue;
|
||||
}
|
||||
|
||||
g += "/" + full[i];
|
||||
g.append("/").append(full[i]);
|
||||
}
|
||||
}
|
||||
|
||||
String ff = g.substring(1).split("\\Q.\\E")[0];
|
||||
return ff;
|
||||
return g.substring(1).split("\\Q.\\E")[0];
|
||||
} else {
|
||||
Iris.error("Forign file from loader " + f.getPath() + " (loader realm: " + getDataFolder().getPath() + ")");
|
||||
}
|
||||
|
@ -123,8 +123,7 @@ public class ScriptResourceLoader extends ResourceLoader<IrisScript> {
|
||||
String key = name + "-" + objectClass.getCanonicalName();
|
||||
|
||||
if (loadCache.containsKey(key)) {
|
||||
IrisScript t = loadCache.get(key);
|
||||
return t;
|
||||
return loadCache.get(key);
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
|
@ -135,9 +135,7 @@ public class IrisCreator {
|
||||
|
||||
|
||||
try {
|
||||
J.sfut(() -> {
|
||||
world.set(wc.createWorld());
|
||||
}).get();
|
||||
J.sfut(() -> world.set(wc.createWorld())).get();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -149,9 +147,7 @@ public class IrisCreator {
|
||||
done.set(true);
|
||||
|
||||
if (sender.isPlayer()) {
|
||||
J.s(() -> {
|
||||
sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0));
|
||||
});
|
||||
J.s(() -> sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0)));
|
||||
}
|
||||
|
||||
if (studio) {
|
||||
|
@ -84,9 +84,7 @@ public class IrisCarveLayer {
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> rawStream(RNG rng, IrisData data) {
|
||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> {
|
||||
return getCng(rng, data).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||
}, Interpolated.DOUBLE));
|
||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> getCng(rng, data).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4), Interpolated.DOUBLE));
|
||||
}
|
||||
|
||||
public CNG getCng(RNG rng, IrisData data) {
|
||||
|
@ -70,8 +70,10 @@ public class IrisDecorator {
|
||||
private int stackMax = 1;
|
||||
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" +
|
||||
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
|
||||
@Desc("""
|
||||
Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height
|
||||
|
||||
Within a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height""")
|
||||
private boolean scaleStack = false;
|
||||
|
||||
@Required
|
||||
|
@ -560,10 +560,6 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
});
|
||||
}
|
||||
|
||||
public void pickRandomColor(DataProvider data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "regions";
|
||||
|
@ -24,15 +24,10 @@ import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class IrisContext {
|
||||
private static ChronoLatch cl = new ChronoLatch(60000);
|
||||
public record IrisContext(Engine engine) {
|
||||
private static final ChronoLatch cl = new ChronoLatch(60000);
|
||||
private static final KMap<Thread, IrisContext> context = new KMap<>();
|
||||
private final Engine engine;
|
||||
|
||||
public static IrisContext get() {
|
||||
return context.get(Thread.currentThread());
|
||||
|
@ -380,13 +380,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
|
||||
* @return a new Cuboid outset by the given direction and amount
|
||||
*/
|
||||
public Cuboid outset(CuboidDirection dir, int amount) {
|
||||
Cuboid c = switch (dir) {
|
||||
return switch (dir) {
|
||||
case Horizontal -> expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
|
||||
case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
|
||||
case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
|
||||
default -> throw new IllegalArgumentException("invalid direction " + dir);
|
||||
};
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
data = new NibbleArray(CAPACITY, i);
|
||||
}
|
||||
|
||||
private final void expand() {
|
||||
private void expand() {
|
||||
if (bpb < 8) {
|
||||
changeBitsPerBlock(bpb + 1);
|
||||
} else {
|
||||
@ -90,7 +90,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
changeBitsPerBlock(targetBits);
|
||||
}
|
||||
|
||||
private final void changeBitsPerBlock(int bits) {
|
||||
private void changeBitsPerBlock(int bits) {
|
||||
bpb = bits;
|
||||
data = new NibbleArray(bpb, CAPACITY, data);
|
||||
}
|
||||
@ -103,7 +103,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
return palette.get(data.get(getCoordinateIndex(x, y, z)));
|
||||
}
|
||||
|
||||
private final int getPaletteId(T d) {
|
||||
private int getPaletteId(T d) {
|
||||
int index = palette.indexOf(d);
|
||||
|
||||
if (index == -1) {
|
||||
@ -118,7 +118,7 @@ public abstract class NibbleDataPalette<T> implements Writable {
|
||||
return index + Byte.MIN_VALUE;
|
||||
}
|
||||
|
||||
private final int getCoordinateIndex(int x, int y, int z) {
|
||||
private int getCoordinateIndex(int x, int y, int z) {
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
}
|
||||
|
@ -277,10 +277,8 @@ public class Form {
|
||||
if (phantom > div) {
|
||||
phantom /= div;
|
||||
suffix = "Year";
|
||||
return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s");
|
||||
} else {
|
||||
return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s");
|
||||
}
|
||||
return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s");
|
||||
} else {
|
||||
return Form.fd(phantom, 0) + " " + suffix + ((int) phantom == 1 ? "" : "s");
|
||||
}
|
||||
|
@ -196,8 +196,7 @@ public class RandomColor {
|
||||
int saturation = pickSaturation(color, null, null);
|
||||
int brightness = pickBrightness(color, saturation, null);
|
||||
|
||||
int colorValue = getColor(hue, saturation, brightness);
|
||||
return colorValue;
|
||||
return getColor(hue, saturation, brightness);
|
||||
}
|
||||
|
||||
public int[] random(Color color, int count) {
|
||||
@ -262,18 +261,13 @@ public class RandomColor {
|
||||
|
||||
private int pickSaturation(ColorInfo colorInfo, SaturationType saturationType, Luminosity luminosity) {
|
||||
if (saturationType != null) {
|
||||
switch (saturationType) {
|
||||
case RANDOM:
|
||||
return randomWithin(new Range(0, 100));
|
||||
case MONOCHROME:
|
||||
return 0;
|
||||
case HIGH:
|
||||
return randomWithin(new Range(75, 100));
|
||||
case MEDIUM:
|
||||
return randomWithin(new Range(55, 75));
|
||||
case LOW:
|
||||
return randomWithin(new Range(35, 55));
|
||||
}
|
||||
return switch (saturationType) {
|
||||
case RANDOM -> randomWithin(new Range(0, 100));
|
||||
case MONOCHROME -> 0;
|
||||
case HIGH -> randomWithin(new Range(75, 100));
|
||||
case MEDIUM -> randomWithin(new Range(55, 75));
|
||||
case LOW -> randomWithin(new Range(35, 55));
|
||||
};
|
||||
}
|
||||
|
||||
if (colorInfo == null) {
|
||||
@ -287,15 +281,9 @@ public class RandomColor {
|
||||
|
||||
if (luminosity != null) {
|
||||
switch (luminosity) {
|
||||
case LIGHT:
|
||||
min = 55;
|
||||
break;
|
||||
case BRIGHT:
|
||||
min = max - 10;
|
||||
break;
|
||||
case DARK:
|
||||
max = 55;
|
||||
break;
|
||||
case LIGHT -> min = 55;
|
||||
case BRIGHT -> min = max - 10;
|
||||
case DARK -> max = 55;
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,19 +308,12 @@ public class RandomColor {
|
||||
|
||||
if (luminosity != null) {
|
||||
switch (luminosity) {
|
||||
|
||||
case DARK:
|
||||
max = min + 20;
|
||||
break;
|
||||
|
||||
case LIGHT:
|
||||
min = (max + min) / 2;
|
||||
break;
|
||||
|
||||
case RANDOM:
|
||||
case DARK -> max = min + 20;
|
||||
case LIGHT -> min = (max + min) / 2;
|
||||
case RANDOM -> {
|
||||
min = 0;
|
||||
max = 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,9 +361,7 @@ public class IrisMathHelper {
|
||||
var9 = var5;
|
||||
var10 = var6;
|
||||
}
|
||||
default -> {
|
||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
|
||||
}
|
||||
default -> throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
|
||||
}
|
||||
final int var11 = clamp((int) (var8 * 255.0f), 0, 255);
|
||||
final int var12 = clamp((int) (var9 * 255.0f), 0, 255);
|
||||
|
@ -197,19 +197,15 @@ public class KochanekBartelsInterpolation implements PathInterpolation {
|
||||
* Assumes a < b.
|
||||
*/
|
||||
private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) {
|
||||
switch (indexRight - indexLeft) {
|
||||
case 0:
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, remainderRight);
|
||||
|
||||
case 1:
|
||||
return switch (indexRight - indexLeft) {
|
||||
case 0 -> arcLengthRecursive(indexLeft, remainderLeft, remainderRight);
|
||||
case 1 ->
|
||||
// This case is merely a speed-up for a very common case
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, 1.0)
|
||||
arcLengthRecursive(indexLeft, remainderLeft, 1.0)
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
|
||||
default:
|
||||
return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0)
|
||||
default -> arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0)
|
||||
+ arcLengthRecursive(indexRight, 0.0, remainderRight);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private double arcLengthRecursive(int index, double remainderLeft, double remainderRight) {
|
||||
|
@ -200,11 +200,10 @@ public class MathHelper {
|
||||
|
||||
public static double a(long[] var0) {
|
||||
long var1 = 0L;
|
||||
long[] var3 = var0;
|
||||
int var4 = var0.length;
|
||||
|
||||
for (int var5 = 0; var5 < var4; ++var5) {
|
||||
long var6 = var3[var5];
|
||||
long var6 = var0[var5];
|
||||
var1 += var6;
|
||||
}
|
||||
|
||||
@ -452,7 +451,7 @@ public class MathHelper {
|
||||
public static double d(double var0, double var2) {
|
||||
double var4 = var2 * var2 + var0 * var0;
|
||||
if (Double.isNaN(var4)) {
|
||||
return 0.0D / 0.0;
|
||||
return Double.NaN;
|
||||
} else {
|
||||
boolean var6 = var0 < 0.0D;
|
||||
if (var6) {
|
||||
@ -536,38 +535,37 @@ public class MathHelper {
|
||||
float var9;
|
||||
float var10;
|
||||
switch (var3) {
|
||||
case 0:
|
||||
case 0 -> {
|
||||
var8 = var2;
|
||||
var9 = var7;
|
||||
var10 = var5;
|
||||
break;
|
||||
case 1:
|
||||
}
|
||||
case 1 -> {
|
||||
var8 = var6;
|
||||
var9 = var2;
|
||||
var10 = var5;
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2 -> {
|
||||
var8 = var5;
|
||||
var9 = var2;
|
||||
var10 = var7;
|
||||
break;
|
||||
case 3:
|
||||
}
|
||||
case 3 -> {
|
||||
var8 = var5;
|
||||
var9 = var6;
|
||||
var10 = var2;
|
||||
break;
|
||||
case 4:
|
||||
}
|
||||
case 4 -> {
|
||||
var8 = var7;
|
||||
var9 = var5;
|
||||
var10 = var2;
|
||||
break;
|
||||
case 5:
|
||||
}
|
||||
case 5 -> {
|
||||
var8 = var2;
|
||||
var9 = var5;
|
||||
var10 = var6;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
|
||||
}
|
||||
default -> throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
|
||||
}
|
||||
|
||||
int var11 = clamp((int) (var8 * 255.0F), 0, 255);
|
||||
@ -596,11 +594,10 @@ public class MathHelper {
|
||||
|
||||
public static double[] a(double... var0) {
|
||||
float var1 = 0.0F;
|
||||
double[] var2f = var0;
|
||||
int var3 = var0.length;
|
||||
|
||||
for (int var4 = 0; var4 < var3; ++var4) {
|
||||
double var5 = var2f[var4];
|
||||
double var5 = var0[var4];
|
||||
var1 = (float) ((double) var1 + var5);
|
||||
}
|
||||
|
||||
|
@ -265,85 +265,71 @@ public class VectorMath {
|
||||
KList<BlockFace> faces = new KList<>();
|
||||
|
||||
switch (f) {
|
||||
case DOWN:
|
||||
faces.add(BlockFace.DOWN);
|
||||
break;
|
||||
case EAST:
|
||||
faces.add(BlockFace.EAST);
|
||||
break;
|
||||
case EAST_NORTH_EAST:
|
||||
case DOWN -> faces.add(BlockFace.DOWN);
|
||||
case EAST -> faces.add(BlockFace.EAST);
|
||||
case EAST_NORTH_EAST -> {
|
||||
faces.add(BlockFace.EAST);
|
||||
faces.add(BlockFace.EAST);
|
||||
faces.add(BlockFace.NORTH);
|
||||
break;
|
||||
case EAST_SOUTH_EAST:
|
||||
}
|
||||
case EAST_SOUTH_EAST -> {
|
||||
faces.add(BlockFace.EAST);
|
||||
faces.add(BlockFace.EAST);
|
||||
faces.add(BlockFace.SOUTH);
|
||||
break;
|
||||
case NORTH:
|
||||
faces.add(BlockFace.NORTH);
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
}
|
||||
case NORTH -> faces.add(BlockFace.NORTH);
|
||||
case NORTH_EAST -> {
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.EAST);
|
||||
break;
|
||||
case NORTH_NORTH_EAST:
|
||||
}
|
||||
case NORTH_NORTH_EAST -> {
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.EAST);
|
||||
break;
|
||||
case NORTH_NORTH_WEST:
|
||||
}
|
||||
case NORTH_NORTH_WEST -> {
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.WEST);
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
}
|
||||
case NORTH_WEST -> {
|
||||
faces.add(BlockFace.NORTH);
|
||||
faces.add(BlockFace.WEST);
|
||||
break;
|
||||
case SELF:
|
||||
faces.add(BlockFace.SELF);
|
||||
break;
|
||||
case SOUTH:
|
||||
faces.add(BlockFace.SOUTH);
|
||||
break;
|
||||
case SOUTH_EAST:
|
||||
}
|
||||
case SELF -> faces.add(BlockFace.SELF);
|
||||
case SOUTH -> faces.add(BlockFace.SOUTH);
|
||||
case SOUTH_EAST -> {
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.EAST);
|
||||
break;
|
||||
case SOUTH_SOUTH_EAST:
|
||||
}
|
||||
case SOUTH_SOUTH_EAST -> {
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.EAST);
|
||||
break;
|
||||
case SOUTH_SOUTH_WEST:
|
||||
}
|
||||
case SOUTH_SOUTH_WEST -> {
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.WEST);
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
}
|
||||
case SOUTH_WEST -> {
|
||||
faces.add(BlockFace.SOUTH);
|
||||
faces.add(BlockFace.WEST);
|
||||
break;
|
||||
case UP:
|
||||
faces.add(BlockFace.UP);
|
||||
break;
|
||||
case WEST:
|
||||
faces.add(BlockFace.WEST);
|
||||
break;
|
||||
case WEST_NORTH_WEST:
|
||||
}
|
||||
case UP -> faces.add(BlockFace.UP);
|
||||
case WEST -> faces.add(BlockFace.WEST);
|
||||
case WEST_NORTH_WEST -> {
|
||||
faces.add(BlockFace.WEST);
|
||||
faces.add(BlockFace.WEST);
|
||||
faces.add(BlockFace.NORTH);
|
||||
break;
|
||||
case WEST_SOUTH_WEST:
|
||||
}
|
||||
case WEST_SOUTH_WEST -> {
|
||||
faces.add(BlockFace.WEST);
|
||||
faces.add(BlockFace.WEST);
|
||||
faces.add(BlockFace.SOUTH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
return faces;
|
||||
|
@ -19,14 +19,6 @@
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MatterEntity {
|
||||
private final double xOff;
|
||||
private final double yOff;
|
||||
private final double zOff;
|
||||
private final CompoundTag entityData;
|
||||
public record MatterEntity(double xOff, double yOff, double zOff, CompoundTag entityData) {
|
||||
}
|
||||
|
@ -19,11 +19,6 @@
|
||||
package com.volmit.iris.util.matter;
|
||||
|
||||
import com.volmit.iris.util.nbt.tag.CompoundTag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MatterTile {
|
||||
private final CompoundTag tileData;
|
||||
public record MatterTile(CompoundTag tileData) {
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
|
||||
super(width, height, depth, MatterEntityGroup.class);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> {
|
||||
for (MatterEntity i : d.getEntities()) {
|
||||
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
|
||||
INMS.get().deserializeEntity(i.getEntityData(), realPosition);
|
||||
Location realPosition = new Location(w, x + i.xOff(), y + i.yOff(), z + i.zOff());
|
||||
INMS.get().deserializeEntity(i.entityData(), realPosition);
|
||||
}
|
||||
}));
|
||||
registerReader(World.class, (w, x, y, z) -> {
|
||||
@ -124,10 +124,10 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
|
||||
public void writeNode(MatterEntityGroup b, DataOutputStream dos) throws IOException {
|
||||
Varint.writeUnsignedVarInt(b.getEntities().size(), dos);
|
||||
for (MatterEntity i : b.getEntities()) {
|
||||
dos.writeByte((int) (i.getXOff() * 255) + Byte.MIN_VALUE);
|
||||
dos.writeByte((int) (i.getYOff() * 255) + Byte.MIN_VALUE);
|
||||
dos.writeByte((int) (i.getZOff() * 255) + Byte.MIN_VALUE);
|
||||
NBTUtil.write(i.getEntityData(), dos, false);
|
||||
dos.writeByte((int) (i.xOff() * 255) + Byte.MIN_VALUE);
|
||||
dos.writeByte((int) (i.yOff() * 255) + Byte.MIN_VALUE);
|
||||
dos.writeByte((int) (i.zOff() * 255) + Byte.MIN_VALUE);
|
||||
NBTUtil.write(i.entityData(), dos, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class TileMatter extends RawMatter<MatterTile> {
|
||||
|
||||
public TileMatter(int width, int height, int depth) {
|
||||
super(width, height, depth, MatterTile.class);
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
|
||||
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.tileData(), new Location(w, x, y, z))));
|
||||
registerReader(World.class, (w, x, y, z) -> {
|
||||
Location l = new Location(w, x, y, z);
|
||||
if (INMS.get().hasTile(l)) {
|
||||
@ -55,7 +55,7 @@ public class TileMatter extends RawMatter<MatterTile> {
|
||||
|
||||
@Override
|
||||
public void writeNode(MatterTile b, DataOutputStream dos) throws IOException {
|
||||
NBTUtil.write(b.getTileData(), dos, false);
|
||||
NBTUtil.write(b.tileData(), dos, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -494,7 +494,7 @@ public class Mth {
|
||||
float var6 = var2 * (1.0F - var4 * var1);
|
||||
float var7 = var2 * (1.0F - (1.0F - var4) * var1);
|
||||
switch (var3) {
|
||||
case 0:
|
||||
case 0 -> {
|
||||
var8 = var2;
|
||||
var9 = var7;
|
||||
var10 = var5;
|
||||
@ -502,7 +502,8 @@ public class Mth {
|
||||
var12 = clamp((int) (var9 * 255.0F), 0, 255);
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
case 1:
|
||||
}
|
||||
case 1 -> {
|
||||
var8 = var6;
|
||||
var9 = var2;
|
||||
var10 = var5;
|
||||
@ -510,7 +511,8 @@ public class Mth {
|
||||
var12 = clamp((int) (var9 * 255.0F), 0, 255);
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
case 2:
|
||||
}
|
||||
case 2 -> {
|
||||
var8 = var5;
|
||||
var9 = var2;
|
||||
var10 = var7;
|
||||
@ -518,7 +520,8 @@ public class Mth {
|
||||
var12 = clamp((int) (var9 * 255.0F), 0, 255);
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
case 3:
|
||||
}
|
||||
case 3 -> {
|
||||
var8 = var5;
|
||||
var9 = var6;
|
||||
var10 = var2;
|
||||
@ -526,7 +529,8 @@ public class Mth {
|
||||
var12 = clamp((int) (var9 * 255.0F), 0, 255);
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
case 4:
|
||||
}
|
||||
case 4 -> {
|
||||
var8 = var7;
|
||||
var9 = var5;
|
||||
var10 = var2;
|
||||
@ -534,7 +538,8 @@ public class Mth {
|
||||
var12 = clamp((int) (var9 * 255.0F), 0, 255);
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
case 5:
|
||||
}
|
||||
case 5 -> {
|
||||
var8 = var2;
|
||||
var9 = var5;
|
||||
var10 = var6;
|
||||
@ -543,6 +548,7 @@ public class Mth {
|
||||
var13 = clamp((int) (var10 * 255.0F), 0, 255);
|
||||
return var11 << 16 | var12 << 8 | var13;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
|
||||
}
|
||||
|
||||
|
@ -25,22 +25,23 @@ import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class DL {
|
||||
protected File d;
|
||||
protected URL u;
|
||||
protected ChronoLatch latch;
|
||||
protected KSet<DownloadFlag> flags;
|
||||
protected final File d;
|
||||
protected final URL u;
|
||||
protected final ChronoLatch latch;
|
||||
protected final KSet<DownloadFlag> flags;
|
||||
protected MeteredOutputStream o;
|
||||
protected DownloadState state;
|
||||
protected int timeout;
|
||||
protected final int timeout;
|
||||
protected long size;
|
||||
protected long start;
|
||||
protected long downloaded;
|
||||
protected long currentChunk;
|
||||
protected long lastChunk;
|
||||
protected long bps;
|
||||
protected int bufferSize;
|
||||
protected final int bufferSize;
|
||||
protected long lastPull;
|
||||
protected DownloadMonitor m;
|
||||
|
||||
@ -60,9 +61,7 @@ public abstract class DL {
|
||||
flags = new KSet<>();
|
||||
latch = new ChronoLatch(500);
|
||||
|
||||
for (DownloadFlag i : downloadFlags) {
|
||||
flags.add(i);
|
||||
}
|
||||
flags.addAll(Arrays.asList(downloadFlags));
|
||||
}
|
||||
|
||||
public void monitor(DownloadMonitor m) {
|
||||
|
@ -518,9 +518,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
|
||||
return super.getDataFolder();
|
||||
}
|
||||
|
||||
File f = new File(getDataFolder(), new KList<>(strings).toString(File.separator));
|
||||
|
||||
return f;
|
||||
return new File(getDataFolder(), new KList<>(strings).toString(File.separator));
|
||||
}
|
||||
|
||||
public File getDataFolderList(String pre, String[] strings) {
|
||||
|
@ -206,17 +206,16 @@ public class VolmitSender implements CommandSender {
|
||||
}
|
||||
|
||||
public void sendProgress(double percent, String thing) {
|
||||
int l = 44;
|
||||
int g;
|
||||
if (percent < 0) {
|
||||
int l = 44;
|
||||
int g = (int) (1D * l);
|
||||
g = (int) (1D * l);
|
||||
sendTitle(C.IRIS + thing + " ", 0, 500, 250);
|
||||
sendActionNoProcessing("" + "" + pulse("#00ff80", "#00373d", 1D) + "<underlined> " + Form.repeat(" ", g) + "<reset>" + Form.repeat(" ", l - g));
|
||||
} else {
|
||||
int l = 44;
|
||||
int g = (int) (percent * l);
|
||||
g = (int) (percent * l);
|
||||
sendTitle(C.IRIS + thing + " " + C.BLUE + "<font:minecraft:uniform>" + Form.pc(percent, 0), 0, 500, 250);
|
||||
sendActionNoProcessing("" + "" + pulse("#00ff80", "#00373d", 1D) + "<underlined> " + Form.repeat(" ", g) + "<reset>" + Form.repeat(" ", l - g));
|
||||
}
|
||||
sendActionNoProcessing("" + "" + pulse("#00ff80", "#00373d", 1D) + "<underlined> " + Form.repeat(" ", g) + "<reset>" + Form.repeat(" ", l - g));
|
||||
}
|
||||
|
||||
public static String pulse(String colorA, String colorB, double speed) {
|
||||
@ -388,9 +387,8 @@ public class VolmitSender implements CommandSender {
|
||||
|
||||
|
||||
public void sendHeader(String name, int overrideLength) {
|
||||
int len = overrideLength;
|
||||
int h = name.length() + 2;
|
||||
String s = Form.repeat(" ", len - h - 4);
|
||||
String s = Form.repeat(" ", overrideLength - h - 4);
|
||||
String si = Form.repeat("(", 3);
|
||||
String so = Form.repeat(")", 3);
|
||||
String sf = "[";
|
||||
|
@ -19,7 +19,6 @@
|
||||
package com.volmit.iris.util.scheduling.jobs;
|
||||
|
||||
import com.volmit.iris.util.network.DL;
|
||||
import com.volmit.iris.util.network.DownloadMonitor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -35,16 +34,13 @@ public class DownloadJob implements Job {
|
||||
tw = 1;
|
||||
cw = 0;
|
||||
download = new DL.Download(new URL(url), destination, DL.DownloadFlag.CALCULATE_SIZE);
|
||||
download.monitor(new DownloadMonitor() {
|
||||
@Override
|
||||
public void onUpdate(DL.DownloadState state, double progress, long elapsed, long estimated, long bps, long iobps, long size, long downloaded, long buffer, double bufferuse) {
|
||||
download.monitor((state, progress, elapsed, estimated, bps, iobps, size, downloaded, buffer, bufferuse) -> {
|
||||
if (size == -1) {
|
||||
tw = 1;
|
||||
} else {
|
||||
tw = (int) (size / 100);
|
||||
cw = (int) (downloaded / 100);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user