Skip to content

get the player's position #3415

Answered by greenik228
mncrftfrcnm asked this question in Q&A
Discussion options

You must be logged in to vote
const mineflayer = require('mineflayer')
const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

function createBot () {
    const bot = mineflayer.createBot({
        username: 'YOUR_NICKNAME',
        host: 'YOUR_IP',
        port: 25565
    })
    mainFunc(bot)
}
createBot()

function mainFunc(bot) {
    bot.on('message', (jsonMsg) => {
        console.log(jsonMsg.toAnsi())
    })

    bot.on('end', () => {
        createBot()
        rl.removeAllListeners('line')
    })

    rl.on('line', (input) => {
        if (input.match(/^\$/)) {
            switch (input) {
                case '$pos':
                    

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mncrftfrcnm
Comment options

Answer selected by mncrftfrcnm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants