@nxg-org/mineflayer-util-plugin 1.3.15 → 1.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/calcs/aabb.d.ts +12 -2
- package/lib/calcs/aabb.js +65 -2
- package/lib/calcs/minecraftCalcs.d.ts +0 -0
- package/lib/calcs/minecraftCalcs.js +663 -0
- package/package.json +1 -1
package/lib/calcs/aabb.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare class AABB {
|
|
|
8
8
|
maxZ: number;
|
|
9
9
|
constructor(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number);
|
|
10
10
|
static fromVecs(min: Vec3, max: Vec3): AABB;
|
|
11
|
+
static fromBlock(min: Vec3): AABB;
|
|
11
12
|
set(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
|
|
12
13
|
clone(): AABB;
|
|
13
14
|
toArray(): number[];
|
|
@@ -40,8 +41,17 @@ export declare class AABB {
|
|
|
40
41
|
} | null;
|
|
41
42
|
intersectsSegment(org: Vec3, dest: Vec3): Vec3 | null;
|
|
42
43
|
distanceFromRay(origin: Vec3, direction: Vec3, xz?: boolean): number;
|
|
44
|
+
intersect(aABB: AABB): AABB;
|
|
43
45
|
equals(other: AABB): boolean;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
xzDistanceToVec(pos: Vec3, heightOffset?: number): number;
|
|
47
|
+
distanceToVec(pos: Vec3, heightOffset?: number): number;
|
|
48
|
+
expandTowards(vec3: Vec3): AABB;
|
|
49
|
+
expandTowardsCoords(d: number, d2: number, d3: number): AABB;
|
|
50
|
+
moveCoords(d: number, d2: number, d3: number): AABB;
|
|
51
|
+
move(vec3: Vec3): AABB;
|
|
52
|
+
intersectsCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
53
|
+
collidesAABB(aABB: AABB): boolean;
|
|
54
|
+
collidesCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
55
|
+
getCenter(): Vec3;
|
|
46
56
|
}
|
|
47
57
|
export default AABB;
|
package/lib/calcs/aabb.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AABB = void 0;
|
|
4
4
|
const vec3_1 = require("vec3");
|
|
5
|
+
function lerp(f, f2, f3) {
|
|
6
|
+
return f2 + f * (f3 - f2);
|
|
7
|
+
}
|
|
5
8
|
class AABB {
|
|
6
9
|
constructor(x0, y0, z0, x1, y1, z1) {
|
|
7
10
|
this.minX = x0;
|
|
@@ -14,6 +17,9 @@ class AABB {
|
|
|
14
17
|
static fromVecs(min, max) {
|
|
15
18
|
return new AABB(min.x, min.y, min.z, max.x, max.y, max.z);
|
|
16
19
|
}
|
|
20
|
+
static fromBlock(min) {
|
|
21
|
+
return new AABB(min.x, min.y, min.z, min.x + 1.0, min.y + 1.0, min.z + 1.0);
|
|
22
|
+
}
|
|
17
23
|
set(x0, y0, z0, x1, y1, z1) {
|
|
18
24
|
this.minX = x0;
|
|
19
25
|
this.minY = y0;
|
|
@@ -184,6 +190,15 @@ class AABB {
|
|
|
184
190
|
}
|
|
185
191
|
return lo > hi ? Infinity : lo;
|
|
186
192
|
}
|
|
193
|
+
intersect(aABB) {
|
|
194
|
+
const d = Math.max(this.minX, aABB.minX);
|
|
195
|
+
const d2 = Math.max(this.minY, aABB.minY);
|
|
196
|
+
const d3 = Math.max(this.minZ, aABB.minZ);
|
|
197
|
+
const d4 = Math.min(this.maxX, aABB.maxX);
|
|
198
|
+
const d5 = Math.min(this.maxY, aABB.maxY);
|
|
199
|
+
const d6 = Math.min(this.maxZ, aABB.maxZ);
|
|
200
|
+
return new AABB(d, d2, d3, d4, d5, d6);
|
|
201
|
+
}
|
|
187
202
|
equals(other) {
|
|
188
203
|
return (this.minX === other.minX &&
|
|
189
204
|
this.minY === other.minY &&
|
|
@@ -192,19 +207,67 @@ class AABB {
|
|
|
192
207
|
this.maxY === other.maxY &&
|
|
193
208
|
this.maxZ === other.maxZ);
|
|
194
209
|
}
|
|
195
|
-
|
|
210
|
+
xzDistanceToVec(pos, heightOffset = 0) {
|
|
196
211
|
const { x, y, z } = pos.offset(0, heightOffset, 0);
|
|
197
212
|
let dx = Math.max(this.minX - x, 0, x - this.maxX);
|
|
198
213
|
let dz = Math.max(this.minZ - z, 0, z - this.maxZ);
|
|
199
214
|
return Math.sqrt(dx * dx + dz * dz);
|
|
200
215
|
}
|
|
201
|
-
|
|
216
|
+
distanceToVec(pos, heightOffset = 0) {
|
|
202
217
|
const { x, y, z } = pos.offset(0, heightOffset, 0);
|
|
203
218
|
let dx = Math.max(this.minX - x, 0, x - this.maxX);
|
|
204
219
|
let dy = Math.max(this.minY - y, 0, y - this.maxY);
|
|
205
220
|
let dz = Math.max(this.minZ - z, 0, z - this.maxZ);
|
|
206
221
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
207
222
|
}
|
|
223
|
+
expandTowards(vec3) {
|
|
224
|
+
return this.expandTowardsCoords(vec3.x, vec3.y, vec3.z);
|
|
225
|
+
}
|
|
226
|
+
expandTowardsCoords(d, d2, d3) {
|
|
227
|
+
let d4 = this.minX;
|
|
228
|
+
let d5 = this.minY;
|
|
229
|
+
let d6 = this.minZ;
|
|
230
|
+
let d7 = this.maxX;
|
|
231
|
+
let d8 = this.maxY;
|
|
232
|
+
let d9 = this.maxZ;
|
|
233
|
+
if (d < 0.0) {
|
|
234
|
+
d4 += d;
|
|
235
|
+
}
|
|
236
|
+
else if (d > 0.0) {
|
|
237
|
+
d7 += d;
|
|
238
|
+
}
|
|
239
|
+
if (d2 < 0.0) {
|
|
240
|
+
d5 += d2;
|
|
241
|
+
}
|
|
242
|
+
else if (d2 > 0.0) {
|
|
243
|
+
d8 += d2;
|
|
244
|
+
}
|
|
245
|
+
if (d3 < 0.0) {
|
|
246
|
+
d6 += d3;
|
|
247
|
+
}
|
|
248
|
+
else if (d3 > 0.0) {
|
|
249
|
+
d9 += d3;
|
|
250
|
+
}
|
|
251
|
+
return new AABB(d4, d5, d6, d7, d8, d9);
|
|
252
|
+
}
|
|
253
|
+
moveCoords(d, d2, d3) {
|
|
254
|
+
return new AABB(this.minX + d, this.minY + d2, this.minZ + d3, this.maxX + d, this.maxY + d2, this.maxZ + d3);
|
|
255
|
+
}
|
|
256
|
+
move(vec3) {
|
|
257
|
+
return new AABB(this.minX + vec3.x, this.minY + vec3.y, this.minZ + vec3.z, this.maxX + vec3.x, this.maxY + vec3.y, this.maxZ + vec3.z);
|
|
258
|
+
}
|
|
259
|
+
intersectsCoords(d, d2, d3, d4, d5, d6) {
|
|
260
|
+
return this.minX < d4 && this.maxX > d && this.minY < d5 && this.maxY > d2 && this.minZ < d6 && this.maxZ > d3;
|
|
261
|
+
}
|
|
262
|
+
collidesAABB(aABB) {
|
|
263
|
+
return this.collidesCoords(aABB.minX, aABB.minY, aABB.minZ, aABB.maxX, aABB.maxY, aABB.maxZ);
|
|
264
|
+
}
|
|
265
|
+
collidesCoords(d, d2, d3, d4, d5, d6) {
|
|
266
|
+
return this.minX <= d4 && this.maxX >= d && this.minY <= d5 && this.maxY >= d2 && this.minZ <= d6 && this.maxZ >= d3;
|
|
267
|
+
}
|
|
268
|
+
getCenter() {
|
|
269
|
+
return new vec3_1.Vec3(lerp(0.5, this.minX, this.maxX), lerp(0.5, this.minY, this.maxY), lerp(0.5, this.minZ, this.maxZ));
|
|
270
|
+
}
|
|
208
271
|
}
|
|
209
272
|
exports.AABB = AABB;
|
|
210
273
|
exports.default = AABB;
|
|
File without changes
|
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// /*
|
|
3
|
+
// * Decompiled with CFR 0.146.
|
|
4
|
+
// *
|
|
5
|
+
// * Could not load the following classes:
|
|
6
|
+
// * org.apache.commons.lang3.math.NumberUtils
|
|
7
|
+
// */
|
|
8
|
+
// export class Mth {
|
|
9
|
+
// private static final int BIG_ENOUGH_INT = 1024;
|
|
10
|
+
// private static final float BIG_ENOUGH_FLOAT = 1024.0f;
|
|
11
|
+
// private static final long UUID_VERSION = 61440L;
|
|
12
|
+
// private static final long UUID_VERSION_TYPE_4 = 16384L;
|
|
13
|
+
// private static final long UUID_VARIANT = -4611686018427387904L;
|
|
14
|
+
// private static final long UUID_VARIANT_2 = Long.MIN_VALUE;
|
|
15
|
+
// public static final float PI = 3.1415927f;
|
|
16
|
+
// public static final float HALF_PI = 1.5707964f;
|
|
17
|
+
// public static final float TWO_PI = 6.2831855f;
|
|
18
|
+
// public static final float DEG_TO_RAD = 0.017453292f;
|
|
19
|
+
// public static final float RAD_TO_DEG = 57.295776f;
|
|
20
|
+
// public static final float EPSILON = 1.0E-5f;
|
|
21
|
+
// public static final float SQRT_OF_TWO = Mth.sqrt(2.0f);
|
|
22
|
+
// private static final float SIN_SCALE = 10430.378f;
|
|
23
|
+
// private static final float[] SIN = Util.make(new float[65536], arrf -> {
|
|
24
|
+
// for (int i = 0; i < ((float[])arrf).length; ++i) {
|
|
25
|
+
// arrf[i] = (float)Math.sin((double)i * 3.141592653589793 * 2.0 / 65536.0);
|
|
26
|
+
// }
|
|
27
|
+
// });
|
|
28
|
+
// private static final Random RANDOM = new Random();
|
|
29
|
+
// private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = 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};
|
|
30
|
+
// private static final double ONE_SIXTH = 0.16666666666666666;
|
|
31
|
+
// private static final int FRAC_EXP = 8;
|
|
32
|
+
// private static final int LUT_SIZE = 257;
|
|
33
|
+
// private static final double FRAC_BIAS = Double.longBitsToDouble(4805340802404319232L);
|
|
34
|
+
// private static final double[] ASIN_TAB = new double[257];
|
|
35
|
+
// private static final double[] COS_TAB = new double[257];
|
|
36
|
+
// public static float sin(float f) {
|
|
37
|
+
// return SIN[(int)(f * 10430.378f) & 0xFFFF];
|
|
38
|
+
// }
|
|
39
|
+
// public static float cos(float f) {
|
|
40
|
+
// return SIN[(int)(f * 10430.378f + 16384.0f) & 0xFFFF];
|
|
41
|
+
// }
|
|
42
|
+
// public static float sqrt(float f) {
|
|
43
|
+
// return (float)Math.sqrt(f);
|
|
44
|
+
// }
|
|
45
|
+
// public static int floor(float f) {
|
|
46
|
+
// int n = (int)f;
|
|
47
|
+
// return f < (float)n ? n - 1 : n;
|
|
48
|
+
// }
|
|
49
|
+
// public static int fastFloor(double d) {
|
|
50
|
+
// return (int)(d + 1024.0) - 1024;
|
|
51
|
+
// }
|
|
52
|
+
// public static int floor(double d) {
|
|
53
|
+
// int n = (int)d;
|
|
54
|
+
// return d < (double)n ? n - 1 : n;
|
|
55
|
+
// }
|
|
56
|
+
// public static long lfloor(double d) {
|
|
57
|
+
// long l = (long)d;
|
|
58
|
+
// return d < (double)l ? l - 1L : l;
|
|
59
|
+
// }
|
|
60
|
+
// public static int absFloor(double d) {
|
|
61
|
+
// return (int)(d >= 0.0 ? d : -d + 1.0);
|
|
62
|
+
// }
|
|
63
|
+
// public static float abs(float f) {
|
|
64
|
+
// return Math.abs(f);
|
|
65
|
+
// }
|
|
66
|
+
// public static int abs(int n) {
|
|
67
|
+
// return Math.abs(n);
|
|
68
|
+
// }
|
|
69
|
+
// public static int ceil(float f) {
|
|
70
|
+
// int n = (int)f;
|
|
71
|
+
// return f > (float)n ? n + 1 : n;
|
|
72
|
+
// }
|
|
73
|
+
// public static int ceil(double d) {
|
|
74
|
+
// int n = (int)d;
|
|
75
|
+
// return d > (double)n ? n + 1 : n;
|
|
76
|
+
// }
|
|
77
|
+
// public static byte clamp(byte by, byte by2, byte by3) {
|
|
78
|
+
// if (by < by2) {
|
|
79
|
+
// return by2;
|
|
80
|
+
// }
|
|
81
|
+
// if (by > by3) {
|
|
82
|
+
// return by3;
|
|
83
|
+
// }
|
|
84
|
+
// return by;
|
|
85
|
+
// }
|
|
86
|
+
// public static int clamp(int n, int n2, int n3) {
|
|
87
|
+
// if (n < n2) {
|
|
88
|
+
// return n2;
|
|
89
|
+
// }
|
|
90
|
+
// if (n > n3) {
|
|
91
|
+
// return n3;
|
|
92
|
+
// }
|
|
93
|
+
// return n;
|
|
94
|
+
// }
|
|
95
|
+
// public static long clamp(long l, long l2, long l3) {
|
|
96
|
+
// if (l < l2) {
|
|
97
|
+
// return l2;
|
|
98
|
+
// }
|
|
99
|
+
// if (l > l3) {
|
|
100
|
+
// return l3;
|
|
101
|
+
// }
|
|
102
|
+
// return l;
|
|
103
|
+
// }
|
|
104
|
+
// public static float clamp(float f, float f2, float f3) {
|
|
105
|
+
// if (f < f2) {
|
|
106
|
+
// return f2;
|
|
107
|
+
// }
|
|
108
|
+
// if (f > f3) {
|
|
109
|
+
// return f3;
|
|
110
|
+
// }
|
|
111
|
+
// return f;
|
|
112
|
+
// }
|
|
113
|
+
// public static double clamp(double d, double d2, double d3) {
|
|
114
|
+
// if (d < d2) {
|
|
115
|
+
// return d2;
|
|
116
|
+
// }
|
|
117
|
+
// if (d > d3) {
|
|
118
|
+
// return d3;
|
|
119
|
+
// }
|
|
120
|
+
// return d;
|
|
121
|
+
// }
|
|
122
|
+
// public static double clampedLerp(double d, double d2, double d3) {
|
|
123
|
+
// if (d3 < 0.0) {
|
|
124
|
+
// return d;
|
|
125
|
+
// }
|
|
126
|
+
// if (d3 > 1.0) {
|
|
127
|
+
// return d2;
|
|
128
|
+
// }
|
|
129
|
+
// return Mth.lerp(d3, d, d2);
|
|
130
|
+
// }
|
|
131
|
+
// public static float clampedLerp(float f, float f2, float f3) {
|
|
132
|
+
// if (f3 < 0.0f) {
|
|
133
|
+
// return f;
|
|
134
|
+
// }
|
|
135
|
+
// if (f3 > 1.0f) {
|
|
136
|
+
// return f2;
|
|
137
|
+
// }
|
|
138
|
+
// return Mth.lerp(f3, f, f2);
|
|
139
|
+
// }
|
|
140
|
+
// public static double absMax(double d, double d2) {
|
|
141
|
+
// if (d < 0.0) {
|
|
142
|
+
// d = -d;
|
|
143
|
+
// }
|
|
144
|
+
// if (d2 < 0.0) {
|
|
145
|
+
// d2 = -d2;
|
|
146
|
+
// }
|
|
147
|
+
// return d > d2 ? d : d2;
|
|
148
|
+
// }
|
|
149
|
+
// public static int intFloorDiv(int n, int n2) {
|
|
150
|
+
// return Math.floorDiv(n, n2);
|
|
151
|
+
// }
|
|
152
|
+
// public static int nextInt(Random random, int n, int n2) {
|
|
153
|
+
// if (n >= n2) {
|
|
154
|
+
// return n;
|
|
155
|
+
// }
|
|
156
|
+
// return random.nextInt(n2 - n + 1) + n;
|
|
157
|
+
// }
|
|
158
|
+
// public static float nextFloat(Random random, float f, float f2) {
|
|
159
|
+
// if (f >= f2) {
|
|
160
|
+
// return f;
|
|
161
|
+
// }
|
|
162
|
+
// return random.nextFloat() * (f2 - f) + f;
|
|
163
|
+
// }
|
|
164
|
+
// public static double nextDouble(Random random, double d, double d2) {
|
|
165
|
+
// if (d >= d2) {
|
|
166
|
+
// return d;
|
|
167
|
+
// }
|
|
168
|
+
// return random.nextDouble() * (d2 - d) + d;
|
|
169
|
+
// }
|
|
170
|
+
// public static double average(long[] arrl) {
|
|
171
|
+
// long l = 0L;
|
|
172
|
+
// for (long l2 : arrl) {
|
|
173
|
+
// l += l2;
|
|
174
|
+
// }
|
|
175
|
+
// return (double)l / (double)arrl.length;
|
|
176
|
+
// }
|
|
177
|
+
// public static boolean equal(float f, float f2) {
|
|
178
|
+
// return Math.abs(f2 - f) < 1.0E-5f;
|
|
179
|
+
// }
|
|
180
|
+
// public static boolean equal(double d, double d2) {
|
|
181
|
+
// return Math.abs(d2 - d) < 9.999999747378752E-6;
|
|
182
|
+
// }
|
|
183
|
+
// public static int positiveModulo(int n, int n2) {
|
|
184
|
+
// return Math.floorMod(n, n2);
|
|
185
|
+
// }
|
|
186
|
+
// public static float positiveModulo(float f, float f2) {
|
|
187
|
+
// return (f % f2 + f2) % f2;
|
|
188
|
+
// }
|
|
189
|
+
// public static double positiveModulo(double d, double d2) {
|
|
190
|
+
// return (d % d2 + d2) % d2;
|
|
191
|
+
// }
|
|
192
|
+
// public static int wrapDegrees(int n) {
|
|
193
|
+
// int n2 = n % 360;
|
|
194
|
+
// if (n2 >= 180) {
|
|
195
|
+
// n2 -= 360;
|
|
196
|
+
// }
|
|
197
|
+
// if (n2 < -180) {
|
|
198
|
+
// n2 += 360;
|
|
199
|
+
// }
|
|
200
|
+
// return n2;
|
|
201
|
+
// }
|
|
202
|
+
// public static float wrapDegrees(float f) {
|
|
203
|
+
// float f2 = f % 360.0f;
|
|
204
|
+
// if (f2 >= 180.0f) {
|
|
205
|
+
// f2 -= 360.0f;
|
|
206
|
+
// }
|
|
207
|
+
// if (f2 < -180.0f) {
|
|
208
|
+
// f2 += 360.0f;
|
|
209
|
+
// }
|
|
210
|
+
// return f2;
|
|
211
|
+
// }
|
|
212
|
+
// public static double wrapDegrees(double d) {
|
|
213
|
+
// double d2 = d % 360.0;
|
|
214
|
+
// if (d2 >= 180.0) {
|
|
215
|
+
// d2 -= 360.0;
|
|
216
|
+
// }
|
|
217
|
+
// if (d2 < -180.0) {
|
|
218
|
+
// d2 += 360.0;
|
|
219
|
+
// }
|
|
220
|
+
// return d2;
|
|
221
|
+
// }
|
|
222
|
+
// public static float degreesDifference(float f, float f2) {
|
|
223
|
+
// return Mth.wrapDegrees(f2 - f);
|
|
224
|
+
// }
|
|
225
|
+
// public static float degreesDifferenceAbs(float f, float f2) {
|
|
226
|
+
// return Mth.abs(Mth.degreesDifference(f, f2));
|
|
227
|
+
// }
|
|
228
|
+
// public static float rotateIfNecessary(float f, float f2, float f3) {
|
|
229
|
+
// float f4 = Mth.degreesDifference(f, f2);
|
|
230
|
+
// float f5 = Mth.clamp(f4, -f3, f3);
|
|
231
|
+
// return f2 - f5;
|
|
232
|
+
// }
|
|
233
|
+
// public static float approach(float f, float f2, float f3) {
|
|
234
|
+
// f3 = Mth.abs(f3);
|
|
235
|
+
// if (f < f2) {
|
|
236
|
+
// return Mth.clamp(f + f3, f, f2);
|
|
237
|
+
// }
|
|
238
|
+
// return Mth.clamp(f - f3, f2, f);
|
|
239
|
+
// }
|
|
240
|
+
// public static float approachDegrees(float f, float f2, float f3) {
|
|
241
|
+
// float f4 = Mth.degreesDifference(f, f2);
|
|
242
|
+
// return Mth.approach(f, f + f4, f3);
|
|
243
|
+
// }
|
|
244
|
+
// public static int getInt(String string, int n) {
|
|
245
|
+
// return NumberUtils.toInt((String)string, (int)n);
|
|
246
|
+
// }
|
|
247
|
+
// public static int getInt(String string, int n, int n2) {
|
|
248
|
+
// return Math.max(n2, Mth.getInt(string, n));
|
|
249
|
+
// }
|
|
250
|
+
// public static double getDouble(String string, double d) {
|
|
251
|
+
// try {
|
|
252
|
+
// return Double.parseDouble(string);
|
|
253
|
+
// }
|
|
254
|
+
// catch (Throwable throwable) {
|
|
255
|
+
// return d;
|
|
256
|
+
// }
|
|
257
|
+
// }
|
|
258
|
+
// public static double getDouble(String string, double d, double d2) {
|
|
259
|
+
// return Math.max(d2, Mth.getDouble(string, d));
|
|
260
|
+
// }
|
|
261
|
+
// public static int smallestEncompassingPowerOfTwo(int n) {
|
|
262
|
+
// int n2 = n - 1;
|
|
263
|
+
// n2 |= n2 >> 1;
|
|
264
|
+
// n2 |= n2 >> 2;
|
|
265
|
+
// n2 |= n2 >> 4;
|
|
266
|
+
// n2 |= n2 >> 8;
|
|
267
|
+
// n2 |= n2 >> 16;
|
|
268
|
+
// return n2 + 1;
|
|
269
|
+
// }
|
|
270
|
+
// public static boolean isPowerOfTwo(int n) {
|
|
271
|
+
// return n != 0 && (n & n - 1) == 0;
|
|
272
|
+
// }
|
|
273
|
+
// public static int ceillog2(int n) {
|
|
274
|
+
// n = Mth.isPowerOfTwo(n) ? n : Mth.smallestEncompassingPowerOfTwo(n);
|
|
275
|
+
// return MULTIPLY_DE_BRUIJN_BIT_POSITION[(int)((long)n * 125613361L >> 27) & 0x1F];
|
|
276
|
+
// }
|
|
277
|
+
// public static int log2(int n) {
|
|
278
|
+
// return Mth.ceillog2(n) - (Mth.isPowerOfTwo(n) ? 0 : 1);
|
|
279
|
+
// }
|
|
280
|
+
// public static int color(float f, float f2, float f3) {
|
|
281
|
+
// return Mth.color(Mth.floor(f * 255.0f), Mth.floor(f2 * 255.0f), Mth.floor(f3 * 255.0f));
|
|
282
|
+
// }
|
|
283
|
+
// public static int color(int n, int n2, int n3) {
|
|
284
|
+
// int n4 = n;
|
|
285
|
+
// n4 = (n4 << 8) + n2;
|
|
286
|
+
// n4 = (n4 << 8) + n3;
|
|
287
|
+
// return n4;
|
|
288
|
+
// }
|
|
289
|
+
// public static int colorMultiply(int n, int n2) {
|
|
290
|
+
// int n3 = (n & 0xFF0000) >> 16;
|
|
291
|
+
// int n4 = (n2 & 0xFF0000) >> 16;
|
|
292
|
+
// int n5 = (n & 0xFF00) >> 8;
|
|
293
|
+
// int n6 = (n2 & 0xFF00) >> 8;
|
|
294
|
+
// int n7 = (n & 0xFF) >> 0;
|
|
295
|
+
// int n8 = (n2 & 0xFF) >> 0;
|
|
296
|
+
// int n9 = (int)((float)n3 * (float)n4 / 255.0f);
|
|
297
|
+
// int n10 = (int)((float)n5 * (float)n6 / 255.0f);
|
|
298
|
+
// int n11 = (int)((float)n7 * (float)n8 / 255.0f);
|
|
299
|
+
// return n & 0xFF000000 | n9 << 16 | n10 << 8 | n11;
|
|
300
|
+
// }
|
|
301
|
+
// public static int colorMultiply(int n, float f, float f2, float f3) {
|
|
302
|
+
// int n2 = (n & 0xFF0000) >> 16;
|
|
303
|
+
// int n3 = (n & 0xFF00) >> 8;
|
|
304
|
+
// int n4 = (n & 0xFF) >> 0;
|
|
305
|
+
// int n5 = (int)((float)n2 * f);
|
|
306
|
+
// int n6 = (int)((float)n3 * f2);
|
|
307
|
+
// int n7 = (int)((float)n4 * f3);
|
|
308
|
+
// return n & 0xFF000000 | n5 << 16 | n6 << 8 | n7;
|
|
309
|
+
// }
|
|
310
|
+
// public static float frac(float f) {
|
|
311
|
+
// return f - (float)Mth.floor(f);
|
|
312
|
+
// }
|
|
313
|
+
// public static double frac(double d) {
|
|
314
|
+
// return d - (double)Mth.lfloor(d);
|
|
315
|
+
// }
|
|
316
|
+
// public static Vec3 catmullRomSplinePos(Vec3 vec3, Vec3 vec32, Vec3 vec33, Vec3 vec34, double d) {
|
|
317
|
+
// double d2 = ((-d + 2.0) * d - 1.0) * d * 0.5;
|
|
318
|
+
// double d3 = ((3.0 * d - 5.0) * d * d + 2.0) * 0.5;
|
|
319
|
+
// double d4 = ((-3.0 * d + 4.0) * d + 1.0) * d * 0.5;
|
|
320
|
+
// double d5 = (d - 1.0) * d * d * 0.5;
|
|
321
|
+
// return new Vec3(vec3.x * d2 + vec32.x * d3 + vec33.x * d4 + vec34.x * d5, vec3.y * d2 + vec32.y * d3 + vec33.y * d4 + vec34.y * d5, vec3.z * d2 + vec32.z * d3 + vec33.z * d4 + vec34.z * d5);
|
|
322
|
+
// }
|
|
323
|
+
// public static long getSeed(Vec3i vec3i) {
|
|
324
|
+
// return Mth.getSeed(vec3i.getX(), vec3i.getY(), vec3i.getZ());
|
|
325
|
+
// }
|
|
326
|
+
// public static long getSeed(int n, int n2, int n3) {
|
|
327
|
+
// long l = (long)(n * 3129871) ^ (long)n3 * 116129781L ^ (long)n2;
|
|
328
|
+
// l = l * l * 42317861L + l * 11L;
|
|
329
|
+
// return l >> 16;
|
|
330
|
+
// }
|
|
331
|
+
// public static UUID createInsecureUUID(Random random) {
|
|
332
|
+
// long l = random.nextLong() & 0xFFFFFFFFFFFF0FFFL | 0x4000L;
|
|
333
|
+
// long l2 = random.nextLong() & 0x3FFFFFFFFFFFFFFFL | Long.MIN_VALUE;
|
|
334
|
+
// return new UUID(l, l2);
|
|
335
|
+
// }
|
|
336
|
+
// public static UUID createInsecureUUID() {
|
|
337
|
+
// return Mth.createInsecureUUID(RANDOM);
|
|
338
|
+
// }
|
|
339
|
+
// public static double inverseLerp(double d, double d2, double d3) {
|
|
340
|
+
// return (d - d2) / (d3 - d2);
|
|
341
|
+
// }
|
|
342
|
+
// public static boolean rayIntersectsAABB(Vec3 vec3, Vec3 vec32, AABB aABB) {
|
|
343
|
+
// double d = (aABB.minX + aABB.maxX) * 0.5;
|
|
344
|
+
// double d2 = (aABB.maxX - aABB.minX) * 0.5;
|
|
345
|
+
// double d3 = vec3.x - d;
|
|
346
|
+
// if (Math.abs(d3) > d2 && d3 * vec32.x >= 0.0) {
|
|
347
|
+
// return false;
|
|
348
|
+
// }
|
|
349
|
+
// double d4 = (aABB.minY + aABB.maxY) * 0.5;
|
|
350
|
+
// double d5 = (aABB.maxY - aABB.minY) * 0.5;
|
|
351
|
+
// double d6 = vec3.y - d4;
|
|
352
|
+
// if (Math.abs(d6) > d5 && d6 * vec32.y >= 0.0) {
|
|
353
|
+
// return false;
|
|
354
|
+
// }
|
|
355
|
+
// double d7 = (aABB.minZ + aABB.maxZ) * 0.5;
|
|
356
|
+
// double d8 = (aABB.maxZ - aABB.minZ) * 0.5;
|
|
357
|
+
// double d9 = vec3.z - d7;
|
|
358
|
+
// if (Math.abs(d9) > d8 && d9 * vec32.z >= 0.0) {
|
|
359
|
+
// return false;
|
|
360
|
+
// }
|
|
361
|
+
// double d10 = Math.abs(vec32.x);
|
|
362
|
+
// double d11 = Math.abs(vec32.y);
|
|
363
|
+
// double d12 = Math.abs(vec32.z);
|
|
364
|
+
// double d13 = vec32.y * d9 - vec32.z * d6;
|
|
365
|
+
// if (Math.abs(d13) > d5 * d12 + d8 * d11) {
|
|
366
|
+
// return false;
|
|
367
|
+
// }
|
|
368
|
+
// d13 = vec32.z * d3 - vec32.x * d9;
|
|
369
|
+
// if (Math.abs(d13) > d2 * d12 + d8 * d10) {
|
|
370
|
+
// return false;
|
|
371
|
+
// }
|
|
372
|
+
// d13 = vec32.x * d6 - vec32.y * d3;
|
|
373
|
+
// return Math.abs(d13) < d2 * d11 + d5 * d10;
|
|
374
|
+
// }
|
|
375
|
+
// public static double atan2(double d, double d2) {
|
|
376
|
+
// boolean bl;
|
|
377
|
+
// boolean bl2;
|
|
378
|
+
// double d3;
|
|
379
|
+
// boolean bl3;
|
|
380
|
+
// double d4 = d2 * d2 + d * d;
|
|
381
|
+
// if (Double.isNaN(d4)) {
|
|
382
|
+
// return Double.NaN;
|
|
383
|
+
// }
|
|
384
|
+
// boolean bl4 = bl = d < 0.0;
|
|
385
|
+
// if (bl) {
|
|
386
|
+
// d = -d;
|
|
387
|
+
// }
|
|
388
|
+
// boolean bl5 = bl3 = d2 < 0.0;
|
|
389
|
+
// if (bl3) {
|
|
390
|
+
// d2 = -d2;
|
|
391
|
+
// }
|
|
392
|
+
// boolean bl6 = bl2 = d > d2;
|
|
393
|
+
// if (bl2) {
|
|
394
|
+
// d3 = d2;
|
|
395
|
+
// d2 = d;
|
|
396
|
+
// d = d3;
|
|
397
|
+
// }
|
|
398
|
+
// d3 = Mth.fastInvSqrt(d4);
|
|
399
|
+
// double d5 = FRAC_BIAS + (d *= d3);
|
|
400
|
+
// int n = (int)Double.doubleToRawLongBits(d5);
|
|
401
|
+
// double d6 = ASIN_TAB[n];
|
|
402
|
+
// double d7 = COS_TAB[n];
|
|
403
|
+
// double d8 = d5 - FRAC_BIAS;
|
|
404
|
+
// double d9 = d * d7 - (d2 *= d3) * d8;
|
|
405
|
+
// double d10 = (6.0 + d9 * d9) * d9 * 0.16666666666666666;
|
|
406
|
+
// double d11 = d6 + d10;
|
|
407
|
+
// if (bl2) {
|
|
408
|
+
// d11 = 1.5707963267948966 - d11;
|
|
409
|
+
// }
|
|
410
|
+
// if (bl3) {
|
|
411
|
+
// d11 = 3.141592653589793 - d11;
|
|
412
|
+
// }
|
|
413
|
+
// if (bl) {
|
|
414
|
+
// d11 = -d11;
|
|
415
|
+
// }
|
|
416
|
+
// return d11;
|
|
417
|
+
// }
|
|
418
|
+
// public static float fastInvSqrt(float f) {
|
|
419
|
+
// float f2 = 0.5f * f;
|
|
420
|
+
// int n = Float.floatToIntBits(f);
|
|
421
|
+
// n = 1597463007 - (n >> 1);
|
|
422
|
+
// f = Float.intBitsToFloat(n);
|
|
423
|
+
// f *= 1.5f - f2 * f * f;
|
|
424
|
+
// return f;
|
|
425
|
+
// }
|
|
426
|
+
// public static double fastInvSqrt(double d) {
|
|
427
|
+
// double d2 = 0.5 * d;
|
|
428
|
+
// long l = Double.doubleToRawLongBits(d);
|
|
429
|
+
// l = 6910469410427058090L - (l >> 1);
|
|
430
|
+
// d = Double.longBitsToDouble(l);
|
|
431
|
+
// d *= 1.5 - d2 * d * d;
|
|
432
|
+
// return d;
|
|
433
|
+
// }
|
|
434
|
+
// public static float fastInvCubeRoot(float f) {
|
|
435
|
+
// int n = Float.floatToIntBits(f);
|
|
436
|
+
// n = 1419967116 - n / 3;
|
|
437
|
+
// float f2 = Float.intBitsToFloat(n);
|
|
438
|
+
// f2 = 0.6666667f * f2 + 1.0f / (3.0f * f2 * f2 * f);
|
|
439
|
+
// f2 = 0.6666667f * f2 + 1.0f / (3.0f * f2 * f2 * f);
|
|
440
|
+
// return f2;
|
|
441
|
+
// }
|
|
442
|
+
// public static int hsvToRgb(float f, float f2, float f3) {
|
|
443
|
+
// float f4;
|
|
444
|
+
// float f5;
|
|
445
|
+
// int n = (int)(f * 6.0f) % 6;
|
|
446
|
+
// float f6 = f * 6.0f - (float)n;
|
|
447
|
+
// float f7 = f3 * (1.0f - f2);
|
|
448
|
+
// float f8 = f3 * (1.0f - f6 * f2);
|
|
449
|
+
// float f9 = f3 * (1.0f - (1.0f - f6) * f2);
|
|
450
|
+
// float f10 = switch (n) {
|
|
451
|
+
// case 0 -> {
|
|
452
|
+
// f4 = f3;
|
|
453
|
+
// f5 = f9;
|
|
454
|
+
// break f7;
|
|
455
|
+
// }
|
|
456
|
+
// case 1 -> {
|
|
457
|
+
// f4 = f8;
|
|
458
|
+
// f5 = f3;
|
|
459
|
+
// break f7;
|
|
460
|
+
// }
|
|
461
|
+
// case 2 -> {
|
|
462
|
+
// f4 = f7;
|
|
463
|
+
// f5 = f3;
|
|
464
|
+
// break f9;
|
|
465
|
+
// }
|
|
466
|
+
// case 3 -> {
|
|
467
|
+
// f4 = f7;
|
|
468
|
+
// f5 = f8;
|
|
469
|
+
// break f3;
|
|
470
|
+
// }
|
|
471
|
+
// case 4 -> {
|
|
472
|
+
// f4 = f9;
|
|
473
|
+
// f5 = f7;
|
|
474
|
+
// break f3;
|
|
475
|
+
// }
|
|
476
|
+
// case 5 -> {
|
|
477
|
+
// f4 = f3;
|
|
478
|
+
// f5 = f7;
|
|
479
|
+
// break f8;
|
|
480
|
+
// }
|
|
481
|
+
// default -> throw new java.lang.RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + f + ", " + f2 + ", " + f3);
|
|
482
|
+
// };
|
|
483
|
+
// int n2 = Mth.clamp((int)(f4 * 255.0f), 0, 255);
|
|
484
|
+
// int n3 = Mth.clamp((int)(f5 * 255.0f), 0, 255);
|
|
485
|
+
// int n4 = Mth.clamp((int)(f10 * 255.0f), 0, 255);
|
|
486
|
+
// return n2 << 16 | n3 << 8 | n4;
|
|
487
|
+
// }
|
|
488
|
+
// public static int murmurHash3Mixer(int n) {
|
|
489
|
+
// n ^= n >>> 16;
|
|
490
|
+
// n *= -2048144789;
|
|
491
|
+
// n ^= n >>> 13;
|
|
492
|
+
// n *= -1028477387;
|
|
493
|
+
// n ^= n >>> 16;
|
|
494
|
+
// return n;
|
|
495
|
+
// }
|
|
496
|
+
// public static long murmurHash3Mixer(long l) {
|
|
497
|
+
// l ^= l >>> 33;
|
|
498
|
+
// l *= -49064778989728563L;
|
|
499
|
+
// l ^= l >>> 33;
|
|
500
|
+
// l *= -4265267296055464877L;
|
|
501
|
+
// l ^= l >>> 33;
|
|
502
|
+
// return l;
|
|
503
|
+
// }
|
|
504
|
+
// public static double[] cumulativeSum(double ... arrd) {
|
|
505
|
+
// float f = 0.0f;
|
|
506
|
+
// for (double d : arrd) {
|
|
507
|
+
// f = (float)((double)f + d);
|
|
508
|
+
// }
|
|
509
|
+
// int n = 0;
|
|
510
|
+
// while (n < arrd.length) {
|
|
511
|
+
// double[] arrd2 = arrd;
|
|
512
|
+
// int n2 = n++;
|
|
513
|
+
// arrd2[n2] = arrd2[n2] / (double)f;
|
|
514
|
+
// }
|
|
515
|
+
// for (n = 0; n < arrd.length; ++n) {
|
|
516
|
+
// arrd[n] = (n == 0 ? 0.0 : arrd[n - 1]) + arrd[n];
|
|
517
|
+
// }
|
|
518
|
+
// return arrd;
|
|
519
|
+
// }
|
|
520
|
+
// public static int getRandomForDistributionIntegral(Random random, double[] arrd) {
|
|
521
|
+
// double d = random.nextDouble();
|
|
522
|
+
// for (int i = 0; i < arrd.length; ++i) {
|
|
523
|
+
// if (!(d < arrd[i])) continue;
|
|
524
|
+
// return i;
|
|
525
|
+
// }
|
|
526
|
+
// return arrd.length;
|
|
527
|
+
// }
|
|
528
|
+
// public static double[] binNormalDistribution(double d, double d2, double d3, int n, int n2) {
|
|
529
|
+
// double[] arrd = new double[n2 - n + 1];
|
|
530
|
+
// int n3 = 0;
|
|
531
|
+
// for (int i = n; i <= n2; ++i) {
|
|
532
|
+
// arrd[n3] = Math.max(0.0, d * StrictMath.exp(-((double)i - d3) * ((double)i - d3) / (2.0 * d2 * d2)));
|
|
533
|
+
// ++n3;
|
|
534
|
+
// }
|
|
535
|
+
// return arrd;
|
|
536
|
+
// }
|
|
537
|
+
// public static double[] binBiModalNormalDistribution(double d, double d2, double d3, double d4, double d5, double d6, int n, int n2) {
|
|
538
|
+
// double[] arrd = new double[n2 - n + 1];
|
|
539
|
+
// int n3 = 0;
|
|
540
|
+
// for (int i = n; i <= n2; ++i) {
|
|
541
|
+
// arrd[n3] = Math.max(0.0, d * StrictMath.exp(-((double)i - d3) * ((double)i - d3) / (2.0 * d2 * d2)) + d4 * StrictMath.exp(-((double)i - d6) * ((double)i - d6) / (2.0 * d5 * d5)));
|
|
542
|
+
// ++n3;
|
|
543
|
+
// }
|
|
544
|
+
// return arrd;
|
|
545
|
+
// }
|
|
546
|
+
// public static double[] binLogDistribution(double d, double d2, int n, int n2) {
|
|
547
|
+
// double[] arrd = new double[n2 - n + 1];
|
|
548
|
+
// int n3 = 0;
|
|
549
|
+
// for (int i = n; i <= n2; ++i) {
|
|
550
|
+
// arrd[n3] = Math.max(d * StrictMath.log(i) + d2, 0.0);
|
|
551
|
+
// ++n3;
|
|
552
|
+
// }
|
|
553
|
+
// return arrd;
|
|
554
|
+
// }
|
|
555
|
+
// public static int binarySearch(int n, int n2, IntPredicate intPredicate) {
|
|
556
|
+
// int n3 = n2 - n;
|
|
557
|
+
// while (n3 > 0) {
|
|
558
|
+
// int n4 = n3 / 2;
|
|
559
|
+
// int n5 = n + n4;
|
|
560
|
+
// if (intPredicate.test(n5)) {
|
|
561
|
+
// n3 = n4;
|
|
562
|
+
// continue;
|
|
563
|
+
// }
|
|
564
|
+
// n = n5 + 1;
|
|
565
|
+
// n3 -= n4 + 1;
|
|
566
|
+
// }
|
|
567
|
+
// return n;
|
|
568
|
+
// }
|
|
569
|
+
// public static float lerp(float f, float f2, float f3) {
|
|
570
|
+
// return f2 + f * (f3 - f2);
|
|
571
|
+
// }
|
|
572
|
+
// public static double lerp(double d, double d2, double d3) {
|
|
573
|
+
// return d2 + d * (d3 - d2);
|
|
574
|
+
// }
|
|
575
|
+
// public static double lerp2(double d, double d2, double d3, double d4, double d5, double d6) {
|
|
576
|
+
// return Mth.lerp(d2, Mth.lerp(d, d3, d4), Mth.lerp(d, d5, d6));
|
|
577
|
+
// }
|
|
578
|
+
// public static double lerp3(double d, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10, double d11) {
|
|
579
|
+
// return Mth.lerp(d3, Mth.lerp2(d, d2, d4, d5, d6, d7), Mth.lerp2(d, d2, d8, d9, d10, d11));
|
|
580
|
+
// }
|
|
581
|
+
// public static double smoothstep(double d) {
|
|
582
|
+
// return d * d * d * (d * (d * 6.0 - 15.0) + 10.0);
|
|
583
|
+
// }
|
|
584
|
+
// public static double smoothstepDerivative(double d) {
|
|
585
|
+
// return 30.0 * d * d * (d - 1.0) * (d - 1.0);
|
|
586
|
+
// }
|
|
587
|
+
// public static int sign(double d) {
|
|
588
|
+
// if (d == 0.0) {
|
|
589
|
+
// return 0;
|
|
590
|
+
// }
|
|
591
|
+
// return d > 0.0 ? 1 : -1;
|
|
592
|
+
// }
|
|
593
|
+
// public static float rotLerp(float f, float f2, float f3) {
|
|
594
|
+
// return f2 + f * Mth.wrapDegrees(f3 - f2);
|
|
595
|
+
// }
|
|
596
|
+
// public static float diffuseLight(float f, float f2, float f3) {
|
|
597
|
+
// return Math.min(f * f * 0.6f + f2 * f2 * ((3.0f + f2) / 4.0f) + f3 * f3 * 0.8f, 1.0f);
|
|
598
|
+
// }
|
|
599
|
+
// @Deprecated
|
|
600
|
+
// public static float rotlerp(float f, float f2, float f3) {
|
|
601
|
+
// float f4;
|
|
602
|
+
// for (f4 = f2 - f; f4 < -180.0f; f4 += 360.0f) {
|
|
603
|
+
// }
|
|
604
|
+
// while (f4 >= 180.0f) {
|
|
605
|
+
// f4 -= 360.0f;
|
|
606
|
+
// }
|
|
607
|
+
// return f + f3 * f4;
|
|
608
|
+
// }
|
|
609
|
+
// @Deprecated
|
|
610
|
+
// public static float rotWrap(double d) {
|
|
611
|
+
// while (d >= 180.0) {
|
|
612
|
+
// d -= 360.0;
|
|
613
|
+
// }
|
|
614
|
+
// while (d < -180.0) {
|
|
615
|
+
// d += 360.0;
|
|
616
|
+
// }
|
|
617
|
+
// return (float)d;
|
|
618
|
+
// }
|
|
619
|
+
// public static float triangleWave(float f, float f2) {
|
|
620
|
+
// return (Math.abs(f % f2 - f2 * 0.5f) - f2 * 0.25f) / (f2 * 0.25f);
|
|
621
|
+
// }
|
|
622
|
+
// public static float square(float f) {
|
|
623
|
+
// return f * f;
|
|
624
|
+
// }
|
|
625
|
+
// public static double square(double d) {
|
|
626
|
+
// return d * d;
|
|
627
|
+
// }
|
|
628
|
+
// public static int square(int n) {
|
|
629
|
+
// return n * n;
|
|
630
|
+
// }
|
|
631
|
+
// public static double clampedMap(double d, double d2, double d3, double d4, double d5) {
|
|
632
|
+
// return Mth.clampedLerp(d4, d5, Mth.inverseLerp(d, d2, d3));
|
|
633
|
+
// }
|
|
634
|
+
// public static double map(double d, double d2, double d3, double d4, double d5) {
|
|
635
|
+
// return Mth.lerp(Mth.inverseLerp(d, d2, d3), d4, d5);
|
|
636
|
+
// }
|
|
637
|
+
// public static double wobble(double d) {
|
|
638
|
+
// return d + (2.0 * new Random(Mth.floor(d * 3000.0)).nextDouble() - 1.0) * 1.0E-7 / 2.0;
|
|
639
|
+
// }
|
|
640
|
+
// public static int roundToward(int n, int n2) {
|
|
641
|
+
// return (n + n2 - 1) / n2 * n2;
|
|
642
|
+
// }
|
|
643
|
+
// public static int randomBetweenInclusive(Random random, int n, int n2) {
|
|
644
|
+
// return random.nextInt(n2 - n + 1) + n;
|
|
645
|
+
// }
|
|
646
|
+
// public static float randomBetween(Random random, float f, float f2) {
|
|
647
|
+
// return random.nextFloat() * (f2 - f) + f;
|
|
648
|
+
// }
|
|
649
|
+
// public static float normal(Random random, float f, float f2) {
|
|
650
|
+
// return f + (float)random.nextGaussian() * f2;
|
|
651
|
+
// }
|
|
652
|
+
// public static double length(int n, double d, int n2) {
|
|
653
|
+
// return Math.sqrt((double)(n * n) + d * d + (double)(n2 * n2));
|
|
654
|
+
// }
|
|
655
|
+
// static {
|
|
656
|
+
// for (int i = 0; i < 257; ++i) {
|
|
657
|
+
// double d = (double)i / 256.0;
|
|
658
|
+
// double d2 = Math.asin(d);
|
|
659
|
+
// Mth.COS_TAB[i] = Math.cos(d2);
|
|
660
|
+
// Mth.ASIN_TAB[i] = d2;
|
|
661
|
+
// }
|
|
662
|
+
// }
|
|
663
|
+
// }
|