@nxg-org/mineflayer-util-plugin 1.3.16 → 1.4.0

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.
@@ -1,4 +1,7 @@
1
1
  import { Vec3 } from "vec3";
2
+ declare type AABBPoints = [minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number];
3
+ declare type MinAndMaxPoints = [min: [x: number, y: number, z: number], max: [x: number, y: number, z: number]];
4
+ declare type Vec3AABB = [min: Vec3, max: Vec3];
2
5
  export declare class AABB {
3
6
  minX: number;
4
7
  minY: number;
@@ -11,17 +14,11 @@ export declare class AABB {
11
14
  static fromBlock(min: Vec3): AABB;
12
15
  set(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
13
16
  clone(): AABB;
14
- toArray(): number[];
15
- toMinAndMaxArrays(): {
16
- 0: number[];
17
- 1: number[];
18
- };
19
- toVecs(): {
20
- 0: Vec3;
21
- 1: Vec3;
22
- };
17
+ toArray(): AABBPoints;
18
+ toMinAndMaxArrays(): MinAndMaxPoints;
19
+ toVecs(): Vec3AABB;
23
20
  toVertices(): Vec3[];
24
- floor(): void;
21
+ floor(): this;
25
22
  extend(dx: number, dy: number, dz: number): this;
26
23
  contract(x: number, y: number, z: number): this;
27
24
  expand(x: number, y: number, z: number): this;
@@ -43,8 +40,8 @@ export declare class AABB {
43
40
  distanceFromRay(origin: Vec3, direction: Vec3, xz?: boolean): number;
44
41
  intersect(aABB: AABB): AABB;
45
42
  equals(other: AABB): boolean;
46
- xzDistanceToVec(pos: Vec3, heightOffset?: number): number;
47
- distanceToVec(pos: Vec3, heightOffset?: number): number;
43
+ xzDistanceToVec(pos: Vec3): number;
44
+ distanceToVec(pos: Vec3): number;
48
45
  expandTowards(vec3: Vec3): AABB;
49
46
  expandTowardsCoords(d: number, d2: number, d3: number): AABB;
50
47
  moveCoords(d: number, d2: number, d3: number): AABB;
package/lib/calcs/aabb.js CHANGED
@@ -35,10 +35,10 @@ class AABB {
35
35
  return [this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ];
36
36
  }
37
37
  toMinAndMaxArrays() {
38
- return { 0: [this.minX, this.minY, this.minZ], 1: [this.maxX, this.maxY, this.maxZ] };
38
+ return [[this.minX, this.minY, this.minZ], [this.maxX, this.maxY, this.maxZ]];
39
39
  }
40
40
  toVecs() {
41
- return { 0: new vec3_1.Vec3(this.minX, this.minY, this.minZ), 1: new vec3_1.Vec3(this.maxX, this.maxY, this.maxZ) };
41
+ return [new vec3_1.Vec3(this.minX, this.minY, this.minZ), new vec3_1.Vec3(this.maxX, this.maxY, this.maxZ)];
42
42
  }
43
43
  toVertices() {
44
44
  return [
@@ -59,6 +59,7 @@ class AABB {
59
59
  this.maxX = Math.floor(this.maxX);
60
60
  this.maxY = Math.floor(this.maxY);
61
61
  this.maxZ = Math.floor(this.maxZ);
62
+ return this;
62
63
  }
63
64
  extend(dx, dy, dz) {
64
65
  if (dx < 0)
@@ -207,17 +208,15 @@ class AABB {
207
208
  this.maxY === other.maxY &&
208
209
  this.maxZ === other.maxZ);
209
210
  }
210
- xzDistanceToVec(pos, heightOffset = 0) {
211
- const { x, y, z } = pos.offset(0, heightOffset, 0);
212
- let dx = Math.max(this.minX - x, 0, x - this.maxX);
213
- let dz = Math.max(this.minZ - z, 0, z - this.maxZ);
211
+ xzDistanceToVec(pos) {
212
+ let dx = Math.max(this.minX - pos.x, 0, pos.x - this.maxX);
213
+ let dz = Math.max(this.minZ - pos.z, 0, pos.z - this.maxZ);
214
214
  return Math.sqrt(dx * dx + dz * dz);
215
215
  }
216
- distanceToVec(pos, heightOffset = 0) {
217
- const { x, y, z } = pos.offset(0, heightOffset, 0);
218
- let dx = Math.max(this.minX - x, 0, x - this.maxX);
219
- let dy = Math.max(this.minY - y, 0, y - this.maxY);
220
- let dz = Math.max(this.minZ - z, 0, z - this.maxZ);
216
+ distanceToVec(pos) {
217
+ let dx = Math.max(this.minX - pos.x, 0, pos.x - this.maxX);
218
+ let dy = Math.max(this.minY - pos.y, 0, pos.y - this.maxY);
219
+ let dz = Math.max(this.minZ - pos.z, 0, pos.z - this.maxZ);
221
220
  return Math.sqrt(dx * dx + dy * dy + dz * dz);
222
221
  }
223
222
  expandTowards(vec3) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InterceptFunctions = void 0;
4
4
  const vec3_1 = require("vec3");
5
+ const iterators_1 = require("./iterators");
5
6
  class InterceptFunctions {
6
7
  constructor(bot) {
7
8
  this.bot = bot;
@@ -18,7 +19,7 @@ class InterceptFunctions {
18
19
  }
19
20
  raycast(from, direction, range) {
20
21
  const iterations = [];
21
- const iter = new RaycastIterator(from, direction, range);
22
+ const iter = new iterators_1.RaycastIterator(from, direction, range);
22
23
  let pos = iter.next();
23
24
  while (pos) {
24
25
  iterations.push(pos);
@@ -47,112 +48,3 @@ class InterceptFunctions {
47
48
  }
48
49
  }
49
50
  exports.InterceptFunctions = InterceptFunctions;
50
- var BlockFace;
51
- (function (BlockFace) {
52
- BlockFace[BlockFace["UNKNOWN"] = -999] = "UNKNOWN";
53
- BlockFace[BlockFace["BOTTOM"] = 0] = "BOTTOM";
54
- BlockFace[BlockFace["TOP"] = 1] = "TOP";
55
- BlockFace[BlockFace["NORTH"] = 2] = "NORTH";
56
- BlockFace[BlockFace["SOUTH"] = 3] = "SOUTH";
57
- BlockFace[BlockFace["WEST"] = 4] = "WEST";
58
- BlockFace[BlockFace["EAST"] = 5] = "EAST";
59
- })(BlockFace || (BlockFace = {}));
60
- class RaycastIterator {
61
- constructor(pos, dir, maxDistance) {
62
- this.block = {
63
- x: Math.floor(pos.x),
64
- y: Math.floor(pos.y),
65
- z: Math.floor(pos.z),
66
- face: BlockFace.UNKNOWN,
67
- };
68
- this.blockVec = new vec3_1.Vec3(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z));
69
- this.pos = pos;
70
- this.dir = dir;
71
- this.invDirX = dir.x === 0 ? Number.MAX_VALUE : 1 / dir.x;
72
- this.invDirY = dir.y === 0 ? Number.MAX_VALUE : 1 / dir.y;
73
- this.invDirZ = dir.z === 0 ? Number.MAX_VALUE : 1 / dir.z;
74
- this.stepX = Math.sign(dir.x);
75
- this.stepY = Math.sign(dir.y);
76
- this.stepZ = Math.sign(dir.z);
77
- this.tDeltaX = dir.x === 0 ? Number.MAX_VALUE : Math.abs(1 / dir.x);
78
- this.tDeltaY = dir.y === 0 ? Number.MAX_VALUE : Math.abs(1 / dir.y);
79
- this.tDeltaZ = dir.z === 0 ? Number.MAX_VALUE : Math.abs(1 / dir.z);
80
- this.tMaxX = dir.x === 0 ? Number.MAX_VALUE : Math.abs((this.block.x + (dir.x > 0 ? 1 : 0) - pos.x) / dir.x);
81
- this.tMaxY = dir.y === 0 ? Number.MAX_VALUE : Math.abs((this.block.y + (dir.y > 0 ? 1 : 0) - pos.y) / dir.y);
82
- this.tMaxZ = dir.z === 0 ? Number.MAX_VALUE : Math.abs((this.block.z + (dir.z > 0 ? 1 : 0) - pos.z) / dir.z);
83
- this.maxDistance = maxDistance;
84
- }
85
- // Returns null if none of the shapes is intersected, otherwise returns intersect pos and face
86
- // shapes are translated by offset
87
- //[x0: number,y0: number,z0: number,x1:number,y1:number,z1:number][]
88
- intersect(shapes, offset) {
89
- // Shapes is an array of shapes, each in the form of: [x0, y0, z0, x1, y1, z1]
90
- let t = Number.MAX_VALUE;
91
- let f = BlockFace.UNKNOWN;
92
- const p = this.pos.minus(offset);
93
- for (const shape of shapes) {
94
- let tmin = (shape[this.invDirX > 0 ? 0 : 3] - p.x) * this.invDirX;
95
- let tmax = (shape[this.invDirX > 0 ? 3 : 0] - p.x) * this.invDirX;
96
- const tymin = (shape[this.invDirY > 0 ? 1 : 4] - p.y) * this.invDirY;
97
- const tymax = (shape[this.invDirY > 0 ? 4 : 1] - p.y) * this.invDirY;
98
- let face = this.stepX > 0 ? BlockFace.WEST : BlockFace.EAST;
99
- if (tmin > tymax || tymin > tmax)
100
- continue;
101
- if (tymin > tmin) {
102
- tmin = tymin;
103
- face = this.stepY > 0 ? BlockFace.BOTTOM : BlockFace.TOP;
104
- }
105
- if (tymax < tmax)
106
- tmax = tymax;
107
- const tzmin = (shape[this.invDirZ > 0 ? 2 : 5] - p.z) * this.invDirZ;
108
- const tzmax = (shape[this.invDirZ > 0 ? 5 : 2] - p.z) * this.invDirZ;
109
- if (tmin > tzmax || tzmin > tmax)
110
- continue;
111
- if (tzmin > tmin) {
112
- tmin = tzmin;
113
- face = this.stepZ > 0 ? BlockFace.NORTH : BlockFace.SOUTH;
114
- }
115
- if (tzmax < tmax)
116
- tmax = tzmax;
117
- if (tmin < t) {
118
- t = tmin;
119
- f = face;
120
- }
121
- }
122
- if (t === Number.MAX_VALUE)
123
- return null;
124
- return { pos: this.pos.plus(this.dir.scaled(t)), face: f };
125
- }
126
- next() {
127
- if (Math.min(Math.min(this.tMaxX, this.tMaxY), this.tMaxZ) > this.maxDistance) {
128
- return null;
129
- }
130
- if (this.tMaxX < this.tMaxY) {
131
- if (this.tMaxX < this.tMaxZ) {
132
- this.block.x += this.stepX;
133
- this.tMaxX += this.tDeltaX;
134
- this.block.face = this.stepX > 0 ? BlockFace.WEST : BlockFace.EAST;
135
- }
136
- else {
137
- this.block.z += this.stepZ;
138
- this.tMaxZ += this.tDeltaZ;
139
- this.block.face = this.stepZ > 0 ? BlockFace.NORTH : BlockFace.SOUTH;
140
- }
141
- }
142
- else {
143
- if (this.tMaxY < this.tMaxZ) {
144
- this.block.y += this.stepY;
145
- this.tMaxY += this.tDeltaY;
146
- this.block.face = this.stepY > 0 ? BlockFace.BOTTOM : BlockFace.TOP;
147
- }
148
- else {
149
- this.block.z += this.stepZ;
150
- this.tMaxZ += this.tDeltaZ;
151
- this.block.face = this.stepZ > 0 ? BlockFace.NORTH : BlockFace.SOUTH;
152
- }
153
- }
154
- if (isNaN(this.block.x) || isNaN(this.block.y) || isNaN(this.block.z))
155
- return null;
156
- return this.block;
157
- }
158
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxg-org/mineflayer-util-plugin",
3
- "version": "1.3.16",
3
+ "version": "1.4.0",
4
4
  "description": "mineflayer utils for NextGEN mineflayer plugins.",
5
5
  "keywords": [
6
6
  "mineflayer",
@@ -20,12 +20,12 @@
20
20
  "test": "node --trace-warnings lib/example.js"
21
21
  },
22
22
  "dependencies": {
23
- "minecraft-data": "^2.97.0",
24
- "mineflayer": "^3.11.2",
25
- "mineflayer-pathfinder": "^1.8.0",
26
- "prismarine-block": "^1.10.3",
27
- "prismarine-entity": "^1.2.0",
28
- "prismarine-item": "^1.11.1",
23
+ "minecraft-data": "^2.113.0",
24
+ "mineflayer": "^4.0.0",
25
+ "mineflayer-pathfinder": "^1.9.1",
26
+ "prismarine-block": "^1.13.1",
27
+ "prismarine-entity": "^2.0.0",
28
+ "prismarine-item": "^1.11.2",
29
29
  "vec3": "^0.1.7"
30
30
  },
31
31
  "devDependencies": {
File without changes
@@ -1,663 +0,0 @@
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
- // }