8000 Cannot read properties of undefined (reading 'targets') · Issue #93 · PrismarineJS/mineflayer-collectblock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Cannot read properties of undefined (reading 'targets') #93
Open
@murilopereirame

Description

@murilopereirame

The latest version of plugin throws

TypeError: Cannot read properties of undefined (reading 'targets')
    at /Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:191:31
    at Generator.next (<anonymous>)
    at /Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:4:12)
    at collect (/Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:178:16)
    at collectCallbackified (node:util:304:5)
    at CollectBlock.<anonymous> (/Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:185:61)
    at Generator.next (<anonymous>)
    at /Users/mo0p3/Documents/Projetos/MineBot/node_modules/mineflayer-collectblock/lib/CollectBlock.js:8:71

Script

/**
 * A quick and easy implementation of the collect block plugin. (Requires mineflayer-pathfinder and mineflayer-collectblock)
 */
const mineflayer = require("mineflayer");
const pathfinder = require("mineflayer-pathfinder").pathfinder;
const collectBlock = require("mineflayer-collectblock").plugin;

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

// Load pathfinder and collect block plugins
bot.loadPlugin(pathfinder);
bot.loadPlugin(collectBlock);

// Load mc data
let mcData;

const digIron = async () => {
  const block = bot.findBlock({
    matching: mcData.blocksByName.iron_ore.id,
    maxDistance: 64,
  });
  try {
    await bot.collectBlock.collect(
      block,
      {
        append: true,
        ignoreNoPath: true,
        chestLocations: [],
        itemFilter: (item) => true,
      },
      (err) => {
        if (!err) {
          console.log("New dig!");
          digIron();
        } else console.log("CALLBACK=>", err);
      }
    );
  } catch (err) {
    console.log(err);
  }
};

bot.once("spawn", () => {
  mcData = require("minecraft-data")(bot.version);
  digIron();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0