PrismarineJS / mineflayer-collectblock

A simple utility plugin for Mineflayer that add a higher level API for collecting blocks.
MIT License
40 stars 25 forks source link

TypeError: Cannot read properties of undefined (reading 'id') #114

Open MatLudke opened 1 year ago

MatLudke commented 1 year ago

i copied the code from the repository and i cant run it, have installed all the dependencies `// Create your bot const mineflayer = require("mineflayer") const bot = mineflayer.createBot({ host: 'fakeafusername.aternos.me', username: 'Player', version: '1.8.9' }) let mcData

// Load collect block bot.loadPlugin(require('mineflayer-collectblock').plugin)

async function collectGrass() { // Find a nearby grass block const grass = bot.findBlock({ matching: mcData.blocksByName.grass_block.id, maxDistance: 64 })

if (grass) { // If we found one, collect it. try { await bot.collectBlock.collect(grass) collectGrass() // Collect another grass block } catch (err) { console.log(err) // Handle errors, if any } } }

// On spawn, start collecting all nearby grass bot.once('spawn', () => { mcData = require('minecraft-data')(bot.version) collectGrass() })`

it gives this eror: matching: mcData.blocksByName.grass_block.id, ^ TypeError: Cannot read properties of undefined (reading 'id')