Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot.toss and bot.tossStack instantly crash the bot #3590

Open
1 task done
JaWarrior12 opened this issue Feb 21, 2025 · 2 comments
Open
1 task done

bot.toss and bot.tossStack instantly crash the bot #3590

JaWarrior12 opened this issue Feb 21, 2025 · 2 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@JaWarrior12
Copy link

JaWarrior12 commented Feb 21, 2025

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 10.9.2
  • server: vanilla/spigot/paper vanilla 1.20.4
  • node: 22.14.0

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?

I'm trying to build a kitbot for shulker/item delivery. When I go to have the bot toss the items out from its inventory, it crashes instantly.

Error:

    triggerUncaughtException(err, true /* fromPromise */);
    ^

AssertionError [ERR_ASSERTION]: Invalid itemType
    at transferOne (----\node_modules\mineflayer\lib\plugins\inventory.js:293:9)
    at EventEmitter.transfer (----\node_modules\mineflayer\lib\plugins\inventory.js:280:11)
    at EventEmitter.toss (----\node_modules\mineflayer\lib\plugins\simple_inventory.js:40:15)
    at EventEmitter.<anonymous> (--------\fetchKit.js:62:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: undefined,
  expected: true,
  operator: '=='
}

What did you try yet?

Did you try any method from the API? Yes, I've tried both toss and tossStack, both fail with the same AssertionError
Did you try any example? Any error from those? I haven't found an example that uses toss or tossStack.

I've tried hard coding the item data through a direct minecraft-data itemsByName and to hasn't worked.

Your current code

const mcData = require('minecraft-data')(botInstance.version)
const chestBlock = bot.findBlock({
    matching: mcData.blocksByName.chest.id,
    maxDistance: 2
  })
//const chestBlock = botInstance.blockAt(chestPos, true);
const chest = await botInstance.openContainer(chestBlock);

const item = chestData.item;
await chest.withdraw(botInstance.registry.itemsByName[item].id, null, amount);
chest.close();

botInstance.chat(`/w ${player} Took ${amount} ${item} from "${chestName}" chest.`);
botInstance.chat(`/tpa ${player}`);
botInstance.pathfinder.setGoal(null);
console.log(mcData.blocksByName["lime_shulker_box"])
console.log(mcData.blocksByName["lime_shulker_box"].id)
console.log(mcData.blocksByName[chestData.item])
console.log(mcData.blocksByName[chestData.item].id)
const itemInfo = mcData.itemsByName[chestData.item]
botInstance.toss(itemInfo,null,amount)//, null, amount);
resolve(true);
} catch (error) {
console.log("Error taking item from chest:");
reject(error);
}

Expected behavior

The bot is expected to toss the shulker box from its inventory, instead it crashes.

@JaWarrior12 JaWarrior12 added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Feb 21, 2025
@rom1504
Copy link
Member

rom1504 commented Feb 21, 2025

bot.tossStack(book)

@rom1504
Copy link
Member

rom1504 commented Feb 21, 2025

await bot.toss(item.type, null, amount)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

2 participants