PrismarineJS / mineflayer

Create Minecraft bots with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/mineflayer/
MIT License
4.95k stars 904 forks source link

examples/perfectShotBow.js does not load #3013

Closed tyjtyj closed 1 year ago

tyjtyj commented 1 year ago

Versions

Detailed description of a problem

A clear and concise description of what the problem is, with as much context as possible. What are you building? What problem are you trying to solve? mineflayer/examples/perfectShotBow.js

dumping errors

node:assert:400
    throw err;
    ^

AssertionError [ERR_ASSERTION]: plugin needs to be a function
    at EventEmitter.loadPlugin (/root/mineflayer/node_modules/mineflayer/lib/plugin_loader.js:16:12)
    at Object.<anonymous> (/root/mineflayer/perfectShotBow.js:12:5)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

What did you try yet? nodejs v14 - 18 with same result

npm i minecrafthawkeye

Did you try any method from the API? this is provided examples Did you try any example? Any error from those? Exmples not working

Your current code


/*
https://github.com/PrismarineJS/mineflayer/blob/master/examples/perfectShotBow.js
*/

Expected behavior

A clear and concise description of what you expected to happen. It should load

Additional context

Add any other context about the problem here. https://github.com/sefirosweb/minecraftHawkEye/issues/20

Neotastisch commented 1 year ago

Fix: const minecraftHawkEye = require('minecrafthawkeye'); bot.loadPlugin(minecraftHawkEye.default)

tyjtyj commented 1 year ago

Fix: const minecraftHawkEye = require('minecrafthawkeye'); bot.loadPlugin(minecraftHawkEye.default)

This fixed the issue

amoraschi commented 1 year ago

Could you PR the fix?

Neotastisch commented 1 year ago

Could you PR the fix?

Done