@nxg-org/mineflayer-util-plugin 1.8.3 → 1.9.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.
- package/.vscode/settings.json +2 -2
- package/LICENSE +674 -674
- package/lib/calcs/aabb.d.ts +81 -81
- package/lib/calcs/aabb.js +330 -330
- package/lib/calcs/intercept.d.ts +20 -20
- package/lib/calcs/intercept.js +50 -50
- package/lib/calcs/iterators.d.ts +45 -45
- package/lib/calcs/iterators.js +114 -114
- package/lib/entityFunctions.d.ts +43 -43
- package/lib/entityFunctions.js +80 -80
- package/lib/filterFunctions.d.ts +22 -22
- package/lib/filterFunctions.js +44 -44
- package/lib/index.d.ts +22 -22
- package/lib/index.js +19 -19
- package/lib/inventoryFunctions.d.ts +38 -37
- package/lib/inventoryFunctions.js +141 -134
- package/lib/movementFunctions.d.ts +20 -10
- package/lib/movementFunctions.js +135 -49
- package/lib/predictiveFunctions.d.ts +24 -24
- package/lib/predictiveFunctions.js +188 -188
- package/lib/rayTracingFunctions.d.ts +21 -21
- package/lib/rayTracingFunctions.js +85 -85
- package/lib/static/aabbUtil.d.ts +24 -24
- package/lib/static/aabbUtil.js +41 -41
- package/lib/static/index.d.ts +3 -3
- package/lib/static/index.js +19 -19
- package/lib/static/mathUtil.d.ts +29 -29
- package/lib/static/mathUtil.js +70 -70
- package/lib/static/tasks.d.ts +9 -9
- package/lib/static/tasks.js +37 -37
- package/lib/utilFunctions.d.ts +26 -26
- package/lib/utilFunctions.js +32 -32
- package/lib/worldRelated/predictiveWorld.d.ts +42 -42
- package/lib/worldRelated/predictiveWorld.js +111 -111
- package/package.json +30 -28
package/lib/static/aabbUtil.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AABBUtils = void 0;
|
|
4
|
-
const aabb_1 = require("../calcs/aabb");
|
|
5
|
-
var AABBUtils;
|
|
6
|
-
(function (AABBUtils) {
|
|
7
|
-
function getBlockAABB(block, height = 1) {
|
|
8
|
-
const { x, y, z } = block.position;
|
|
9
|
-
return new aabb_1.AABB(x, y, z, x + 1, y + height, z + 1);
|
|
10
|
-
}
|
|
11
|
-
AABBUtils.getBlockAABB = getBlockAABB;
|
|
12
|
-
function getBlockPosAABB(block, height = 1) {
|
|
13
|
-
const { x, y, z } = block.floored();
|
|
14
|
-
return new aabb_1.AABB(x, y, z, x + 1, y + height, z + 1);
|
|
15
|
-
}
|
|
16
|
-
AABBUtils.getBlockPosAABB = getBlockPosAABB;
|
|
17
|
-
function getEntityAABB(entity) {
|
|
18
|
-
switch (entity.type) {
|
|
19
|
-
case "player":
|
|
20
|
-
return getEntityAABBRaw({ position: entity.position, height: entity.height + 0.18, width: entity.width });
|
|
21
|
-
case "mob":
|
|
22
|
-
default: //TODO: Implement better AABBs. However, this may just be correct.
|
|
23
|
-
return getEntityAABBRaw({ position: entity.position, height: entity.height, width: entity.width });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
AABBUtils.getEntityAABB = getEntityAABB;
|
|
27
|
-
function getPlayerAABB(entity) {
|
|
28
|
-
const hw = entity.width ? entity.width / 2 : 0.3;
|
|
29
|
-
return new aabb_1.AABB(-hw, 0, -hw, hw, entity.height ? entity.height + 0.18 : 1.8, hw).translateVec(entity.position);
|
|
30
|
-
}
|
|
31
|
-
AABBUtils.getPlayerAABB = getPlayerAABB;
|
|
32
|
-
function getPlayerAABBRaw(position, height = 1.8) {
|
|
33
|
-
return new aabb_1.AABB(-0.3, 0, -0.3, 0.3, height, 0.3).translateVec(position);
|
|
34
|
-
}
|
|
35
|
-
AABBUtils.getPlayerAABBRaw = getPlayerAABBRaw;
|
|
36
|
-
function getEntityAABBRaw(entity) {
|
|
37
|
-
const hw = entity.width ? entity.width / 2 : entity.height / 2;
|
|
38
|
-
return new aabb_1.AABB(-hw, 0, -hw, hw, entity.height, hw).translateVec(entity.position);
|
|
39
|
-
}
|
|
40
|
-
AABBUtils.getEntityAABBRaw = getEntityAABBRaw;
|
|
41
|
-
})(AABBUtils = exports.AABBUtils || (exports.AABBUtils = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AABBUtils = void 0;
|
|
4
|
+
const aabb_1 = require("../calcs/aabb");
|
|
5
|
+
var AABBUtils;
|
|
6
|
+
(function (AABBUtils) {
|
|
7
|
+
function getBlockAABB(block, height = 1) {
|
|
8
|
+
const { x, y, z } = block.position;
|
|
9
|
+
return new aabb_1.AABB(x, y, z, x + 1, y + height, z + 1);
|
|
10
|
+
}
|
|
11
|
+
AABBUtils.getBlockAABB = getBlockAABB;
|
|
12
|
+
function getBlockPosAABB(block, height = 1) {
|
|
13
|
+
const { x, y, z } = block.floored();
|
|
14
|
+
return new aabb_1.AABB(x, y, z, x + 1, y + height, z + 1);
|
|
15
|
+
}
|
|
16
|
+
AABBUtils.getBlockPosAABB = getBlockPosAABB;
|
|
17
|
+
function getEntityAABB(entity) {
|
|
18
|
+
switch (entity.type) {
|
|
19
|
+
case "player":
|
|
20
|
+
return getEntityAABBRaw({ position: entity.position, height: entity.height + 0.18, width: entity.width });
|
|
21
|
+
case "mob":
|
|
22
|
+
default: //TODO: Implement better AABBs. However, this may just be correct.
|
|
23
|
+
return getEntityAABBRaw({ position: entity.position, height: entity.height, width: entity.width });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
AABBUtils.getEntityAABB = getEntityAABB;
|
|
27
|
+
function getPlayerAABB(entity) {
|
|
28
|
+
const hw = entity.width ? entity.width / 2 : 0.3;
|
|
29
|
+
return new aabb_1.AABB(-hw, 0, -hw, hw, entity.height ? entity.height + 0.18 : 1.8, hw).translateVec(entity.position);
|
|
30
|
+
}
|
|
31
|
+
AABBUtils.getPlayerAABB = getPlayerAABB;
|
|
32
|
+
function getPlayerAABBRaw(position, height = 1.8) {
|
|
33
|
+
return new aabb_1.AABB(-0.3, 0, -0.3, 0.3, height, 0.3).translateVec(position);
|
|
34
|
+
}
|
|
35
|
+
AABBUtils.getPlayerAABBRaw = getPlayerAABBRaw;
|
|
36
|
+
function getEntityAABBRaw(entity) {
|
|
37
|
+
const hw = entity.width ? entity.width / 2 : entity.height / 2;
|
|
38
|
+
return new aabb_1.AABB(-hw, 0, -hw, hw, entity.height, hw).translateVec(entity.position);
|
|
39
|
+
}
|
|
40
|
+
AABBUtils.getEntityAABBRaw = getEntityAABBRaw;
|
|
41
|
+
})(AABBUtils = exports.AABBUtils || (exports.AABBUtils = {}));
|
package/lib/static/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./aabbUtil";
|
|
2
|
-
export * from "./mathUtil";
|
|
3
|
-
export * from "./tasks";
|
|
1
|
+
export * from "./aabbUtil";
|
|
2
|
+
export * from "./mathUtil";
|
|
3
|
+
export * from "./tasks";
|
package/lib/static/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./aabbUtil"), exports);
|
|
18
|
-
__exportStar(require("./mathUtil"), exports);
|
|
19
|
-
__exportStar(require("./tasks"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./aabbUtil"), exports);
|
|
18
|
+
__exportStar(require("./mathUtil"), exports);
|
|
19
|
+
__exportStar(require("./tasks"), exports);
|
package/lib/static/mathUtil.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { Bot } from "mineflayer";
|
|
2
|
-
import { Vec3 } from "vec3";
|
|
3
|
-
export declare namespace MathUtils {
|
|
4
|
-
const TO_RAD: number;
|
|
5
|
-
const TO_DEG: number;
|
|
6
|
-
const FROM_NOTCH_BYTE: number;
|
|
7
|
-
const FROM_NOTCH_VEL: number;
|
|
8
|
-
const toNotchianYaw: (yaw: number) => number;
|
|
9
|
-
const toNotchianPitch: (pitch: number) => number;
|
|
10
|
-
const fromNotchianYawByte: (yaw: number) => number;
|
|
11
|
-
const fromNotchianPitchByte: (pitch: number) => number;
|
|
12
|
-
function euclideanMod(numerator: number, denominator: number): number;
|
|
13
|
-
function toRadians(degrees: number): number;
|
|
14
|
-
function toDegrees(radians: number): number;
|
|
15
|
-
function fromNotchianYaw(yaw: number): number;
|
|
16
|
-
function fromNotchianPitch(pitch: number): number;
|
|
17
|
-
function fromNotchVelocity(vel: Vec3): Vec3;
|
|
18
|
-
function pointToYawAndPitch(bot: Bot, point: Vec3): {
|
|
19
|
-
yaw: number;
|
|
20
|
-
pitch: number;
|
|
21
|
-
};
|
|
22
|
-
function dirToYawAndPitch(dir: Vec3): {
|
|
23
|
-
yaw: number;
|
|
24
|
-
pitch: number;
|
|
25
|
-
};
|
|
26
|
-
function getYaw(origin: Vec3, destination: Vec3): number;
|
|
27
|
-
function getViewDir(pitch: number, yaw: number): Vec3;
|
|
28
|
-
function yawPitchAndSpeedToDir(yaw: number, pitch: number, speed: number): Vec3;
|
|
29
|
-
}
|
|
1
|
+
import { Bot } from "mineflayer";
|
|
2
|
+
import { Vec3 } from "vec3";
|
|
3
|
+
export declare namespace MathUtils {
|
|
4
|
+
const TO_RAD: number;
|
|
5
|
+
const TO_DEG: number;
|
|
6
|
+
const FROM_NOTCH_BYTE: number;
|
|
7
|
+
const FROM_NOTCH_VEL: number;
|
|
8
|
+
const toNotchianYaw: (yaw: number) => number;
|
|
9
|
+
const toNotchianPitch: (pitch: number) => number;
|
|
10
|
+
const fromNotchianYawByte: (yaw: number) => number;
|
|
11
|
+
const fromNotchianPitchByte: (pitch: number) => number;
|
|
12
|
+
function euclideanMod(numerator: number, denominator: number): number;
|
|
13
|
+
function toRadians(degrees: number): number;
|
|
14
|
+
function toDegrees(radians: number): number;
|
|
15
|
+
function fromNotchianYaw(yaw: number): number;
|
|
16
|
+
function fromNotchianPitch(pitch: number): number;
|
|
17
|
+
function fromNotchVelocity(vel: Vec3): Vec3;
|
|
18
|
+
function pointToYawAndPitch(bot: Bot, point: Vec3): {
|
|
19
|
+
yaw: number;
|
|
20
|
+
pitch: number;
|
|
21
|
+
};
|
|
22
|
+
function dirToYawAndPitch(dir: Vec3): {
|
|
23
|
+
yaw: number;
|
|
24
|
+
pitch: number;
|
|
25
|
+
};
|
|
26
|
+
function getYaw(origin: Vec3, destination: Vec3): number;
|
|
27
|
+
function getViewDir(pitch: number, yaw: number): Vec3;
|
|
28
|
+
function yawPitchAndSpeedToDir(yaw: number, pitch: number, speed: number): Vec3;
|
|
29
|
+
}
|
package/lib/static/mathUtil.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MathUtils = void 0;
|
|
4
|
-
const vec3_1 = require("vec3");
|
|
5
|
-
var MathUtils;
|
|
6
|
-
(function (MathUtils) {
|
|
7
|
-
const PI = Math.PI;
|
|
8
|
-
const PI_2 = Math.PI * 2;
|
|
9
|
-
MathUtils.TO_RAD = PI / 180;
|
|
10
|
-
MathUtils.TO_DEG = 1 / MathUtils.TO_RAD;
|
|
11
|
-
MathUtils.FROM_NOTCH_BYTE = 360 / 256;
|
|
12
|
-
// From wiki.vg: Velocity is believed to be in units of 1/8000 of a block per server tick (50ms)
|
|
13
|
-
MathUtils.FROM_NOTCH_VEL = 1 / 8000;
|
|
14
|
-
MathUtils.toNotchianYaw = (yaw) => toDegrees(PI - yaw);
|
|
15
|
-
MathUtils.toNotchianPitch = (pitch) => toDegrees(-pitch);
|
|
16
|
-
MathUtils.fromNotchianYawByte = (yaw) => fromNotchianYaw(yaw * MathUtils.FROM_NOTCH_BYTE);
|
|
17
|
-
MathUtils.fromNotchianPitchByte = (pitch) => fromNotchianPitch(pitch * MathUtils.FROM_NOTCH_BYTE);
|
|
18
|
-
function euclideanMod(numerator, denominator) {
|
|
19
|
-
const result = numerator % denominator;
|
|
20
|
-
return result < 0 ? result + denominator : result;
|
|
21
|
-
}
|
|
22
|
-
MathUtils.euclideanMod = euclideanMod;
|
|
23
|
-
function toRadians(degrees) {
|
|
24
|
-
return MathUtils.TO_RAD * degrees;
|
|
25
|
-
}
|
|
26
|
-
MathUtils.toRadians = toRadians;
|
|
27
|
-
function toDegrees(radians) {
|
|
28
|
-
return MathUtils.TO_DEG * radians;
|
|
29
|
-
}
|
|
30
|
-
MathUtils.toDegrees = toDegrees;
|
|
31
|
-
function fromNotchianYaw(yaw) {
|
|
32
|
-
return euclideanMod(PI - toRadians(yaw), PI_2);
|
|
33
|
-
}
|
|
34
|
-
MathUtils.fromNotchianYaw = fromNotchianYaw;
|
|
35
|
-
function fromNotchianPitch(pitch) {
|
|
36
|
-
return euclideanMod(toRadians(-pitch) + PI, PI_2) - PI;
|
|
37
|
-
}
|
|
38
|
-
MathUtils.fromNotchianPitch = fromNotchianPitch;
|
|
39
|
-
function fromNotchVelocity(vel) {
|
|
40
|
-
return new vec3_1.Vec3(vel.x * MathUtils.FROM_NOTCH_VEL, vel.y * MathUtils.FROM_NOTCH_VEL, vel.z * MathUtils.FROM_NOTCH_VEL);
|
|
41
|
-
}
|
|
42
|
-
MathUtils.fromNotchVelocity = fromNotchVelocity;
|
|
43
|
-
function pointToYawAndPitch(bot, point) {
|
|
44
|
-
const delta = point.minus(bot.entity.position.offset(0, bot.entity.height, 0));
|
|
45
|
-
return dirToYawAndPitch(delta);
|
|
46
|
-
}
|
|
47
|
-
MathUtils.pointToYawAndPitch = pointToYawAndPitch;
|
|
48
|
-
function dirToYawAndPitch(dir) {
|
|
49
|
-
const yaw = Math.atan2(-dir.x, -dir.z);
|
|
50
|
-
const groundDistance = Math.sqrt(dir.x * dir.x + dir.z * dir.z);
|
|
51
|
-
const pitch = Math.atan2(dir.y, groundDistance);
|
|
52
|
-
return { yaw: yaw, pitch: pitch };
|
|
53
|
-
}
|
|
54
|
-
MathUtils.dirToYawAndPitch = dirToYawAndPitch;
|
|
55
|
-
function getYaw(origin, destination) {
|
|
56
|
-
const xDistance = destination.x - origin.x;
|
|
57
|
-
const zDistance = destination.z - origin.z;
|
|
58
|
-
const yaw = Math.atan2(xDistance, zDistance) + Math.PI;
|
|
59
|
-
return yaw;
|
|
60
|
-
}
|
|
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;
|
|
66
|
-
function yawPitchAndSpeedToDir(yaw, pitch, speed) {
|
|
67
|
-
return new vec3_1.Vec3(-Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)).scale(speed);
|
|
68
|
-
}
|
|
69
|
-
MathUtils.yawPitchAndSpeedToDir = yawPitchAndSpeedToDir;
|
|
70
|
-
})(MathUtils = exports.MathUtils || (exports.MathUtils = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MathUtils = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
5
|
+
var MathUtils;
|
|
6
|
+
(function (MathUtils) {
|
|
7
|
+
const PI = Math.PI;
|
|
8
|
+
const PI_2 = Math.PI * 2;
|
|
9
|
+
MathUtils.TO_RAD = PI / 180;
|
|
10
|
+
MathUtils.TO_DEG = 1 / MathUtils.TO_RAD;
|
|
11
|
+
MathUtils.FROM_NOTCH_BYTE = 360 / 256;
|
|
12
|
+
// From wiki.vg: Velocity is believed to be in units of 1/8000 of a block per server tick (50ms)
|
|
13
|
+
MathUtils.FROM_NOTCH_VEL = 1 / 8000;
|
|
14
|
+
MathUtils.toNotchianYaw = (yaw) => toDegrees(PI - yaw);
|
|
15
|
+
MathUtils.toNotchianPitch = (pitch) => toDegrees(-pitch);
|
|
16
|
+
MathUtils.fromNotchianYawByte = (yaw) => fromNotchianYaw(yaw * MathUtils.FROM_NOTCH_BYTE);
|
|
17
|
+
MathUtils.fromNotchianPitchByte = (pitch) => fromNotchianPitch(pitch * MathUtils.FROM_NOTCH_BYTE);
|
|
18
|
+
function euclideanMod(numerator, denominator) {
|
|
19
|
+
const result = numerator % denominator;
|
|
20
|
+
return result < 0 ? result + denominator : result;
|
|
21
|
+
}
|
|
22
|
+
MathUtils.euclideanMod = euclideanMod;
|
|
23
|
+
function toRadians(degrees) {
|
|
24
|
+
return MathUtils.TO_RAD * degrees;
|
|
25
|
+
}
|
|
26
|
+
MathUtils.toRadians = toRadians;
|
|
27
|
+
function toDegrees(radians) {
|
|
28
|
+
return MathUtils.TO_DEG * radians;
|
|
29
|
+
}
|
|
30
|
+
MathUtils.toDegrees = toDegrees;
|
|
31
|
+
function fromNotchianYaw(yaw) {
|
|
32
|
+
return euclideanMod(PI - toRadians(yaw), PI_2);
|
|
33
|
+
}
|
|
34
|
+
MathUtils.fromNotchianYaw = fromNotchianYaw;
|
|
35
|
+
function fromNotchianPitch(pitch) {
|
|
36
|
+
return euclideanMod(toRadians(-pitch) + PI, PI_2) - PI;
|
|
37
|
+
}
|
|
38
|
+
MathUtils.fromNotchianPitch = fromNotchianPitch;
|
|
39
|
+
function fromNotchVelocity(vel) {
|
|
40
|
+
return new vec3_1.Vec3(vel.x * MathUtils.FROM_NOTCH_VEL, vel.y * MathUtils.FROM_NOTCH_VEL, vel.z * MathUtils.FROM_NOTCH_VEL);
|
|
41
|
+
}
|
|
42
|
+
MathUtils.fromNotchVelocity = fromNotchVelocity;
|
|
43
|
+
function pointToYawAndPitch(bot, point) {
|
|
44
|
+
const delta = point.minus(bot.entity.position.offset(0, bot.entity.height, 0));
|
|
45
|
+
return dirToYawAndPitch(delta);
|
|
46
|
+
}
|
|
47
|
+
MathUtils.pointToYawAndPitch = pointToYawAndPitch;
|
|
48
|
+
function dirToYawAndPitch(dir) {
|
|
49
|
+
const yaw = Math.atan2(-dir.x, -dir.z);
|
|
50
|
+
const groundDistance = Math.sqrt(dir.x * dir.x + dir.z * dir.z);
|
|
51
|
+
const pitch = Math.atan2(dir.y, groundDistance);
|
|
52
|
+
return { yaw: yaw, pitch: pitch };
|
|
53
|
+
}
|
|
54
|
+
MathUtils.dirToYawAndPitch = dirToYawAndPitch;
|
|
55
|
+
function getYaw(origin, destination) {
|
|
56
|
+
const xDistance = destination.x - origin.x;
|
|
57
|
+
const zDistance = destination.z - origin.z;
|
|
58
|
+
const yaw = Math.atan2(xDistance, zDistance) + Math.PI;
|
|
59
|
+
return yaw;
|
|
60
|
+
}
|
|
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;
|
|
66
|
+
function yawPitchAndSpeedToDir(yaw, pitch, speed) {
|
|
67
|
+
return new vec3_1.Vec3(-Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), -Math.cos(yaw) * Math.cos(pitch)).scale(speed);
|
|
68
|
+
}
|
|
69
|
+
MathUtils.yawPitchAndSpeedToDir = yawPitchAndSpeedToDir;
|
|
70
|
+
})(MathUtils = exports.MathUtils || (exports.MathUtils = {}));
|
package/lib/static/tasks.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare class Task<Finish = void, Cancel = void> {
|
|
2
|
-
done: boolean;
|
|
3
|
-
promise: Promise<any>;
|
|
4
|
-
cancel: (error: Cancel) => Cancel;
|
|
5
|
-
finish: (result: Finish) => Finish;
|
|
6
|
-
constructor();
|
|
7
|
-
static createTask<Finish = void, Cancel = void>(): Task<Finish, Cancel>;
|
|
8
|
-
static createDoneTask(): Task<any, any>;
|
|
9
|
-
}
|
|
1
|
+
export declare class Task<Finish = void, Cancel = void> {
|
|
2
|
+
done: boolean;
|
|
3
|
+
promise: Promise<any>;
|
|
4
|
+
cancel: (error: Cancel) => Cancel;
|
|
5
|
+
finish: (result: Finish) => Finish;
|
|
6
|
+
constructor();
|
|
7
|
+
static createTask<Finish = void, Cancel = void>(): Task<Finish, Cancel>;
|
|
8
|
+
static createDoneTask(): Task<any, any>;
|
|
9
|
+
}
|
package/lib/static/tasks.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Task = void 0;
|
|
4
|
-
// stolen task from mineflayer, just strongly typed now.
|
|
5
|
-
class Task {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.done = false;
|
|
8
|
-
this.promise = new Promise((resolve, reject) => {
|
|
9
|
-
this.cancel = (err) => {
|
|
10
|
-
if (!this.done) {
|
|
11
|
-
this.done = true;
|
|
12
|
-
reject(err);
|
|
13
|
-
}
|
|
14
|
-
throw err;
|
|
15
|
-
};
|
|
16
|
-
this.finish = (result) => {
|
|
17
|
-
if (!this.done) {
|
|
18
|
-
this.done = true;
|
|
19
|
-
resolve(result);
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
static createTask() {
|
|
26
|
-
return new Task();
|
|
27
|
-
}
|
|
28
|
-
static createDoneTask() {
|
|
29
|
-
return {
|
|
30
|
-
done: true,
|
|
31
|
-
promise: Promise.resolve(),
|
|
32
|
-
cancel: () => { },
|
|
33
|
-
finish: () => { }
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.Task = Task;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Task = void 0;
|
|
4
|
+
// stolen task from mineflayer, just strongly typed now.
|
|
5
|
+
class Task {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.done = false;
|
|
8
|
+
this.promise = new Promise((resolve, reject) => {
|
|
9
|
+
this.cancel = (err) => {
|
|
10
|
+
if (!this.done) {
|
|
11
|
+
this.done = true;
|
|
12
|
+
reject(err);
|
|
13
|
+
}
|
|
14
|
+
throw err;
|
|
15
|
+
};
|
|
16
|
+
this.finish = (result) => {
|
|
17
|
+
if (!this.done) {
|
|
18
|
+
this.done = true;
|
|
19
|
+
resolve(result);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
static createTask() {
|
|
26
|
+
return new Task();
|
|
27
|
+
}
|
|
28
|
+
static createDoneTask() {
|
|
29
|
+
return {
|
|
30
|
+
done: true,
|
|
31
|
+
promise: Promise.resolve(),
|
|
32
|
+
cancel: () => { },
|
|
33
|
+
finish: () => { }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Task = Task;
|
package/lib/utilFunctions.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { Bot } from "mineflayer";
|
|
2
|
-
import { Vec3 } from "vec3";
|
|
3
|
-
import { EntityFunctions } from "./entityFunctions";
|
|
4
|
-
import { FilterFunctions } from "./filterFunctions";
|
|
5
|
-
import { InventoryFunctions } from "./inventoryFunctions";
|
|
6
|
-
import { MovementFunctions } from "./movementFunctions";
|
|
7
|
-
import { PredictiveFunctions } from "./predictiveFunctions";
|
|
8
|
-
import { RayTraceFunctions } from "./rayTracingFunctions";
|
|
9
|
-
/**
|
|
10
|
-
* I can't inherit from multiple classes. This language sucks.
|
|
11
|
-
* I'm not using mixins. Fuck you, fuck that.
|
|
12
|
-
* I'm just going to segregate these functions into separate categories
|
|
13
|
-
* because once again, fuck you.
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export declare class UtilFunctions {
|
|
17
|
-
private bot;
|
|
18
|
-
inv: InventoryFunctions;
|
|
19
|
-
move: MovementFunctions;
|
|
20
|
-
entity: EntityFunctions;
|
|
21
|
-
predict: PredictiveFunctions;
|
|
22
|
-
filters: FilterFunctions;
|
|
23
|
-
raytrace: RayTraceFunctions;
|
|
24
|
-
constructor(bot: Bot);
|
|
25
|
-
getViewDir(): Vec3;
|
|
26
|
-
}
|
|
1
|
+
import type { Bot } from "mineflayer";
|
|
2
|
+
import { Vec3 } from "vec3";
|
|
3
|
+
import { EntityFunctions } from "./entityFunctions";
|
|
4
|
+
import { FilterFunctions } from "./filterFunctions";
|
|
5
|
+
import { InventoryFunctions } from "./inventoryFunctions";
|
|
6
|
+
import { MovementFunctions } from "./movementFunctions";
|
|
7
|
+
import { PredictiveFunctions } from "./predictiveFunctions";
|
|
8
|
+
import { RayTraceFunctions } from "./rayTracingFunctions";
|
|
9
|
+
/**
|
|
10
|
+
* I can't inherit from multiple classes. This language sucks.
|
|
11
|
+
* I'm not using mixins. Fuck you, fuck that.
|
|
12
|
+
* I'm just going to segregate these functions into separate categories
|
|
13
|
+
* because once again, fuck you.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare class UtilFunctions {
|
|
17
|
+
private bot;
|
|
18
|
+
inv: InventoryFunctions;
|
|
19
|
+
move: MovementFunctions;
|
|
20
|
+
entity: EntityFunctions;
|
|
21
|
+
predict: PredictiveFunctions;
|
|
22
|
+
filters: FilterFunctions;
|
|
23
|
+
raytrace: RayTraceFunctions;
|
|
24
|
+
constructor(bot: Bot);
|
|
25
|
+
getViewDir(): Vec3;
|
|
26
|
+
}
|
package/lib/utilFunctions.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UtilFunctions = void 0;
|
|
4
|
-
const vec3_1 = require("vec3");
|
|
5
|
-
const entityFunctions_1 = require("./entityFunctions");
|
|
6
|
-
const filterFunctions_1 = require("./filterFunctions");
|
|
7
|
-
const inventoryFunctions_1 = require("./inventoryFunctions");
|
|
8
|
-
const movementFunctions_1 = require("./movementFunctions");
|
|
9
|
-
const predictiveFunctions_1 = require("./predictiveFunctions");
|
|
10
|
-
const rayTracingFunctions_1 = require("./rayTracingFunctions");
|
|
11
|
-
/**
|
|
12
|
-
* I can't inherit from multiple classes. This language sucks.
|
|
13
|
-
* I'm not using mixins. Fuck you, fuck that.
|
|
14
|
-
* I'm just going to segregate these functions into separate categories
|
|
15
|
-
* because once again, fuck you.
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
class UtilFunctions {
|
|
19
|
-
constructor(bot) {
|
|
20
|
-
this.bot = bot;
|
|
21
|
-
this.inv = new inventoryFunctions_1.InventoryFunctions(bot);
|
|
22
|
-
this.move = new movementFunctions_1.MovementFunctions(bot);
|
|
23
|
-
this.entity = new entityFunctions_1.EntityFunctions(bot);
|
|
24
|
-
this.predict = new predictiveFunctions_1.PredictiveFunctions(bot);
|
|
25
|
-
this.filters = new filterFunctions_1.FilterFunctions(bot);
|
|
26
|
-
this.raytrace = new rayTracingFunctions_1.RayTraceFunctions(bot);
|
|
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
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.UtilFunctions = UtilFunctions;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UtilFunctions = void 0;
|
|
4
|
+
const vec3_1 = require("vec3");
|
|
5
|
+
const entityFunctions_1 = require("./entityFunctions");
|
|
6
|
+
const filterFunctions_1 = require("./filterFunctions");
|
|
7
|
+
const inventoryFunctions_1 = require("./inventoryFunctions");
|
|
8
|
+
const movementFunctions_1 = require("./movementFunctions");
|
|
9
|
+
const predictiveFunctions_1 = require("./predictiveFunctions");
|
|
10
|
+
const rayTracingFunctions_1 = require("./rayTracingFunctions");
|
|
11
|
+
/**
|
|
12
|
+
* I can't inherit from multiple classes. This language sucks.
|
|
13
|
+
* I'm not using mixins. Fuck you, fuck that.
|
|
14
|
+
* I'm just going to segregate these functions into separate categories
|
|
15
|
+
* because once again, fuck you.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
class UtilFunctions {
|
|
19
|
+
constructor(bot) {
|
|
20
|
+
this.bot = bot;
|
|
21
|
+
this.inv = new inventoryFunctions_1.InventoryFunctions(bot);
|
|
22
|
+
this.move = new movementFunctions_1.MovementFunctions(bot);
|
|
23
|
+
this.entity = new entityFunctions_1.EntityFunctions(bot);
|
|
24
|
+
this.predict = new predictiveFunctions_1.PredictiveFunctions(bot);
|
|
25
|
+
this.filters = new filterFunctions_1.FilterFunctions(bot);
|
|
26
|
+
this.raytrace = new rayTracingFunctions_1.RayTraceFunctions(bot);
|
|
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
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.UtilFunctions = UtilFunctions;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import type { Bot } from "mineflayer";
|
|
2
|
-
import type { Block } from "prismarine-block";
|
|
3
|
-
import { Vec3 } from "vec3";
|
|
4
|
-
import AABB from "../calcs/aabb";
|
|
5
|
-
export type Overwrites = {
|
|
6
|
-
[coord: string]: Block | null;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* A class dedicated to predictive logic.
|
|
10
|
-
*
|
|
11
|
-
* Currently, this class can predict explosion damages of crystals using a custom world.
|
|
12
|
-
*/
|
|
13
|
-
export declare class PredictiveWorld {
|
|
14
|
-
private blocks;
|
|
15
|
-
private originalWorld;
|
|
16
|
-
constructor(bot: Bot);
|
|
17
|
-
raycast(from: Vec3, direction: Vec3, range: number, matcher?: ((block: Block) => boolean) | null): Block | null;
|
|
18
|
-
/**
|
|
19
|
-
* this works
|
|
20
|
-
* @param {Block} block
|
|
21
|
-
*/
|
|
22
|
-
setBlock(pos: Vec3, block: Block): void;
|
|
23
|
-
/**
|
|
24
|
-
* @param {Overwrites} blocks Blocks indexed by position.toString()
|
|
25
|
-
*/
|
|
26
|
-
setBlocks(blocks: Overwrites): void;
|
|
27
|
-
/**
|
|
28
|
-
* @param {Vec3} pos
|
|
29
|
-
* @returns {Block | null} Block at position.
|
|
30
|
-
*/
|
|
31
|
-
getBlock(pos: Vec3): Block | null;
|
|
32
|
-
removeBlock(pos: Vec3, force: boolean): void;
|
|
33
|
-
removeBlocks(positions: Vec3[], force: boolean): void;
|
|
34
|
-
/**
|
|
35
|
-
* @param playerPos Position of effected entity.
|
|
36
|
-
* @param explosionPos Position of explosion origin.
|
|
37
|
-
* @param block bot.block
|
|
38
|
-
* @returns List of affected blocks that potentially protect the entity.
|
|
39
|
-
*/
|
|
40
|
-
getExplosionAffectedBlocks(entityBB: AABB, explosionPos: Vec3): Overwrites;
|
|
41
|
-
loadProtectiveBlocks(playerPos: Vec3, explosionPos: Vec3): void;
|
|
42
|
-
}
|
|
1
|
+
import type { Bot } from "mineflayer";
|
|
2
|
+
import type { Block } from "prismarine-block";
|
|
3
|
+
import { Vec3 } from "vec3";
|
|
4
|
+
import AABB from "../calcs/aabb";
|
|
5
|
+
export type Overwrites = {
|
|
6
|
+
[coord: string]: Block | null;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A class dedicated to predictive logic.
|
|
10
|
+
*
|
|
11
|
+
* Currently, this class can predict explosion damages of crystals using a custom world.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PredictiveWorld {
|
|
14
|
+
private blocks;
|
|
15
|
+
private originalWorld;
|
|
16
|
+
constructor(bot: Bot);
|
|
17
|
+
raycast(from: Vec3, direction: Vec3, range: number, matcher?: ((block: Block) => boolean) | null): Block | null;
|
|
18
|
+
/**
|
|
19
|
+
* this works
|
|
20
|
+
* @param {Block} block
|
|
21
|
+
*/
|
|
22
|
+
setBlock(pos: Vec3, block: Block): void;
|
|
23
|
+
/**
|
|
24
|
+
* @param {Overwrites} blocks Blocks indexed by position.toString()
|
|
25
|
+
*/
|
|
26
|
+
setBlocks(blocks: Overwrites): void;
|
|
27
|
+
/**
|
|
28
|
+
* @param {Vec3} pos
|
|
29
|
+
* @returns {Block | null} Block at position.
|
|
30
|
+
*/
|
|
31
|
+
getBlock(pos: Vec3): Block | null;
|
|
32
|
+
removeBlock(pos: Vec3, force: boolean): void;
|
|
33
|
+
removeBlocks(positions: Vec3[], force: boolean): void;
|
|
34
|
+
/**
|
|
35
|
+
* @param playerPos Position of effected entity.
|
|
36
|
+
* @param explosionPos Position of explosion origin.
|
|
37
|
+
* @param block bot.block
|
|
38
|
+
* @returns List of affected blocks that potentially protect the entity.
|
|
39
|
+
*/
|
|
40
|
+
getExplosionAffectedBlocks(entityBB: AABB, explosionPos: Vec3): Overwrites;
|
|
41
|
+
loadProtectiveBlocks(playerPos: Vec3, explosionPos: Vec3): void;
|
|
42
|
+
}
|