PrismarineJS / mineflayer

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

blockAtCursor cant break nether wart #2744

Closed eeoms closed 1 year ago

eeoms commented 2 years ago

Versions

Detailed description of a problem

I want to make my bot break Nether wart using blockAtCursor()

Your current code

const mineflayer = require('mineflayer');

const bot = mineflayer.createBot({
    host: 'mc.hypixel.net',
    port: 25565,
    username: '#######',
    password: '########',
    version: "1.16.4",
    auth: 'microsoft'
})

async function dig() {
  var block = bot.blockAtCursor(5);
  if (!block) return setTimeout(function() {
    dig();
  }, 100);
  await bot.dig(block, 'ignore', 'raycast') // 2nd param: true to 'snap at block' or 'ignore' to just not turn head
  dig()
}

setTimeout(async () => {
  bot.chat('/play sb')
}, 3000);

setTimeout(async () => {
  bot.chat('/is')
}, 4000);

setTimeout(async () => {
  dig();
}, 5000);

Expected behavior

Breaks the Nether wart in front of the bot

Additional context

Im aware that blockAtCursor() doesnt work with most crops, but is there any way i can get around this? Im trying to make a bot that hold left click while going left.

rom1504 commented 2 years ago

Did you check the data values of that block are correct for your version? (In Minecraft data repo ?)