@nxg-org/mineflayer-util-plugin 1.8.2 → 1.8.4
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
CHANGED
|
@@ -17,6 +17,7 @@ export declare class AABB {
|
|
|
17
17
|
constructor(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number);
|
|
18
18
|
static fromVecs(min: FakeVec3, max: FakeVec3): AABB;
|
|
19
19
|
static fromBlock(min: FakeVec3): AABB;
|
|
20
|
+
static fromBlockPos(min: FakeVec3): AABB;
|
|
20
21
|
static fromShape(pts: AABBPoints, offset?: Vec3): AABB;
|
|
21
22
|
set(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
|
|
22
23
|
clone(): AABB;
|
|
@@ -72,8 +73,9 @@ export declare class AABB {
|
|
|
72
73
|
intersectsCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
73
74
|
collides(aABB: AABB): boolean;
|
|
74
75
|
collidesCoords(d: number, d2: number, d3: number, d4: number, d5: number, d6: number): boolean;
|
|
76
|
+
contains(aABB: AABB): boolean;
|
|
75
77
|
containsVec(vec: FakeVec3): boolean;
|
|
76
|
-
|
|
78
|
+
containsCoords(x: number, y: number, z: number): boolean;
|
|
77
79
|
getCenter(): Vec3;
|
|
78
80
|
}
|
|
79
81
|
export default AABB;
|
package/lib/calcs/aabb.js
CHANGED
|
@@ -21,6 +21,9 @@ class AABB {
|
|
|
21
21
|
static fromBlock(min) {
|
|
22
22
|
return new AABB(min.x, min.y, min.z, min.x + 1.0, min.y + 1.0, min.z + 1.0);
|
|
23
23
|
}
|
|
24
|
+
static fromBlockPos(min) {
|
|
25
|
+
return new AABB(Math.floor(min.x), Math.floor(min.y), Math.floor(min.z), Math.floor(min.x) + 1.0, Math.floor(min.y) + 1.0, Math.floor(min.z) + 1.0);
|
|
26
|
+
}
|
|
24
27
|
static fromShape(pts, offset = emptyVec) {
|
|
25
28
|
return new AABB(pts[0], pts[1], pts[2], pts[3], pts[4], pts[5]).translateVec(offset);
|
|
26
29
|
}
|
|
@@ -308,17 +311,15 @@ class AABB {
|
|
|
308
311
|
return this.collidesCoords(aABB.minX, aABB.minY, aABB.minZ, aABB.maxX, aABB.maxY, aABB.maxZ);
|
|
309
312
|
}
|
|
310
313
|
collidesCoords(d, d2, d3, d4, d5, d6) {
|
|
311
|
-
return
|
|
314
|
+
return this.minX <= d4 && this.maxX >= d && this.minY <= d5 && this.maxY >= d2 && this.minZ <= d6 && this.maxZ >= d3;
|
|
315
|
+
}
|
|
316
|
+
contains(aABB) {
|
|
317
|
+
return this.containsCoords(aABB.minX, aABB.minY, aABB.minZ) && this.containsCoords(aABB.maxX, aABB.maxY, aABB.maxZ);
|
|
312
318
|
}
|
|
313
319
|
containsVec(vec) {
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
this.maxY >= vec.y &&
|
|
318
|
-
this.minZ <= vec.z &&
|
|
319
|
-
this.maxZ >= vec.z);
|
|
320
|
-
}
|
|
321
|
-
contains(x, y, z) {
|
|
320
|
+
return this.minX <= vec.x && this.maxX >= vec.x && this.minY <= vec.y && this.maxY >= vec.y && this.minZ <= vec.z && this.maxZ >= vec.z;
|
|
321
|
+
}
|
|
322
|
+
containsCoords(x, y, z) {
|
|
322
323
|
return this.minX <= x && this.maxX >= x && this.minY <= y && this.maxY >= y && this.minZ <= z && this.maxZ >= z;
|
|
323
324
|
}
|
|
324
325
|
getCenter() {
|
|
@@ -25,6 +25,7 @@ export declare class InventoryFunctions {
|
|
|
25
25
|
get equippingMainHand(): boolean;
|
|
26
26
|
set equippingOffHand(value: boolean);
|
|
27
27
|
get equippingOffHand(): boolean;
|
|
28
|
+
get equipmentSlots(): EquipmentDestination[];
|
|
28
29
|
getAllItems(): Item[];
|
|
29
30
|
getAllItemsExceptCurrent(current: EquipmentDestination): Item[];
|
|
30
31
|
getHandWithItem(offhand?: boolean): Item | null;
|
|
@@ -62,16 +62,23 @@ class InventoryFunctions {
|
|
|
62
62
|
get equippingOffHand() {
|
|
63
63
|
return this._equippingOffHand;
|
|
64
64
|
}
|
|
65
|
+
get equipmentSlots() {
|
|
66
|
+
const ret = ["hand", "head", "torso", "legs", "feet"];
|
|
67
|
+
if (!this.bot.supportFeature('doesntHaveOffHandSlot')) {
|
|
68
|
+
ret.push("off-hand");
|
|
69
|
+
}
|
|
70
|
+
return ret;
|
|
71
|
+
}
|
|
65
72
|
getAllItems() {
|
|
66
73
|
return [
|
|
67
74
|
...this.bot.inventory.items(),
|
|
68
|
-
...
|
|
75
|
+
...this.equipmentSlots.map((name) => this.bot.inventory.slots[this.bot.getEquipmentDestSlot(name)]),
|
|
69
76
|
].filter((e) => !!e);
|
|
70
77
|
}
|
|
71
78
|
getAllItemsExceptCurrent(current) {
|
|
72
79
|
return [
|
|
73
80
|
...this.bot.inventory.items(),
|
|
74
|
-
...(
|
|
81
|
+
...(this.equipmentSlots
|
|
75
82
|
.filter((name) => name !== current))
|
|
76
83
|
.map((name) => this.bot.inventory.slots[this.bot.getEquipmentDestSlot(name)]),
|
|
77
84
|
].filter((e) => !!e);
|
package/lib/static/aabbUtil.js
CHANGED
|
@@ -25,17 +25,17 @@ var AABBUtils;
|
|
|
25
25
|
}
|
|
26
26
|
AABBUtils.getEntityAABB = getEntityAABB;
|
|
27
27
|
function getPlayerAABB(entity) {
|
|
28
|
-
const
|
|
29
|
-
return new aabb_1.AABB(-
|
|
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
30
|
}
|
|
31
31
|
AABBUtils.getPlayerAABB = getPlayerAABB;
|
|
32
32
|
function getPlayerAABBRaw(position, height = 1.8) {
|
|
33
|
-
return new aabb_1.AABB(-0.
|
|
33
|
+
return new aabb_1.AABB(-0.3, 0, -0.3, 0.3, height, 0.3).translateVec(position);
|
|
34
34
|
}
|
|
35
35
|
AABBUtils.getPlayerAABBRaw = getPlayerAABBRaw;
|
|
36
36
|
function getEntityAABBRaw(entity) {
|
|
37
|
-
const
|
|
38
|
-
return new aabb_1.AABB(-
|
|
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
39
|
}
|
|
40
40
|
AABBUtils.getEntityAABBRaw = getEntityAABBRaw;
|
|
41
41
|
})(AABBUtils = exports.AABBUtils || (exports.AABBUtils = {}));
|