@nxg-org/mineflayer-util-plugin 1.2.2 → 1.2.6
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/entityFunctions.d.ts +14 -1
- package/lib/entityFunctions.js +32 -6
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/utilFunctions.d.ts +0 -2
- package/lib/utilFunctions.js +0 -2
- package/package.json +1 -2
- package/lib/commonSense.d.ts +0 -22
- package/lib/commonSense.js +0 -220
package/lib/entityFunctions.d.ts
CHANGED
|
@@ -23,9 +23,21 @@ export declare class EntityFunctions {
|
|
|
23
23
|
/**
|
|
24
24
|
* TODO: Version specific right now. Generalize. Unknown method.
|
|
25
25
|
* @param metadata metadata from Prismarine-Entity Entity.
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns number
|
|
27
27
|
*/
|
|
28
28
|
getHealth(entity?: Entity): number;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param metadata Must be FULL metadata object.
|
|
32
|
+
* @returns number
|
|
33
|
+
*/
|
|
34
|
+
getHealthFromMetadata(metadata: object[]): number;
|
|
35
|
+
/**
|
|
36
|
+
* TODO: Version specific right now. Generalize. Unknown method.
|
|
37
|
+
* @param metadata metadata from Prismarine-Entity Entity.
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
getHealthChange(packetMetadata: any, entity: Entity): number;
|
|
29
41
|
getDistanceToEntity(entity: Entity): number;
|
|
30
42
|
getDistanceBetweenEntities(first: Entity, second: Entity): number;
|
|
31
43
|
getEntityAABB(entity: {
|
|
@@ -33,4 +45,5 @@ export declare class EntityFunctions {
|
|
|
33
45
|
height: number;
|
|
34
46
|
width?: number;
|
|
35
47
|
}): AABB;
|
|
48
|
+
private parseMetadata;
|
|
36
49
|
}
|
package/lib/entityFunctions.js
CHANGED
|
@@ -45,15 +45,13 @@ class EntityFunctions {
|
|
|
45
45
|
/**
|
|
46
46
|
* TODO: Version specific right now. Generalize. Unknown method.
|
|
47
47
|
* @param metadata metadata from Prismarine-Entity Entity.
|
|
48
|
-
* @returns
|
|
48
|
+
* @returns number
|
|
49
49
|
*/
|
|
50
50
|
getHealth(entity) {
|
|
51
51
|
var _a, _b;
|
|
52
|
-
entity
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
let healthSlot = this.healthSlot; //metadata[this.healthSlot] ? this.healthSlot : metadata.findIndex((met) => Number(met) > 1 && Number(met) <= 20);
|
|
56
|
-
// return Number(metadata[healthSlot]) + (Number(metadata[healthSlot + 4]) ?? 0);
|
|
52
|
+
entity !== null && entity !== void 0 ? entity : (entity = this.bot.entity);
|
|
53
|
+
const metadata = entity.metadata;
|
|
54
|
+
const healthSlot = this.healthSlot; //metadata[this.healthSlot] ? this.healthSlot : metadata.findIndex((met) => Number(met) > 1 && Number(met) <= 20);
|
|
57
55
|
let health = Number(metadata[healthSlot]);
|
|
58
56
|
if (!health || health === 0)
|
|
59
57
|
health = entity === this.bot.entity ? (_a = this.bot.entity.health) !== null && _a !== void 0 ? _a : 0 : 0;
|
|
@@ -62,6 +60,25 @@ class EntityFunctions {
|
|
|
62
60
|
// console.log(health + (Number(metadata[this.healthSlot + 4]) ?? 0))
|
|
63
61
|
return health + ((_b = Number(metadata[this.healthSlot + 4])) !== null && _b !== void 0 ? _b : 0);
|
|
64
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param metadata Must be FULL metadata object.
|
|
66
|
+
* @returns number
|
|
67
|
+
*/
|
|
68
|
+
getHealthFromMetadata(metadata) {
|
|
69
|
+
var _a;
|
|
70
|
+
return (_a = (Number(metadata[this.healthSlot]) + Number(metadata[this.healthSlot + 4]))) !== null && _a !== void 0 ? _a : undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* TODO: Version specific right now. Generalize. Unknown method.
|
|
74
|
+
* @param metadata metadata from Prismarine-Entity Entity.
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
getHealthChange(packetMetadata, entity) {
|
|
78
|
+
const oldHealth = this.getHealthFromMetadata(entity.metadata);
|
|
79
|
+
const newHealth = this.getHealthFromMetadata(this.parseMetadata(packetMetadata, entity.metadata));
|
|
80
|
+
return -(oldHealth - newHealth);
|
|
81
|
+
}
|
|
65
82
|
getDistanceToEntity(entity) {
|
|
66
83
|
return this.getDistanceBetweenEntities(this.bot.entity, entity);
|
|
67
84
|
}
|
|
@@ -74,5 +91,14 @@ class EntityFunctions {
|
|
|
74
91
|
const { x, y, z } = entity.position;
|
|
75
92
|
return new aabb_1.AABB(-w, 0, -w, w, entity.height, w).offset(x, y, z);
|
|
76
93
|
}
|
|
94
|
+
//Stolen from mineflayer.
|
|
95
|
+
parseMetadata(packetMetadata, entityMetadata = {}) {
|
|
96
|
+
if (packetMetadata !== undefined) {
|
|
97
|
+
for (const { key, value } of packetMetadata) {
|
|
98
|
+
entityMetadata[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return entityMetadata;
|
|
102
|
+
}
|
|
77
103
|
}
|
|
78
104
|
exports.EntityFunctions = EntityFunctions;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AABB =
|
|
3
|
+
exports.AABB = void 0;
|
|
4
4
|
const utilFunctions_1 = require("./utilFunctions");
|
|
5
5
|
function inject(bot) {
|
|
6
6
|
bot.util = new utilFunctions_1.UtilFunctions(bot);
|
|
7
7
|
}
|
|
8
8
|
exports.default = inject;
|
|
9
|
-
var commonSense_1 = require("./commonSense");
|
|
10
|
-
Object.defineProperty(exports, "CommonSense", { enumerable: true, get: function () { return commonSense_1.CommonSense; } });
|
|
11
9
|
var aabb_1 = require("./calcs/aabb");
|
|
12
10
|
Object.defineProperty(exports, "AABB", { enumerable: true, get: function () { return aabb_1.AABB; } });
|
package/lib/utilFunctions.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { InventoryFunctions } from "./inventoryFunctions";
|
|
|
6
6
|
import { MovementFunctions } from "./movementFunctions";
|
|
7
7
|
import { PredictiveFunctions } from "./predictiveFunctions";
|
|
8
8
|
import { MathFunctions } from "./mathUtil";
|
|
9
|
-
import { CommonSense } from "./commonSense";
|
|
10
9
|
import { WorldFunctions } from "./WorldFunctions";
|
|
11
10
|
export declare type BuiltInPriorityOptions = {
|
|
12
11
|
group: PrioGroups;
|
|
@@ -28,7 +27,6 @@ export declare class UtilFunctions {
|
|
|
28
27
|
predict: PredictiveFunctions;
|
|
29
28
|
filters: FilterFunctions;
|
|
30
29
|
math: MathFunctions;
|
|
31
|
-
commonSense: CommonSense;
|
|
32
30
|
world: WorldFunctions;
|
|
33
31
|
private builtInsPriorityStore;
|
|
34
32
|
private customPriorityStore;
|
package/lib/utilFunctions.js
CHANGED
|
@@ -17,7 +17,6 @@ const movementFunctions_1 = require("./movementFunctions");
|
|
|
17
17
|
const util_1 = require("util");
|
|
18
18
|
const predictiveFunctions_1 = require("./predictiveFunctions");
|
|
19
19
|
const mathUtil_1 = require("./mathUtil");
|
|
20
|
-
const commonSense_1 = require("./commonSense");
|
|
21
20
|
const WorldFunctions_1 = require("./WorldFunctions");
|
|
22
21
|
class UtilFunctions {
|
|
23
22
|
constructor(bot) {
|
|
@@ -28,7 +27,6 @@ class UtilFunctions {
|
|
|
28
27
|
this.entity = new entityFunctions_1.EntityFunctions(bot);
|
|
29
28
|
this.predict = new predictiveFunctions_1.PredictiveFunctions(bot);
|
|
30
29
|
this.filters = new filterFunctions_1.FilterFunctions(bot);
|
|
31
|
-
this.commonSense = new commonSense_1.CommonSense(bot);
|
|
32
30
|
this.world = new WorldFunctions_1.WorldFunctions(bot);
|
|
33
31
|
this.math = new mathUtil_1.MathFunctions();
|
|
34
32
|
this.builtInsPriorityStore = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxg-org/mineflayer-util-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "mineflayer utils for NextGEN mineflayer plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mineflayer",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"prepublish": "npm run build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@nxg-org/mineflayer-util-plugin": "^1.0.1",
|
|
23
22
|
"minecraft-data": "^2.97.0",
|
|
24
23
|
"mineflayer": "^3.11.2",
|
|
25
24
|
"mineflayer-pathfinder": "^1.8.0",
|
package/lib/commonSense.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Bot } from "mineflayer";
|
|
2
|
-
import type { Block } from "prismarine-block";
|
|
3
|
-
export declare class CommonSense {
|
|
4
|
-
bot: Bot;
|
|
5
|
-
autoRespond: boolean;
|
|
6
|
-
isFalling: boolean;
|
|
7
|
-
isOnFire: boolean;
|
|
8
|
-
checkForFalling: boolean;
|
|
9
|
-
checkForFire: boolean;
|
|
10
|
-
useOffHand: boolean;
|
|
11
|
-
requipLastItem: boolean;
|
|
12
|
-
puttingOutFire: boolean;
|
|
13
|
-
MLGing: boolean;
|
|
14
|
-
constructor(bot: Bot);
|
|
15
|
-
onMetadataFireCheck(packet: any): Promise<void>;
|
|
16
|
-
onStatusFireCheck(packet: any): Promise<void>;
|
|
17
|
-
putOutFire(): Promise<boolean>;
|
|
18
|
-
pickUpWater(nearbyBlock?: Block | null, maxDistance?: number, immediate?: boolean): Promise<void>;
|
|
19
|
-
isFallingCheckEasy(): Promise<void>;
|
|
20
|
-
private findBlockForWaterPlacement;
|
|
21
|
-
waterBucket(): Promise<boolean>;
|
|
22
|
-
}
|
package/lib/commonSense.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CommonSense = void 0;
|
|
13
|
-
const vec3_1 = require("vec3");
|
|
14
|
-
const util_1 = require("util");
|
|
15
|
-
const sleep = (0, util_1.promisify)(setTimeout);
|
|
16
|
-
class CommonSense {
|
|
17
|
-
constructor(bot) {
|
|
18
|
-
this.bot = bot;
|
|
19
|
-
this.autoRespond = false;
|
|
20
|
-
this.isFalling = false;
|
|
21
|
-
this.isOnFire = false;
|
|
22
|
-
this.checkForFalling = true;
|
|
23
|
-
this.checkForFire = true;
|
|
24
|
-
this.useOffHand = true;
|
|
25
|
-
this.requipLastItem = false;
|
|
26
|
-
this.puttingOutFire = false;
|
|
27
|
-
this.MLGing = false;
|
|
28
|
-
this.bot.on("physicsTick", this.isFallingCheckEasy.bind(this));
|
|
29
|
-
this.bot._client.on("entity_metadata", this.onMetadataFireCheck.bind(this));
|
|
30
|
-
this.bot._client.on("entity_status", this.onStatusFireCheck.bind(this));
|
|
31
|
-
// this.bot.on("physicsTick", this.onPhysicsTickFireCheck.bind(this));
|
|
32
|
-
//TODO: Move this to bot movement.
|
|
33
|
-
}
|
|
34
|
-
// async onPhysicsTickFireCheck() {
|
|
35
|
-
// if ((this.bot.entity.metadata[0] as any) === 1) {
|
|
36
|
-
// this.isOnFire = true;
|
|
37
|
-
// while (!this.bot.entity.onGround) await sleep(0);
|
|
38
|
-
// if (!this.puttingOutFire && this.autoRespond) this.putOutFire();
|
|
39
|
-
// } else {
|
|
40
|
-
// this.isOnFire = false
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
onMetadataFireCheck(packet) {
|
|
44
|
-
var _a;
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (!this.checkForFire)
|
|
47
|
-
return;
|
|
48
|
-
if (!packet.entityId)
|
|
49
|
-
return;
|
|
50
|
-
const entity = this.bot.entities[packet.entityId];
|
|
51
|
-
if (!entity || entity !== this.bot.entity)
|
|
52
|
-
return;
|
|
53
|
-
// if ((entity.metadata[0] as any).value !== 1) {
|
|
54
|
-
const wantedKey = packet.metadata.findIndex((md) => md.key === 0);
|
|
55
|
-
if (wantedKey === -1)
|
|
56
|
-
return;
|
|
57
|
-
if (((_a = packet.metadata[wantedKey]) === null || _a === void 0 ? void 0 : _a.value) !== 1) {
|
|
58
|
-
this.isOnFire = false;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// }
|
|
62
|
-
this.isOnFire = true;
|
|
63
|
-
while (!this.bot.entity.onGround)
|
|
64
|
-
yield this.bot.waitForTicks(1);
|
|
65
|
-
if (!this.puttingOutFire && this.autoRespond)
|
|
66
|
-
this.putOutFire();
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
onStatusFireCheck(packet) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (!this.checkForFire)
|
|
72
|
-
return;
|
|
73
|
-
if (!packet.entityId)
|
|
74
|
-
return;
|
|
75
|
-
const entity = this.bot.entities[packet.entityId];
|
|
76
|
-
if (!entity || entity !== this.bot.entity)
|
|
77
|
-
return;
|
|
78
|
-
if (!packet.entityStatus || packet.entityStatus !== 37) {
|
|
79
|
-
this.isOnFire = false;
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
this.isOnFire = true;
|
|
83
|
-
while (!this.bot.entity.onGround)
|
|
84
|
-
yield sleep(0);
|
|
85
|
-
if (!this.puttingOutFire && this.autoRespond)
|
|
86
|
-
this.putOutFire();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
putOutFire() {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
if (this.puttingOutFire)
|
|
93
|
-
return true;
|
|
94
|
-
this.puttingOutFire = true;
|
|
95
|
-
const water = this.bot.util.inv.getAllItemsExceptCurrent("off-hand").find((item) => item === null || item === void 0 ? void 0 : item.name.includes("water_bucket"));
|
|
96
|
-
const holdingItem = (_a = this.bot.util.inv.getHandWithItem(this.useOffHand)) === null || _a === void 0 ? void 0 : _a.name.includes("water_bucket");
|
|
97
|
-
if (!water && !holdingItem) {
|
|
98
|
-
this.puttingOutFire = false;
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
else if (!holdingItem && water)
|
|
102
|
-
yield this.bot.util.inv.customEquip(water, "off-hand");
|
|
103
|
-
if ((_b = this.bot.util.inv.getHandWithItem(this.useOffHand)) === null || _b === void 0 ? void 0 : _b.name.includes("water_bucket")) {
|
|
104
|
-
const nearbyBlock = this.bot.findBlock({ matching: (block) => (block === null || block === void 0 ? void 0 : block.name) === "fire", maxDistance: 2 });
|
|
105
|
-
if (nearbyBlock) {
|
|
106
|
-
yield this.bot.dig(nearbyBlock, true);
|
|
107
|
-
yield this.bot.util.move.forceLookAt(nearbyBlock.position.offset(0, -1, 0));
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
yield this.bot.util.move.forceLook(this.bot.entity.yaw, -90);
|
|
111
|
-
}
|
|
112
|
-
// while (!this.bot.entity.isCollidedVertically) await this.bot.waitForTicks(1);
|
|
113
|
-
this.bot.activateItem(this.useOffHand);
|
|
114
|
-
yield this.pickUpWater(nearbyBlock);
|
|
115
|
-
this.puttingOutFire = false;
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
this.puttingOutFire = false;
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
pickUpWater(nearbyBlock = null, maxDistance = 2, immediate = false) {
|
|
125
|
-
var _a;
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
if (!immediate)
|
|
128
|
-
yield this.bot.waitForTicks(3);
|
|
129
|
-
const block = this.bot.findBlock({
|
|
130
|
-
point: (_a = nearbyBlock === null || nearbyBlock === void 0 ? void 0 : nearbyBlock.position) !== null && _a !== void 0 ? _a : this.bot.entity.position,
|
|
131
|
-
matching: (block) => (block.type === 8 || block.type === 9) && block.metadata === 0,
|
|
132
|
-
//@ts-expect-error
|
|
133
|
-
useExtraInfo: (block) => {
|
|
134
|
-
return this.bot.util.world.getBlockAABB(block).distanceTo(this.bot.entity.position, 1.62) < 4;
|
|
135
|
-
},
|
|
136
|
-
maxDistance: maxDistance,
|
|
137
|
-
});
|
|
138
|
-
if (block) {
|
|
139
|
-
this.bot.util.move.forceLookAt(block.position.offset(0.5, 0.5, 0.5), true);
|
|
140
|
-
this.bot.activateItem(this.useOffHand);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
console.log("didn't get block. fuck.");
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
isFallingCheckEasy() {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
if (!this.checkForFalling)
|
|
150
|
-
return;
|
|
151
|
-
if (this.bot.entity.velocity.y >= -0.6) {
|
|
152
|
-
this.isFalling = false;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
this.isFalling = true;
|
|
156
|
-
if (!this.MLGing && this.autoRespond) {
|
|
157
|
-
yield this.waterBucket();
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
findBlockForWaterPlacement() {
|
|
162
|
-
const pos = this.bot.entity.position.offset(this.bot.entity.velocity.x, 0, this.bot.entity.velocity.z);
|
|
163
|
-
const aabb = this.bot.util.entity.getEntityAABB({
|
|
164
|
-
position: pos,
|
|
165
|
-
height: this.bot.entity.height,
|
|
166
|
-
width: 0.3,
|
|
167
|
-
});
|
|
168
|
-
const spacing = { x0: aabb.minX, z0: aabb.minZ, x1: aabb.maxX, z1: aabb.maxZ };
|
|
169
|
-
const floored = { x0: Math.floor(spacing.x0), z0: Math.floor(spacing.z0), x1: Math.floor(spacing.x1), z1: Math.floor(spacing.z1) };
|
|
170
|
-
let blocks = [];
|
|
171
|
-
const posY = this.bot.entity.position.clone().floored().y;
|
|
172
|
-
loop1: for (let i = floored.x0; i <= floored.x1; i++) {
|
|
173
|
-
loop2: for (let j = floored.z0; j <= floored.z1; j++) {
|
|
174
|
-
loop3: for (let k = posY; k > 0; k--) {
|
|
175
|
-
const block = this.bot.blockAt(new vec3_1.Vec3(i, k, j));
|
|
176
|
-
if (!!block && block.type !== 0) {
|
|
177
|
-
blocks.push(block);
|
|
178
|
-
break loop3;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const maxY = Math.max(...blocks.map((b) => b.position.y));
|
|
184
|
-
blocks = blocks.filter((b) => b.position.y === maxY);
|
|
185
|
-
const block = blocks.sort((a, b) => this.bot.util.world.getBlockAABB(b).distanceTo(pos) - this.bot.util.world.getBlockAABB(a).distanceTo(pos))[0];
|
|
186
|
-
// console.log(block.position, this.bot.entity.position, this.bot.entity.position.distanceTo(block.position).toFixed(2));
|
|
187
|
-
return block;
|
|
188
|
-
}
|
|
189
|
-
waterBucket() {
|
|
190
|
-
var _a, _b;
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
if (this.MLGing)
|
|
193
|
-
return true;
|
|
194
|
-
this.MLGing = true;
|
|
195
|
-
const water = this.bot.util.inv.getAllItemsExceptCurrent("off-hand").find((item) => item === null || item === void 0 ? void 0 : item.name.includes("water_bucket"));
|
|
196
|
-
const holdingItem = (_a = this.bot.util.inv.getHandWithItem(true)) === null || _a === void 0 ? void 0 : _a.name.includes("water_bucket");
|
|
197
|
-
if (!water && !holdingItem) {
|
|
198
|
-
this.MLGing = false;
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
else if (!holdingItem && water)
|
|
202
|
-
yield this.bot.util.inv.customEquip(water, "off-hand");
|
|
203
|
-
for (let i = 0; i < 120; i++) {
|
|
204
|
-
const landingBlock = this.findBlockForWaterPlacement();
|
|
205
|
-
if (landingBlock) {
|
|
206
|
-
yield this.bot.util.move.forceLookAt(landingBlock.position.offset(0.5, 0.5, 0.5), true);
|
|
207
|
-
}
|
|
208
|
-
if (this.bot.entity.position.y <= ((_b = landingBlock === null || landingBlock === void 0 ? void 0 : landingBlock.position.y) !== null && _b !== void 0 ? _b : 0) + 3) {
|
|
209
|
-
this.bot.activateItem(this.useOffHand);
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
yield this.bot.waitForTicks(1);
|
|
213
|
-
}
|
|
214
|
-
yield this.pickUpWater(null, 2);
|
|
215
|
-
this.MLGing = false;
|
|
216
|
-
return true;
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
exports.CommonSense = CommonSense;
|