@nxg-org/mineflayer-util-plugin 1.7.2 → 1.7.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.
@@ -12,6 +12,7 @@ export declare class AABB {
12
12
  constructor(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number);
13
13
  static fromVecs(min: Vec3, max: Vec3): AABB;
14
14
  static fromBlock(min: Vec3): AABB;
15
+ static fromShape(pts: AABBPoints, offset?: Vec3): AABB;
15
16
  set(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number): void;
16
17
  clone(): AABB;
17
18
  minPoint(): Vec3;
package/lib/calcs/aabb.js CHANGED
@@ -5,6 +5,7 @@ const vec3_1 = require("vec3");
5
5
  function lerp(f, f2, f3) {
6
6
  return f2 + f * (f3 - f2);
7
7
  }
8
+ const emptyVec = new vec3_1.Vec3(0, 0, 0);
8
9
  class AABB {
9
10
  constructor(x0, y0, z0, x1, y1, z1) {
10
11
  this.minX = x0;
@@ -20,6 +21,9 @@ class AABB {
20
21
  static fromBlock(min) {
21
22
  return new AABB(min.x, min.y, min.z, min.x + 1.0, min.y + 1.0, min.z + 1.0);
22
23
  }
24
+ static fromShape(pts, offset = emptyVec) {
25
+ return new AABB(pts[0], pts[1], pts[2], pts[3], pts[4], pts[5]).offsetVec(offset);
26
+ }
23
27
  set(x0, y0, z0, x1, y1, z1) {
24
28
  this.minX = x0;
25
29
  this.minY = y0;
@@ -69,8 +73,8 @@ class AABB {
69
73
  * @returns {number[][]} single element long array of shapes.
70
74
  */
71
75
  toShapeFromBottomMiddle() {
72
- const wx = lerp(0.5, this.minX, this.maxX);
73
- const wz = lerp(0.5, this.minX, this.maxX);
76
+ const wx = (this.maxX - this.minX) / 2;
77
+ const wz = (this.maxZ - this.minZ) / 2;
74
78
  return [[-wx, 0, -wz, wx, this.maxY - this.minY, wz]];
75
79
  }
76
80
  toVertices() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxg-org/mineflayer-util-plugin",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "mineflayer utils for NextGEN mineflayer plugins.",
5
5
  "keywords": [
6
6
  "mineflayer",