@nxg-org/mineflayer-util-plugin 1.8.2 → 1.8.3

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.
@@ -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
- contains(x: number, y: number, z: number): boolean;
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 (this.minX <= d4 && this.maxX >= d && this.minY <= d5 && this.maxY >= d2 && this.minZ <= d6 && this.maxZ >= d3);
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 (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) {
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,17 +25,17 @@ var AABBUtils;
25
25
  }
26
26
  AABBUtils.getEntityAABB = getEntityAABB;
27
27
  function getPlayerAABB(entity) {
28
- const w = entity.width ? entity.width / 2 : 0.6;
29
- return new aabb_1.AABB(-w, 0, -w, w, entity.height ? entity.height + 0.18 : 1.8, w).translateVec(entity.position);
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.6, 0, -0.6, 0.6, height, 0.6).translateVec(position);
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 w = entity.width ? entity.width / 2 : entity.height / 2;
38
- return new aabb_1.AABB(-w, 0, -w, w, entity.height, w).translateVec(entity.position);
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 = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxg-org/mineflayer-util-plugin",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "mineflayer utils for NextGEN mineflayer plugins.",
5
5
  "keywords": [
6
6
  "mineflayer",