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

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

Open
MatLudke opened this issue Jan 8, 2023 · 0 comments
Open

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

MatLudke opened this issue Jan 8, 2023 · 0 comments

Comments

@MatLudke
Copy link

MatLudke commented Jan 8, 2023

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant