Coder Social home page Coder Social logo

mineflayerarmormanager's Introduction

ArmorManager

Plugin for MineFlayer, that makes bot automatically equip better armor.

Footage

Getting started

If using NPM:

npm install mineflayer-armor-manager

If using YARN:

yarn add mineflayer-armor-manager

Usage

const armorManager = require("mineflayer-armor-manager");
const mineflayer = require("mineflayer");

const bot = mineflayer.createBot({
  username: "Player",
  host: "localhost",
  port: 25565,
});

bot.loadPlugin(armorManager);

If needed, it's possible to trigger a function that will check whole inventory and equip best possible armor, on spawn for example:

bot.once("spawn", () => bot.armorManager.equipAll());

License

MIT © Konstantin Azizov

mineflayerarmormanager's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar g07cha avatar moneymakingtornado avatar rom1504 avatar slord6 avatar theairblow avatar thedudefromci avatar u9g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mineflayerarmormanager's Issues

Add npm deploy to workflows

It would be helpful to have a method of releasing NPM packages automatically when the package version is bumped.

How to support elytra ???

I want to use elytra but the plugins doesn't allow us to use elytra.

So I'm able to code the feature. But how add a method like equipeElytra or bot.armor.elytra=true ???

What do you thinks ?

Don't log errors on picking up XP orbs

It's extremely common to pick up XP orbs in Minecraft. Currently, an error is thrown every time one is picked up. These don't hurt the bot in any way, but they are extremely spammy in the console.

using hideErrors: true fixes this, but can pose other issues by hiding other important issues from other plugins or bot code.

Support enchants (and nbt)

currently armor is chosen by itemId which disregards both nbt and enchants so...
this plugin would need to add support for

  • exact item equiping (dont equip by item id, equip by item reference)
  • choosing armor pieces by which has better enchants

Support for Shields / Totem

It would be useful to automatically equip shields (or totems) if one is available, as this is usually also equipped alongside armor.

Promisify

To match the Mineflayer codebase.

Not working for 1.15.2

Hi,

I found out it's not working for 1.15.2 and wrote a fix, can you give me permissions to push a branch so I can contribute? ;)

I use armorManager but the problem is when it gets the armor in inventory this error occures

Failed to retrieve block id, probably exp bottle TypeError: Cannot read properties of null (reading 'findItemOrBlockById')
at isArmor (D:\Burda Yap\FelixBot Minecraft\node_modules\mineflayer-armor-manager\dist\lib\isArmor.js:7:30)
at EventEmitter.onPlayerCollect (D:\Burda Yap\FelixBot Minecraft\node_modules\mineflayer-armor-manager\dist\index.js:43:27)
at EventEmitter.emit (node:events:530:35)
at Client. (D:\Burda Yap\FelixBot Minecraft\node_modules\mineflayer\lib\plugins\entities.js:144:9)
at Client.emit (node:events:518:28)
at emitPacket (D:\Burda Yap\FelixBot Minecraft\node_modules\minecraft-protocol\src\client.js:83:12)
at FullPacketParser. (D:\Burda Yap\FelixBot Minecraft\node_modules\minecraft-protocol\src\client.js:112:9)
at FullPacketParser.emit (node:events:518:28)
at addChunk (D:\Burda Yap\FelixBot Minecraft\node_modules\protodef\node_modules\readable-stream\lib_stream_readable.js:298:12)
at readableAddChunk (D:\Burda Yap\FelixBot Minecraft\node_modules\protodef\node_modules\readable-stream\lib_stream_readable.js:280:11)

minecraft-data": 3.60.0
mineflayer: 4.18.0
mineflayer-armor-manager: 1.4.2

Plugin loaded after login fails to identify armour

If the plugin is loaded after login, then versionData is not populated. I think this can be fixed by initalising versionData straight away, and then updating with the login event like so:

var versionData = minecraftData(bot.version)

  // Version is only detected after bot logs in 
  bot.on('login', function onLogin() {
      versionData = minecraftData(bot.version)
  })

Bug with XP

Versions

  • mineflayer: 1.16.3
  • server: vanilla/spigot/paper vanilla
  • node: 15.6.0

Detailed description of a problem

when it kills a moped and drops an orbit xp it gives me an error message

Error

