@nxg-org/mineflayer-util-plugin 1.3.8 → 1.3.9

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,7 +12,7 @@ declare type BlockAndIterations = {
12
12
  iterations: Iteration[];
13
13
  };
14
14
  export declare class InterceptFunctions {
15
- bot: Bot;
15
+ private bot;
16
16
  constructor(bot: Bot);
17
17
  check(from: Vec3, to: Vec3): BlockAndIterations;
18
18
  raycast(from: Vec3, direction: Vec3, range: number): BlockAndIterations;
package/lib/index.js CHANGED
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InterceptFunctions = exports.AABB = void 0;
4
4
  const utilFunctions_1 = require("./utilFunctions");
5
+ const mineflayer_pathfinder_1 = require("mineflayer-pathfinder");
5
6
  function inject(bot) {
7
+ if (!bot.pathfinder)
8
+ bot.loadPlugin(mineflayer_pathfinder_1.pathfinder);
6
9
  bot.util = new utilFunctions_1.UtilFunctions(bot);
7
10
  }
8
11
  exports.default = inject;
@@ -90,18 +90,17 @@ class InventoryFunctions {
90
90
  }
91
91
  findItemByID(itemId, metadata) {
92
92
  var _a, _b;
93
- const potentialMatches = this.getAllItems().filter((item) => item.type === itemId);
94
93
  if (metadata)
95
- return (_a = potentialMatches.find((item) => item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
96
- return (_b = potentialMatches[0]) !== null && _b !== void 0 ? _b : null;
94
+ return (_a = this.getAllItems().find((item) => item.type === itemId && item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
95
+ else
96
+ return (_b = this.getAllItems().find((item) => item.type === itemId)) !== null && _b !== void 0 ? _b : null;
97
97
  }
98
98
  findItem(name, metadata) {
99
99
  var _a, _b;
100
- //[...this.getAllItems(), this.bot.inventory.selectedItem!]
101
- const potentialMatches = this.getAllItems().filter((item) => item === null || item === void 0 ? void 0 : item.name.includes(name));
102
100
  if (metadata)
103
- return (_a = potentialMatches.find((item) => item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
104
- return (_b = potentialMatches[0]) !== null && _b !== void 0 ? _b : null;
101
+ return (_a = this.getAllItems().find((item) => item.name === name && item.metadata === metadata)) !== null && _a !== void 0 ? _a : null;
102
+ else
103
+ return (_b = this.getAllItems().find((item) => item.name === name)) !== null && _b !== void 0 ? _b : null;
105
104
  }
106
105
  //alias.
107
106
  has(name, metadata) {
@@ -100,7 +100,7 @@ class MovementFunctions {
100
100
  if (update) {
101
101
  // this.bot.entity.yaw = yaw;
102
102
  // this.bot.entity.pitch = pitch
103
- this.bot.lookAt(pos, true);
103
+ this.bot.look(yaw, pitch, true);
104
104
  }
105
105
  }
106
106
  }
@@ -91,15 +91,21 @@ const AIR_BLOCK = { type: 0 };
91
91
  class PredictiveFunctions {
92
92
  constructor(bot) {
93
93
  this.bot = bot;
94
- this.damageMultiplier = 7; // for 1.12+ 8 for 1.8 TODO check when the change occur (likely 1.9)
95
94
  this.resistanceIndex = "11";
96
- if (require('minecraft-data')(bot.version).isNewerOrEqualTo("1.16")) {
95
+ const version = Number(bot.version.split(".")[1]);
96
+ if (version === 16) {
97
97
  this.armorToughnessKey = "generic.armorToughness";
98
98
  this.armorProtectionKey = "generic.armor";
99
99
  }
100
100
  else {
101
- this.armorToughnessKey = "generic.armorToughness";
102
- this.armorProtectionKey = "generic.armor";
101
+ this.armorToughnessKey = "minecraft:generic.armor_toughness";
102
+ this.armorProtectionKey = "minecraft:generic.armor";
103
+ }
104
+ if (version > 9) {
105
+ this.damageMultiplier = 8;
106
+ }
107
+ else {
108
+ this.damageMultiplier = 7;
103
109
  }
104
110
  const effects = (0, minecraft_data_1.default)(bot.version).effects;
105
111
  for (const effectId in effects) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxg-org/mineflayer-util-plugin",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "mineflayer utils for NextGEN mineflayer plugins.",
5
5
  "keywords": [
6
6
  "mineflayer",
@@ -28,7 +28,7 @@
28
28
  "vec3": "^0.1.7"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^16.11.11",
31
+ "@types/node": "^17.0.4",
32
32
  "typescript": "^4.5.2"
33
33
  }
34
34
  }