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

Example code missing )} at the end #145

Closed
EswarBalasubramanian opened this issue Apr 25, 2021 · 1 comment
Closed

Example code missing )} at the end #145

EswarBalasubramanian opened this issue Apr 25, 2021 · 1 comment

Comments

@EswarBalasubramanian
Copy link
Contributor

EswarBalasubramanian commented Apr 25, 2021

EXISTING CODE:
const mineflayer ...
... bot.loadPlugin(pathfinder)

bot.once('spawn', () => { // THIS OPEN BRACKET REQUIRES APPROPRIATE CLOSING BRACKET
...................................
..................................
.............bot.pathfinder.setGoal(new GoalNear(p.x, p.y, p.z, 1))
}
})
// MISSING CLOSING BRACKETS

UPDATED CODE:

const mineflayer ...
... bot.loadPlugin(pathfinder)

bot.once('spawn', () => {
...................................
..................................
.............bot.pathfinder.setGoal(new GoalNear(p.x, p.y, p.z, 1))
}
})
}) // ADDED CLOSING BRACKETS

ACTUAL UPDATED CODE:

const mineflayer = require('mineflayer')
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
const bot = mineflayer.createBot({ username: 'Player' })

bot.loadPlugin(pathfinder)

bot.once('spawn', () => {

  const mcData = require('minecraft-data')(bot.version)

  const defaultMove = new Movements(bot, mcData)
  
  bot.on('chat', function (username, message) {
  
    if (username === bot.username) return

    const target = bot.players[username] ? bot.players[username].entity : null
    if (message === 'come') {
      if (!target) {
        bot.chat('I don\'t see you !')
        return
      }
      const p = target.position

      bot.pathfinder.setMovements(defaultMove)
      bot.pathfinder.setGoal(new GoalNear(p.x, p.y, p.z, 1))
    }
  })
})
@EswarBalasubramanian
Copy link
Contributor Author

#146 Solved unexpected end of input error in example code in README.txt. Thanks for merging my pull request.

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