@nxg-org/mineflayer-physics-util 1.4.7 → 1.5.0

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.
@@ -83,7 +83,7 @@ class EntityPhysics {
83
83
  }
84
84
  getEntityBB(entity, pos) {
85
85
  const w = entity.getHalfWidth();
86
- return new mineflayer_util_plugin_1.AABB(-w, 0, -w, w, entity.height, w).offset(pos.x, pos.y, pos.z);
86
+ return new mineflayer_util_plugin_1.AABB(-w, 0, -w, w, entity.height, w).translate(pos.x, pos.y, pos.z);
87
87
  }
88
88
  setPositionToBB(entity, bb, pos) {
89
89
  const halfWidth = entity.getHalfWidth();
@@ -105,7 +105,7 @@ class EntityPhysics {
105
105
  const blockPos = block.position;
106
106
  for (const shape of block.shapes) {
107
107
  const blockBB = new mineflayer_util_plugin_1.AABB(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]);
108
- blockBB.offset(blockPos.x, blockPos.y, blockPos.z);
108
+ blockBB.translate(blockPos.x, blockPos.y, blockPos.z);
109
109
  surroundingBBs.push(blockBB);
110
110
  }
111
111
  }
@@ -124,7 +124,7 @@ class EntityPhysics {
124
124
  const blockPos = block.position;
125
125
  for (const shape of block.shapes) {
126
126
  const blockBB = new mineflayer_util_plugin_1.AABB(shape[0], shape[1], shape[2], shape[3], shape[4], shape[5]);
127
- blockBB.offset(blockPos.x, blockPos.y, blockPos.z);
127
+ blockBB.translate(blockPos.x, blockPos.y, blockPos.z);
128
128
  surroundingBBs.push(blockBB);
129
129
  }
130
130
  }
@@ -168,7 +168,7 @@ class EntityPhysics {
168
168
  if (entity.useControls && entity.state.controlState.sneak && entity.state.onGround) {
169
169
  const step = 0.05;
170
170
  // In the 3 loops bellow, y offset should be -1, but that doesnt reproduce vanilla behavior.
171
- for (; dx !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).offset(dx, 0, 0), world).length === 0; oldVelX = dx) {
171
+ for (; dx !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).translate(dx, 0, 0), world).length === 0; oldVelX = dx) {
172
172
  if (dx < step && dx >= -step)
173
173
  dx = 0;
174
174
  else if (dx > 0)
@@ -176,7 +176,7 @@ class EntityPhysics {
176
176
  else
177
177
  dx += step;
178
178
  }
179
- for (; dz !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).offset(0, 0, dz), world).length === 0; oldVelZ = dz) {
179
+ for (; dz !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).translate(0, 0, dz), world).length === 0; oldVelZ = dz) {
180
180
  if (dz < step && dz >= -step)
181
181
  dz = 0;
182
182
  else if (dz > 0)
@@ -184,7 +184,7 @@ class EntityPhysics {
184
184
  else
185
185
  dz += step;
186
186
  }
187
- while (dx !== 0 && dz !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).offset(dx, 0, dz), world).length === 0) {
187
+ while (dx !== 0 && dz !== 0 && this.getSurroundingBBs(this.getEntityBB(entity, pos).translate(dx, 0, dz), world).length === 0) {
188
188
  if (dx < step && dx >= -step)
189
189
  dx = 0;
190
190
  else if (dx > 0)
@@ -208,15 +208,15 @@ class EntityPhysics {
208
208
  for (const blockBB of surroundingBBs) {
209
209
  dy = blockBB.computeOffsetY(playerBB, dy);
210
210
  }
211
- playerBB.offset(0, dy, 0);
211
+ playerBB.translate(0, dy, 0);
212
212
  for (const blockBB of surroundingBBs) {
213
213
  dx = blockBB.computeOffsetX(playerBB, dx);
214
214
  }
215
- playerBB.offset(dx, 0, 0);
215
+ playerBB.translate(dx, 0, 0);
216
216
  for (const blockBB of surroundingBBs) {
217
217
  dz = blockBB.computeOffsetZ(playerBB, dz);
218
218
  }
219
- playerBB.offset(0, 0, dz);
219
+ playerBB.translate(0, 0, dz);
220
220
  // Step on block if height < stepHeight
221
221
  if (entity.stepHeight > 0 && (entity.state.onGround || (dy !== oldVelY && oldVelY < 0)) && (dx !== oldVelX || dz !== oldVelZ)) {
222
222
  const oldVelXCol = dx;
@@ -235,24 +235,24 @@ class EntityPhysics {
235
235
  dy1 = blockBB.computeOffsetY(BB_XZ, dy1);
236
236
  dy2 = blockBB.computeOffsetY(BB2, dy2);
237
237
  }
238
- BB1.offset(0, dy1, 0);
239
- BB2.offset(0, dy2, 0);
238
+ BB1.translate(0, dy1, 0);
239
+ BB2.translate(0, dy2, 0);
240
240
  let dx1 = oldVelX;
241
241
  let dx2 = oldVelX;
242
242
  for (const blockBB of surroundingBBs) {
243
243
  dx1 = blockBB.computeOffsetX(BB1, dx1);
244
244
  dx2 = blockBB.computeOffsetX(BB2, dx2);
245
245
  }
246
- BB1.offset(dx1, 0, 0);
247
- BB2.offset(dx2, 0, 0);
246
+ BB1.translate(dx1, 0, 0);
247
+ BB2.translate(dx2, 0, 0);
248
248
  let dz1 = oldVelZ;
249
249
  let dz2 = oldVelZ;
250
250
  for (const blockBB of surroundingBBs) {
251
251
  dz1 = blockBB.computeOffsetZ(BB1, dz1);
252
252
  dz2 = blockBB.computeOffsetZ(BB2, dz2);
253
253
  }
254
- BB1.offset(0, 0, dz1);
255
- BB2.offset(0, 0, dz2);
254
+ BB1.translate(0, 0, dz1);
255
+ BB2.translate(0, 0, dz2);
256
256
  const norm1 = dx1 * dx1 + dz1 * dz1;
257
257
  const norm2 = dx2 * dx2 + dz2 * dz2;
258
258
  if (norm1 > norm2) {
@@ -270,7 +270,7 @@ class EntityPhysics {
270
270
  for (const blockBB of surroundingBBs) {
271
271
  dy = blockBB.computeOffsetY(playerBB, dy);
272
272
  }
273
- playerBB.offset(0, dy, 0);
273
+ playerBB.translate(0, dy, 0);
274
274
  if (oldVelXCol * oldVelXCol + oldVelZCol * oldVelZCol >= dx * dx + dz * dz) {
275
275
  dx = oldVelXCol;
276
276
  dy = oldVelYCol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxg-org/mineflayer-physics-util",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "Provides functionality for more accurate entity and projectile tracking.",
5
5
  "keywords": [
6
6
  "mineflayer",
@@ -21,7 +21,7 @@
21
21
  "test": "ts-node -T tests/fakeWorld.ts"
22
22
  },
23
23
  "dependencies": {
24
- "@nxg-org/mineflayer-util-plugin": "^1.6.2"
24
+ "@nxg-org/mineflayer-util-plugin": "^1.7.11"
25
25
  },
26
26
  "devDependencies": {
27
27
  "mineflayer": "^4.6.0",