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

Change the code so that the bot digs several blocks, and exactly how much I tell him. #3458

Open
Sweety4ka opened this issue Sep 13, 2024 · 0 comments
Labels
new feature Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Sweety4ka
Copy link

I took the code, but it breaks only one block, for example: collect dirt.
He will only break 1 block, but I want me to write: collect dirt 64, and he dug 64 dirt. Please help me!
Code:
let mcData
bot.once('spawn', () => {
mcData = require('minecraft-data')(bot.version);
})

bot.on('chat', async (username, message) => {
const args = message.split(' ')
if (args[0] !== 'collect') return

let count = 1
if (args.length === 3) count = parseInt(args[1])

let type = args[1]
if (args.length === 3) type = args[2]

const blockType = mcData.blocksByName[type]
if (!blockType) {
return
}

const blocks = bot.findBlocks({
matching: blockType.id,
maxDistance: 64,
count: count
})

if (blocks.length === 0) {
bot.chat("I don't see that block nearby.")
return
}

const targets = []
for (let i = 0; i < Math.min(blocks.length, count); i++) {
targets.push(bot.blockAt(blocks[i]))
}

bot.chat(Found ${targets.length} ${type}(s))

try {
await bot.collectBlock.collect(targets)
// All blocks have been collected.
bot.chat('Done')
} catch (err) {
// An error occurred, report it.
bot.chat(err.message)
console.log(err)
}

})

@Sweety4ka Sweety4ka added new feature Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature 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

1 participant