mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 07:16:22 +00:00
Cleanup
This commit is contained in:
@@ -29,10 +29,10 @@ import com.volmit.iris.util.data.DoubleArrayUtils;
|
||||
*/
|
||||
public class Average {
|
||||
protected final double[] values;
|
||||
protected int cursor;
|
||||
private double average;
|
||||
private double lastSum;
|
||||
private boolean dirty;
|
||||
protected int cursor;
|
||||
private boolean brandNew;
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,14 +40,6 @@ public class AxisAlignedBB {
|
||||
this.zb = zb;
|
||||
}
|
||||
|
||||
public AxisAlignedBB shifted(IrisPosition p) {
|
||||
return shifted(p.getX(), p.getY(), p.getZ());
|
||||
}
|
||||
|
||||
public AxisAlignedBB shifted(double x, double y, double z) {
|
||||
return new AxisAlignedBB(min().add(new IrisPosition((int) x, (int) y, (int) z)), max().add(new IrisPosition((int) x, (int) y, (int) z)));
|
||||
}
|
||||
|
||||
public AxisAlignedBB(AlignedPoint a, AlignedPoint b) {
|
||||
this(a.getX(), b.getX(), a.getY(), b.getY(), a.getZ(), b.getZ());
|
||||
}
|
||||
@@ -56,6 +48,14 @@ public class AxisAlignedBB {
|
||||
this(a.getX(), b.getX(), a.getY(), b.getY(), a.getZ(), b.getZ());
|
||||
}
|
||||
|
||||
public AxisAlignedBB shifted(IrisPosition p) {
|
||||
return shifted(p.getX(), p.getY(), p.getZ());
|
||||
}
|
||||
|
||||
public AxisAlignedBB shifted(double x, double y, double z) {
|
||||
return new AxisAlignedBB(min().add(new IrisPosition((int) x, (int) y, (int) z)), max().add(new IrisPosition((int) x, (int) y, (int) z)));
|
||||
}
|
||||
|
||||
public boolean contains(AlignedPoint p) {
|
||||
return p.getX() >= xa && p.getX() <= xb && p.getY() >= ya && p.getZ() <= yb && p.getZ() >= za && p.getZ() <= zb;
|
||||
}
|
||||
|
||||
@@ -26,17 +26,16 @@ import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class BlockPosition {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
//Magic numbers
|
||||
private static final int m1 = 1 + MathHelper.f(MathHelper.c(30000000));
|
||||
private static final int m2 = 64 - (m1 * 2);
|
||||
private static final long m3 = m1 + m2;
|
||||
private static final long m4 = (1L << m1) - 1L;
|
||||
private static final long m5 = (1L << m2) - 1L;
|
||||
private static final long m4 = (1L << m1) - 1L;
|
||||
private static final long m6 = (1L << m1) - 1L;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public BlockPosition(int x, int y, int z) {
|
||||
this.x = x;
|
||||
@@ -44,6 +43,14 @@ public class BlockPosition {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static long toLong(int x, int y, int z) {
|
||||
long var3 = 0L;
|
||||
var3 |= (x & m4) << m3;
|
||||
var3 |= (y & m5);
|
||||
var3 |= (z & m6) << m2;
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z);
|
||||
@@ -82,14 +89,6 @@ public class BlockPosition {
|
||||
return toLong(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public static long toLong(int x, int y, int z) {
|
||||
long var3 = 0L;
|
||||
var3 |= (x & m4) << m3;
|
||||
var3 |= (y & m5);
|
||||
var3 |= (z & m6) << m2;
|
||||
return var3;
|
||||
}
|
||||
|
||||
public Block toBlock(World world) {
|
||||
return world.getBlockAt(x, y, z);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package com.volmit.iris.util.math;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class CDou {
|
||||
private double number;
|
||||
private final double max;
|
||||
private double number;
|
||||
|
||||
public CDou(double max) {
|
||||
number = 0;
|
||||
|
||||
@@ -48,6 +48,13 @@ public enum Direction {
|
||||
private final int z;
|
||||
private final CuboidDirection f;
|
||||
|
||||
Direction(int x, int y, int z, CuboidDirection f) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public static Direction getDirection(BlockFace f) {
|
||||
return switch (f) {
|
||||
case DOWN -> D;
|
||||
@@ -60,23 +67,6 @@ public enum Direction {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return switch (this) {
|
||||
case D -> "Down";
|
||||
case E -> "East";
|
||||
case N -> "North";
|
||||
case S -> "South";
|
||||
case U -> "Up";
|
||||
case W -> "West";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public boolean isVertical() {
|
||||
return equals(D) || equals(U);
|
||||
}
|
||||
|
||||
public static Direction closest(Vector v) {
|
||||
double m = Double.MAX_VALUE;
|
||||
Direction s = null;
|
||||
@@ -128,75 +118,6 @@ public enum Direction {
|
||||
return s;
|
||||
}
|
||||
|
||||
public Vector toVector() {
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
|
||||
public boolean isCrooked(Direction to) {
|
||||
if (equals(to.reverse())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !equals(to);
|
||||
}
|
||||
|
||||
Direction(int x, int y, int z, CuboidDirection f) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.f = f;
|
||||
}
|
||||
|
||||
public Vector angle(Vector initial, Direction d) {
|
||||
calculatePermutations();
|
||||
|
||||
for (Map.Entry<GBiset<Direction, Direction>, DOP> entry : permute.entrySet()) {
|
||||
GBiset<Direction, Direction> i = entry.getKey();
|
||||
if (i.getA().equals(this) && i.getB().equals(d)) {
|
||||
return entry.getValue().op(initial);
|
||||
}
|
||||
}
|
||||
|
||||
return initial;
|
||||
}
|
||||
|
||||
public Direction reverse() {
|
||||
switch (this) {
|
||||
case D:
|
||||
return U;
|
||||
case E:
|
||||
return W;
|
||||
case N:
|
||||
return S;
|
||||
case S:
|
||||
return N;
|
||||
case U:
|
||||
return D;
|
||||
case W:
|
||||
return E;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public CuboidDirection f() {
|
||||
return f;
|
||||
}
|
||||
|
||||
public static KList<Direction> news() {
|
||||
return new KList<Direction>().add(N, E, W, S);
|
||||
}
|
||||
@@ -245,32 +166,6 @@ public enum Direction {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the byte value represented in some directional blocks
|
||||
*
|
||||
* @return the byte value
|
||||
*/
|
||||
public byte byteValue() {
|
||||
switch (this) {
|
||||
case D:
|
||||
return 0;
|
||||
case E:
|
||||
return 5;
|
||||
case N:
|
||||
return 2;
|
||||
case S:
|
||||
return 3;
|
||||
case U:
|
||||
return 1;
|
||||
case W:
|
||||
return 4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void calculatePermutations() {
|
||||
if (permute != null) {
|
||||
return;
|
||||
@@ -359,6 +254,111 @@ public enum Direction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return switch (this) {
|
||||
case D -> "Down";
|
||||
case E -> "East";
|
||||
case N -> "North";
|
||||
case S -> "South";
|
||||
case U -> "Up";
|
||||
case W -> "West";
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public boolean isVertical() {
|
||||
return equals(D) || equals(U);
|
||||
}
|
||||
|
||||
public Vector toVector() {
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
|
||||
public boolean isCrooked(Direction to) {
|
||||
if (equals(to.reverse())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !equals(to);
|
||||
}
|
||||
|
||||
public Vector angle(Vector initial, Direction d) {
|
||||
calculatePermutations();
|
||||
|
||||
for (Map.Entry<GBiset<Direction, Direction>, DOP> entry : permute.entrySet()) {
|
||||
GBiset<Direction, Direction> i = entry.getKey();
|
||||
if (i.getA().equals(this) && i.getB().equals(d)) {
|
||||
return entry.getValue().op(initial);
|
||||
}
|
||||
}
|
||||
|
||||
return initial;
|
||||
}
|
||||
|
||||
public Direction reverse() {
|
||||
switch (this) {
|
||||
case D:
|
||||
return U;
|
||||
case E:
|
||||
return W;
|
||||
case N:
|
||||
return S;
|
||||
case S:
|
||||
return N;
|
||||
case U:
|
||||
return D;
|
||||
case W:
|
||||
return E;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public CuboidDirection f() {
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the byte value represented in some directional blocks
|
||||
*
|
||||
* @return the byte value
|
||||
*/
|
||||
public byte byteValue() {
|
||||
switch (this) {
|
||||
case D:
|
||||
return 0;
|
||||
case E:
|
||||
return 5;
|
||||
case N:
|
||||
return 2;
|
||||
case S:
|
||||
return 3;
|
||||
case U:
|
||||
return 1;
|
||||
case W:
|
||||
return 4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public BlockFace getFace() {
|
||||
return switch (this) {
|
||||
case D -> BlockFace.DOWN;
|
||||
|
||||
@@ -30,6 +30,21 @@ public class IrisMathHelper {
|
||||
private static final double[] f;
|
||||
private static final double[] g;
|
||||
|
||||
static {
|
||||
a = c(2.0f);
|
||||
c = new Random();
|
||||
d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
e = Double.longBitsToDouble(4805340802404319232L);
|
||||
f = new double[257];
|
||||
g = new double[257];
|
||||
for (int var2 = 0; var2 < 257; ++var2) {
|
||||
final double var3 = var2 / 256.0;
|
||||
final double var4 = Math.asin(var3);
|
||||
IrisMathHelper.g[var2] = Math.cos(var4);
|
||||
IrisMathHelper.f[var2] = var4;
|
||||
}
|
||||
}
|
||||
|
||||
public static float c(final float var0) {
|
||||
return (float) Math.sqrt(var0);
|
||||
}
|
||||
@@ -436,19 +451,4 @@ public class IrisMathHelper {
|
||||
public static float k(final float var0) {
|
||||
return var0 * var0;
|
||||
}
|
||||
|
||||
static {
|
||||
a = c(2.0f);
|
||||
c = new Random();
|
||||
d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
e = Double.longBitsToDouble(4805340802404319232L);
|
||||
f = new double[257];
|
||||
g = new double[257];
|
||||
for (int var2 = 0; var2 < 257; ++var2) {
|
||||
final double var3 = var2 / 256.0;
|
||||
final double var4 = Math.asin(var3);
|
||||
IrisMathHelper.g[var2] = Math.cos(var4);
|
||||
IrisMathHelper.f[var2] = var4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,12 @@ public class M {
|
||||
private static final float[] sin = new float[modulus];
|
||||
public static int tick = 0;
|
||||
|
||||
static {
|
||||
for (int i = 0; i < sin.length; i++) {
|
||||
sin[i] = (float) Math.sin((i * Math.PI) / (precision * 180));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales B by an external range change so that <br/>
|
||||
* <br/>
|
||||
@@ -355,12 +361,6 @@ public class M {
|
||||
return ms / 1000 / 60 / 60 / 24;
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < sin.length; i++) {
|
||||
sin[i] = (float) Math.sin((i * Math.PI) / (precision * 180));
|
||||
}
|
||||
}
|
||||
|
||||
private static float sinLookup(int a) {
|
||||
return a >= 0 ? sin[a % (modulus)] : -sin[-a % (modulus)];
|
||||
}
|
||||
|
||||
@@ -29,12 +29,6 @@ import java.util.UUID;
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
public class MathHelper {
|
||||
private static final int h = 1024;
|
||||
private static final float i = 1024.0F;
|
||||
private static final long j = 61440L;
|
||||
private static final long k = 16384L;
|
||||
private static final long l = -4611686018427387904L;
|
||||
private static final long m = -9223372036854775808L;
|
||||
public static final float a = 3.1415927F;
|
||||
public static final float b = 1.5707964F;
|
||||
public static final float c = 6.2831855F;
|
||||
@@ -42,6 +36,12 @@ public class MathHelper {
|
||||
public static final float e = 57.295776F;
|
||||
public static final float f = 1.0E-5F;
|
||||
public static final float g = c(2.0F);
|
||||
private static final int h = 1024;
|
||||
private static final float i = 1024.0F;
|
||||
private static final long j = 61440L;
|
||||
private static final long k = 16384L;
|
||||
private static final long l = -4611686018427387904L;
|
||||
private static final long m = -9223372036854775808L;
|
||||
private static final float n = 10430.378F;
|
||||
private static final float[] o = SystemUtils.a(new float[65536], (var0x) -> {
|
||||
for (int var1 = 0; var1 < var0x.length; ++var1) {
|
||||
@@ -58,6 +58,16 @@ public class MathHelper {
|
||||
private static final double[] v = new double[257];
|
||||
private static final double[] w = new double[257];
|
||||
|
||||
static {
|
||||
for (int var0 = 0; var0 < 257; ++var0) {
|
||||
double var1 = (double) var0 / 256.0D;
|
||||
double var3 = Math.asin(var1);
|
||||
w[var0] = Math.cos(var3);
|
||||
v[var0] = var3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MathHelper() {
|
||||
}
|
||||
|
||||
@@ -794,14 +804,4 @@ public class MathHelper {
|
||||
public static double a(int var0, double var1, int var3) {
|
||||
return Math.sqrt((double) (var0 * var0) + var1 * var1 + (double) (var3 * var3));
|
||||
}
|
||||
|
||||
static {
|
||||
for (int var0 = 0; var0 < 257; ++var0) {
|
||||
double var1 = (double) var0 / 256.0D;
|
||||
double var3 = Math.asin(var1);
|
||||
w[var0] = Math.cos(var3);
|
||||
v[var0] = var3;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RNG extends Random {
|
||||
public static final RNG r = new RNG();
|
||||
private static final char[] CHARGEN = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=!@#$%^&*()_+`~[];',./<>?:\\\"{}|\\\\".toCharArray();
|
||||
private static final long serialVersionUID = 5222938581174415179L;
|
||||
public static final RNG r = new RNG();
|
||||
private final long sx;
|
||||
|
||||
public RNG() {
|
||||
|
||||
@@ -46,14 +46,14 @@ public class RollingSequence extends Average {
|
||||
return f;
|
||||
}
|
||||
|
||||
public void setPrecision(boolean p) {
|
||||
this.precision = p;
|
||||
}
|
||||
|
||||
public boolean isPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
public void setPrecision(boolean p) {
|
||||
this.precision = p;
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
if (dirtyExtremes > (isPrecision() ? 0 : values.length)) {
|
||||
resetExtremes();
|
||||
|
||||
@@ -20,9 +20,9 @@ package com.volmit.iris.util.math;
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
public class Spiraler {
|
||||
private final Spiraled spiraled;
|
||||
int x, z, dx, dz, sizeX, sizeZ, t, maxI, i;
|
||||
int ox, oz;
|
||||
private final Spiraled spiraled;
|
||||
|
||||
public Spiraler(int sizeX, int sizeZ, Spiraled spiraled) {
|
||||
ox = 0;
|
||||
@@ -31,16 +31,16 @@ public class Spiraler {
|
||||
retarget(sizeX, sizeZ);
|
||||
}
|
||||
|
||||
static void Spiral(int X, int Y) {
|
||||
|
||||
}
|
||||
|
||||
public void drain() {
|
||||
while (hasNext()) {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
static void Spiral(int X, int Y) {
|
||||
|
||||
}
|
||||
|
||||
public Spiraler setOffset(int ox, int oz) {
|
||||
this.ox = ox;
|
||||
this.oz = oz;
|
||||
|
||||
@@ -23,6 +23,12 @@ package com.volmit.iris.util.math;
|
||||
* objects containing float or double values. This fixes Issue 36.
|
||||
*/
|
||||
class VecMathUtil {
|
||||
/**
|
||||
* Do not construct an instance of this class.
|
||||
*/
|
||||
private VecMathUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the representation of the specified floating-point
|
||||
* value according to the IEEE 754 floating-point "single format"
|
||||
@@ -78,11 +84,4 @@ class VecMathUtil {
|
||||
return Double.doubleToLongBits(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do not construct an instance of this class.
|
||||
*/
|
||||
private VecMathUtil() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user