@nxg-org/mineflayer-util-plugin 1.7.9 → 1.7.11
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 +15 -8
- package/lib/calcs/aabb.js +12 -1
- package/lib/static/mathUtil.d.ts +1 -0
- package/lib/static/mathUtil.js +4 -0
- package/lib/utilFunctions.d.ts +2 -8
- package/lib/utilFunctions.js +4 -8
- package/package.json +1 -1
package/lib/calcs/aabb.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { Vec3 } from "vec3";
|
|
2
|
+
type FakeVec3 = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z: number;
|
|
6
|
+
};
|
|
2
7
|
type AABBPoints = [minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number];
|
|
3
8
|
type MinAndMaxPoints = [min: [x: number, y: number, z: number], max: [x: number, y: number, z: number]];
|
|
4
9
|
type Vec3AABB = [min: Vec3, max: Vec3];
|
|
@@ -10,8 +15,8 @@ export declare class AABB {
|
|
|
10
15
|
maxY: number;
|
|
11
16
|
maxZ: number;
|
|
12
17
|
constructor(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number);
|
|
13
|
-
static fromVecs(min:
|
|
14
|
-
static fromBlock(min:
|
|
18
|
+
static fromVecs(min: FakeVec3, max: FakeVec3): AABB;
|
|
19
|
+
static fromBlock(min: FakeVec3): AABB;
|
|
15
20
|
static fromShape(pts: AABBPoints, offset?: Vec3): AABB;
|
|
16
21
|
set(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
|
|
17
22
|
clone(): AABB;
|
|
@@ -40,7 +45,7 @@ export declare class AABB {
|
|
|
40
45
|
contract(x: number, y: number, z: number): this;
|
|
41
46
|
expand(x: number, y: number, z: number): this;
|
|
42
47
|
translate(x: number, y: number, z: number): this;
|
|
43
|
-
translateVec(vec:
|
|
48
|
+
translateVec(vec: FakeVec3): this;
|
|
44
49
|
computeOffsetX(other: AABB, offsetX: number): number;
|
|
45
50
|
computeOffsetY(other: AABB, offsetY: number): number;
|
|
46
51
|
computeOffsetZ(other: AABB, offsetZ: number): number;
|
|
@@ -58,15 +63,17 @@ export declare class AABB {
|
|
|
58
63
|
distanceFromRay(origin: Vec3, direction: Vec3, xz?: boolean): number;
|
|
59
64
|
intersect(aABB: AABB): AABB;
|
|
60
65
|
equals(other: AABB): boolean;
|
|
61
|
-
xzDistanceToVec(pos:
|
|
62
|
-
distanceToVec(pos:
|
|
63
|
-
expandTowards(vec3:
|
|
66
|
+
xzDistanceToVec(pos: FakeVec3): number;
|
|
67
|
+
distanceToVec(pos: FakeVec3): number;
|
|
68
|
+
expandTowards(vec3: FakeVec3): AABB;
|
|
64
69
|
expandTowardsCoords(d: number, d2: number, d3: number): AABB;
|
|
65
70
|
moveCoords(d: number, d2: number, d3: number): AABB;
|
|
66
|
-
move(vec3:
|
|
71
|
+
move(vec3: FakeVec3): AABB;
|
|
67
72
|
intersectsCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
68
|
-
|
|
73
|
+
collides(aABB: AABB): boolean;
|
|
69
74
|
collidesCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
75
|
+
containsVec(vec: FakeVec3): boolean;
|
|
76
|
+
contains(x: number, y: number, z: number): boolean;
|
|
70
77
|
getCenter(): Vec3;
|
|
71
78
|
}
|
|
72
79
|
export default AABB;
|
package/lib/calcs/aabb.js
CHANGED
|
@@ -304,12 +304,23 @@ class AABB {
|
|
|
304
304
|
intersectsCoords(d, d2, d3, d4, d5, d6) {
|
|
305
305
|
return this.minX < d4 && this.maxX > d && this.minY < d5 && this.maxY > d2 && this.minZ < d6 && this.maxZ > d3;
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
collides(aABB) {
|
|
308
308
|
return this.collidesCoords(aABB.minX, aABB.minY, aABB.minZ, aABB.maxX, aABB.maxY, aABB.maxZ);
|
|
309
309
|
}
|
|
310
310
|
collidesCoords(d, d2, d3, d4, d5, d6) {
|
|
311
311
|
return (this.minX <= d4 && this.maxX >= d && this.minY <= d5 && this.maxY >= d2 && this.minZ <= d6 && this.maxZ >= d3);
|
|
312
312
|
}
|
|
313
|
+
containsVec(vec) {
|
|
314
|
+
return (this.minX <= vec.x &&
|
|
315
|
+
this.maxX >= vec.x &&
|
|
316
|
+
this.minY <= vec.y &&
|
|
317
|
+
this.maxY >= vec.y &&
|
|
318
|
+
this.minZ <= vec.z &&
|
|
319
|
+
this.maxZ >= vec.z);
|
|
320
|
+
}
|
|
321
|
+
contains(x, y, z) {
|
|
322
|
+
return this.minX <= x && this.maxX >= x && this.minY <= y && this.maxY >= y && this.minZ <= z && this.maxZ >= z;
|
|
323
|
+
}
|
|
313
324
|
getCenter() {
|
|
314
325
|
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));
|
|
315
326
|
}
|
package/lib/static/mathUtil.d.ts
CHANGED
|
@@ -24,5 +24,6 @@ export declare namespace MathUtils {
|
|
|
24
24
|
pitch: number;
|
|
25
25
|
};
|
|
26
26
|
function getYaw(origin: Vec3, destination: Vec3): number;
|
|
27
|
+
function getViewDir(pitch: number, yaw: number): Vec3;
|
|
27
28
|
function yawPitchAndSpeedToDir(yaw: number, pitch: number, speed: number): Vec3;
|
|
28
29
|
}
|
package/lib/static/mathUtil.js
CHANGED
|
@@ -59,6 +59,10 @@ var MathUtils;
|
|
|
59
59
|
return yaw;
|
|
60
60
|
}
|
|
61
61
|
MathUtils.getYaw = getYaw;
|
|
62
|
+
function getViewDir(pitch, yaw) {
|
|
63
|
+
return new vec3_1.Vec3(-Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch));
|
|
64
|
+
}
|
|
65
|
+
MathUtils.getViewDir = getViewDir;
|
|
62
66
|
function yawPitchAndSpeedToDir(yaw, pitch, speed) {
|
|
63
67
|
return new vec3_1.Vec3(-Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)).scale(speed);
|
|
64
68
|
}
|
package/lib/utilFunctions.d.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { Bot } from "mineflayer";
|
|
2
|
+
import { Vec3 } from "vec3";
|
|
2
3
|
import { EntityFunctions } from "./entityFunctions";
|
|
3
4
|
import { FilterFunctions } from "./filterFunctions";
|
|
4
5
|
import { InventoryFunctions } from "./inventoryFunctions";
|
|
5
6
|
import { MovementFunctions } from "./movementFunctions";
|
|
6
7
|
import { PredictiveFunctions } from "./predictiveFunctions";
|
|
7
8
|
import { RayTraceFunctions } from "./rayTracingFunctions";
|
|
8
|
-
/**
|
|
9
|
-
* I don't believe I need any locks, as I'm only going to have one instance of this per bot.
|
|
10
|
-
* This is added to bot context so multiple instances will exist in memory.
|
|
11
|
-
* Therefore, I don't need this. https://www.npmjs.com/package/async-lock
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* I may add listeners to this class, as halting until an item is equipped may be good.
|
|
15
|
-
*/
|
|
16
9
|
/**
|
|
17
10
|
* I can't inherit from multiple classes. This language sucks.
|
|
18
11
|
* I'm not using mixins. Fuck you, fuck that.
|
|
@@ -29,4 +22,5 @@ export declare class UtilFunctions {
|
|
|
29
22
|
filters: FilterFunctions;
|
|
30
23
|
raytrace: RayTraceFunctions;
|
|
31
24
|
constructor(bot: Bot);
|
|
25
|
+
getViewDir(): Vec3;
|
|
32
26
|
}
|
package/lib/utilFunctions.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UtilFunctions = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
4
5
|
const entityFunctions_1 = require("./entityFunctions");
|
|
5
6
|
const filterFunctions_1 = require("./filterFunctions");
|
|
6
7
|
const inventoryFunctions_1 = require("./inventoryFunctions");
|
|
7
8
|
const movementFunctions_1 = require("./movementFunctions");
|
|
8
9
|
const predictiveFunctions_1 = require("./predictiveFunctions");
|
|
9
10
|
const rayTracingFunctions_1 = require("./rayTracingFunctions");
|
|
10
|
-
/**
|
|
11
|
-
* I don't believe I need any locks, as I'm only going to have one instance of this per bot.
|
|
12
|
-
* This is added to bot context so multiple instances will exist in memory.
|
|
13
|
-
* Therefore, I don't need this. https://www.npmjs.com/package/async-lock
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* I may add listeners to this class, as halting until an item is equipped may be good.
|
|
17
|
-
*/
|
|
18
11
|
/**
|
|
19
12
|
* I can't inherit from multiple classes. This language sucks.
|
|
20
13
|
* I'm not using mixins. Fuck you, fuck that.
|
|
@@ -32,5 +25,8 @@ class UtilFunctions {
|
|
|
32
25
|
this.filters = new filterFunctions_1.FilterFunctions(bot);
|
|
33
26
|
this.raytrace = new rayTracingFunctions_1.RayTraceFunctions(bot);
|
|
34
27
|
}
|
|
28
|
+
getViewDir() {
|
|
29
|
+
return new vec3_1.Vec3(-Math.sin(this.bot.entity.yaw) * Math.cos(this.bot.entity.pitch), Math.sin(this.bot.entity.pitch), -Math.cos(this.bot.entity.yaw) * Math.cos(this.bot.entity.pitch));
|
|
30
|
+
}
|
|
35
31
|
}
|
|
36
32
|
exports.UtilFunctions = UtilFunctions;
|