Failed to retrieve block id, probably exp bottle TypeError: Cannot use 'in' operator to search for 'itemId' in 0
at EventEmitter.onPlayerCollect (D:\dev test\mc bot\node_modules\mineflayer-armor-manager\dist\index.js:35:35)
at EventEmitter.emit (node:events:379:20)
at Client. (D:\dev test\mc bot\node_modules\mineflayer\lib\plugins\entities.js:159:9)
at Client.emit (node:events:379:20)
at FullPacketParser. (D:\dev test\mc bot\node_modules\minecraft-protocol\src\client.js:91:12)
at FullPacketParser.emit (node:events:379:20)
at addChunk (D:\dev test\mc bot\node_modules\readable-stream\lib_stream_readable.js:298:12)
at readableAddChunk (D:\dev test\mc bot\node_modules\readable-stream\lib_stream_readable.js:280:11)
at FullPacketParser.Readable.push (D:\dev test\mc bot\node_modules\readable-stream\lib_stream_readable.js:241:10)
at FullPacketParser.Transform.push (D:\dev test\mc bot\node_modules\readable-stream\lib_stream_transform.js:139:32)

Stops when using bot.clickWindow() or bot.closeWindow()

Info

  • Stops working when using bot.clickWindow() or bot.closeWindow()
  • The code below is dropping all items from inventory, and then plugin stops working

Code

      var slots = bot.inventory.slots
      for (var currSlot of slots) {
        if (currSlot == null) continue;
        bot.clickWindow(currSlot.slot, 0, 0, () => {
          bot.clickWindow(-999, 0, 0)
        })
        bot.closeWindow(slots)
        continue;
      }

Fails to detect item

Spam with error on item pickup, even without any related code to armor manager at all.

Mineflayer 4.8.1
mineflayer-armor-manager: 1.4.2
Minecraft: 1.19.3/java
Nodejs: 18.14.0

Failed to retrieve block id, probably exp bottle TypeError: Cannot read properties of null (reading 'findItemOrBlockById')
    at Object.isArmor (C:\dev\NodeMinecraftProtocol\ArtIdiot\node_modules\mineflayer-armor-manager\dist\lib\isArmor.js:7:30)
    at EventEmitter.onPlayerCollect (C:\dev\NodeMinecraftProtocol\ArtIdiot\node_modules\mineflayer-armor-manager\dist\index.js:42:37)
    at EventEmitter.emit (node:events:525:35)
    at EventEmitter.emit (node:domain:489:12)
    at Client.<anonymous> (C:\dev\NodeMinecraftProtocol\ArtIdiot\node_modules\mineflayer\lib\plugins\entities.js:170:9)
    at Client.emit (node:events:513:28)
    at Client.emit (node:domain:489:12)
    at FullPacketParser.<anonymous> (C:\dev\NodeMinecraftProtocol\ArtIdiot\node_modules\mineflayer\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (node:events:513:28)
    at FullPacketParser.emit (node:domain:489:12)

Totem support

Currently only armor chosen, but what about Totems of Undying?

The bot crashes when trying to use equipAll while you have helmet on

C:\Mineflayer00\node_modules\minecraft-protocol\src\transforms\framing.js:67
          } else { throw e }
                   ^

TypeError: Cannot read property 'id' of undefined
    at confirmTransaction (C:\Mineflayer00\node_modules\mineflayer\lib\plugins\inventory.js:465:29)
    at Client.<anonymous> (C:\Mineflayer00\node_modules\mineflayer\lib\plugins\inventory.js:566:5)
    at Client.emit (node:events:329:20)
    at FullPacketParser.<anonymous> (C:\Mineflayer00\node_modules\minecraft-protocol\src\client.js:91:12)
    at FullPacketParser.emit (node:events:329:20)
    at addChunk (C:\Mineflayer00\node_modules\readable-stream\lib\_stream_readable.js:298:12)
    at readableAddChunk (C:\Mineflayer00\node_modules\readable-stream\lib\_stream_readable.js:280:11)
    at FullPacketParser.Readable.push (C:\Mineflayer00\node_modules\readable-stream\lib\_stream_readable.js:241:10)
    at FullPacketParser.Transform.push (C:\Mineflayer00\node_modules\readable-stream\lib\_stream_transform.js:139:32)
    at FullPacketParser._transform (C:\Mineflayer00\node_modules\protodef\src\serializer.js:89:10)

I keep getting this, the Mineflayer version is latest.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.