@nxg-org/mineflayer-util-plugin 1.3.8 → 1.3.12
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/intercept.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare type BlockAndIterations = {
|
|
|
12
12
|
iterations: Iteration[];
|
|
13
13
|
};
|
|
14
14
|
export declare class InterceptFunctions {
|
|
15
|
-
bot
|
|
15
|
+
private bot;
|
|
16
16
|
constructor(bot: Bot);
|
|
17
17
|
check(from: Vec3, to: Vec3): BlockAndIterations;
|
|
18
18
|
raycast(from: Vec3, direction: Vec3, range: number): BlockAndIterations;
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InterceptFunctions = exports.AABB = void 0;
|
|
4
4
|
const utilFunctions_1 = require("./utilFunctions");
|
|
5
|
+
const mineflayer_pathfinder_1 = require("mineflayer-pathfinder");
|
|
5
6
|
function inject(bot) {
|
|
7
|
+
if (!bot.pathfinder)
|
|
8
|
+
bot.loadPlugin(mineflayer_pathfinder_1.pathfinder);
|
|
6
9
|
bot.util = new utilFunctions_1.UtilFunctions(bot);
|
|
7
10
|
}
|
|
8
11
|
exports.default = inject;
|
|
@@ -90,18 +90,17 @@ class InventoryFunctions {
|
|
|
90
90
|
}
|
|
91
91
|
findItemByID(itemId, metadata) {
|
|
92
92
|
var _a, _b;
|
|
93
|
-
const potentialMatches = this.getAllItems().filter((item) => item.type === itemId);
|
|
94
93
|
if (metadata)
|
|
95
|
-
return (_a =
|
|
96
|
-
|
|
94
|
+
return (_a = this.getAllItems().find((item) => item.type === itemId && item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
|
|
95
|
+
else
|
|
96
|
+
return (_b = this.getAllItems().find((item) => item.type === itemId)) !== null && _b !== void 0 ? _b : null;
|
|
97
97
|
}
|
|
98
98
|
findItem(name, metadata) {
|
|
99
99
|
var _a, _b;
|
|
100
|
-
//[...this.getAllItems(), this.bot.inventory.selectedItem!]
|
|
101
|
-
const potentialMatches = this.getAllItems().filter((item) => item === null || item === void 0 ? void 0 : item.name.includes(name));
|
|
102
100
|
if (metadata)
|
|
103
|
-
return (_a =
|
|
104
|
-
|
|
101
|
+
return (_a = this.getAllItems().find((item) => item.name === name && item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
|
|
102
|
+
else
|
|
103
|
+
return (_b = this.getAllItems().find((item) => item.name === name)) !== null && _b !== void 0 ? _b : null;
|
|
105
104
|
}
|
|
106
105
|
//alias.
|
|
107
106
|
has(name, metadata) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Bot } from "mineflayer";
|
|
2
2
|
import type { Entity } from "prismarine-entity";
|
|
3
3
|
import type { Vec3 } from "vec3";
|
|
4
|
-
import { goals } from "mineflayer-pathfinder";
|
|
4
|
+
import { goals, Movements } from "mineflayer-pathfinder";
|
|
5
5
|
export declare class MovementFunctions {
|
|
6
|
-
bot
|
|
6
|
+
private bot;
|
|
7
7
|
goalArray: goals.GoalCompositeAll;
|
|
8
|
-
lastYaw: number;
|
|
9
|
-
lastPitch: number;
|
|
10
8
|
constructor(bot: Bot);
|
|
9
|
+
set movements(movements: Movements);
|
|
10
|
+
get movements(): Movements;
|
|
11
11
|
/**
|
|
12
12
|
* Fuckin' mineflayer-pathfinder still doesn't have typings.
|
|
13
13
|
* Pain in my goddamn ass.
|
|
@@ -37,7 +37,7 @@ export declare class MovementFunctions {
|
|
|
37
37
|
* @returns have the goals changed
|
|
38
38
|
*/
|
|
39
39
|
followEntityWithRespectRange(entity: Entity, followDistance: number, invertDistance?: number): boolean;
|
|
40
|
-
forceLook(yaw: number, pitch: number, update?: boolean): void;
|
|
41
|
-
forceLookAt(pos: Vec3,
|
|
40
|
+
forceLook(yaw: number, pitch: number, onGround?: boolean, update?: boolean): void;
|
|
41
|
+
forceLookAt(pos: Vec3, onGround?: boolean, update?: boolean): void;
|
|
42
42
|
lazyTeleport(endPos: Vec3): void;
|
|
43
43
|
}
|
package/lib/movementFunctions.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.MovementFunctions = void 0;
|
|
4
7
|
const mineflayer_pathfinder_1 = require("mineflayer-pathfinder");
|
|
8
|
+
const minecraft_data_1 = __importDefault(require("minecraft-data"));
|
|
5
9
|
const { GoalCompositeAll, GoalInvert, GoalFollow } = mineflayer_pathfinder_1.goals;
|
|
6
10
|
class MovementFunctions {
|
|
7
11
|
constructor(bot) {
|
|
8
12
|
this.bot = bot;
|
|
9
13
|
this.goalArray = new GoalCompositeAll();
|
|
10
|
-
this.
|
|
11
|
-
|
|
14
|
+
this.movements = new mineflayer_pathfinder_1.Movements(bot, (0, minecraft_data_1.default)(bot.version));
|
|
15
|
+
}
|
|
16
|
+
set movements(movements) {
|
|
17
|
+
this.bot.pathfinder.setMovements(movements);
|
|
18
|
+
}
|
|
19
|
+
get movements() {
|
|
20
|
+
return this.movements;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* Fuckin' mineflayer-pathfinder still doesn't have typings.
|
|
@@ -83,25 +92,23 @@ class MovementFunctions {
|
|
|
83
92
|
}
|
|
84
93
|
return false;
|
|
85
94
|
}
|
|
86
|
-
forceLook(yaw, pitch, update = false) {
|
|
95
|
+
forceLook(yaw, pitch, onGround, update = false) {
|
|
87
96
|
const notchianYawAndPitch = { yaw: this.bot.util.math.toNotchianYaw(yaw), pitch: this.bot.util.math.toNotchianPitch(pitch) };
|
|
88
|
-
this.bot._client.write("look", Object.assign(Object.assign({}, notchianYawAndPitch), { onGround:
|
|
97
|
+
this.bot._client.write("look", Object.assign(Object.assign({}, notchianYawAndPitch), { onGround: onGround !== null && onGround !== void 0 ? onGround : this.bot.entity.onGround }));
|
|
89
98
|
if (update) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.bot.look(yaw, pitch, true);
|
|
99
|
+
this.bot.entity.yaw = yaw;
|
|
100
|
+
this.bot.entity.pitch = pitch;
|
|
101
|
+
// this.bot.look(yaw, pitch, true);
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
forceLookAt(pos,
|
|
104
|
+
forceLookAt(pos, onGround, update = false) {
|
|
96
105
|
const { yaw, pitch } = this.bot.util.math.pointToYawAndPitch(this.bot, pos);
|
|
97
106
|
const nyp = { yaw: this.bot.util.math.toNotchianYaw(yaw), pitch: this.bot.util.math.toNotchianPitch(pitch) };
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.bot.lookAt(pos, true);
|
|
104
|
-
}
|
|
107
|
+
this.bot._client.write("look", Object.assign(Object.assign({}, nyp), { onGround: onGround !== null && onGround !== void 0 ? onGround : this.bot.entity.onGround }));
|
|
108
|
+
if (update) {
|
|
109
|
+
this.bot.entity.yaw = yaw;
|
|
110
|
+
this.bot.entity.pitch = pitch;
|
|
111
|
+
// this.bot.look(yaw, pitch, true);
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
lazyTeleport(endPos) { }
|
|
@@ -91,15 +91,21 @@ const AIR_BLOCK = { type: 0 };
|
|
|
91
91
|
class PredictiveFunctions {
|
|
92
92
|
constructor(bot) {
|
|
93
93
|
this.bot = bot;
|
|
94
|
-
this.damageMultiplier = 7; // for 1.12+ 8 for 1.8 TODO check when the change occur (likely 1.9)
|
|
95
94
|
this.resistanceIndex = "11";
|
|
96
|
-
|
|
95
|
+
const version = Number(bot.version.split(".")[1]);
|
|
96
|
+
if (version === 16) {
|
|
97
97
|
this.armorToughnessKey = "generic.armorToughness";
|
|
98
98
|
this.armorProtectionKey = "generic.armor";
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
this.armorToughnessKey = "generic.
|
|
102
|
-
this.armorProtectionKey = "generic.armor";
|
|
101
|
+
this.armorToughnessKey = "minecraft:generic.armor_toughness";
|
|
102
|
+
this.armorProtectionKey = "minecraft:generic.armor";
|
|
103
|
+
}
|
|
104
|
+
if (version > 9) {
|
|
105
|
+
this.damageMultiplier = 8;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.damageMultiplier = 7;
|
|
103
109
|
}
|
|
104
110
|
const effects = (0, minecraft_data_1.default)(bot.version).effects;
|
|
105
111
|
for (const effectId in effects) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxg-org/mineflayer-util-plugin",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.12",
|
|
4
4
|
"description": "mineflayer utils for NextGEN mineflayer plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mineflayer",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"vec3": "^0.1.7"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
31
|
+
"@types/node": "^17.0.4",
|
|
32
32
|
"typescript": "^4.5.2"
|
|
33
33
|
}
|
|
34
34
|
}
|