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

Cannot move #886

Closed
Zo-Bro-23 opened this issue Aug 6, 2021 · 1 comment
Closed

Cannot move #886

Zo-Bro-23 opened this issue Aug 6, 2021 · 1 comment

Comments

@Zo-Bro-23
Copy link

[ ] The FAQ doesn't contain a resolution to my issue

Versions

  • minecraft-protocol: 1.25.0
  • server: vanilla/spigot/paper 1.17.1
  • node: 14.16.1

Detailed description of a problem

I am not able to move my bot within the world. The bot is connecting to the server, and I was able to send and receive chat messages. When I try to move, however, it doesn't work.

Current code

const mc = require('minecraft-protocol')

const client = mc.createClient({
    host: '[myIP]',
    port: '62457',
    username: 'AFK_Bot1',
    version: '1.17.1'
})  

client.on('login', () => {
    // notInactive(-0.5)

    setTimeout(() => {
        console.log('sigh')
        client.write('position', {
            x: -184,
            y: 84,
            z: 134.53013736121238,
            onGround: true
        })
    }, 2000)

    // client.write('chat', {
    //     message: '/tp -182 84 134'
    // })
    // client.write('chat', {
    //     message: '/spawnpoint'
    // })
    //
    // Single use only!
})

// client.on('chat', (packet) => {
//     if (JSON.parse(packet.message).translate == 'chat.type.announcement' || JSON.parse(packet.message).translate == 'chat.type.text' || JSON.parse(packet.message).translate == undefined) {
//         console.log(JSON.parse(packet.message).extra[0].text)
//     } else {
//         console.log(JSON.parse(packet.message))
//     }
// })

// For debugging only!

function notInactive(number) {
    let position = {
        x: -181.52092902441308,
        y: 84,
        z: 134.53013736121238
    }
    position.x += number
    position.y = 84
    position.z += 0
    client.write('position', {position})
    setTimeout(notInactive, 5000, -number)
}

client.on('error', (err) => {
    console.log(err)
})

// client.on('packet', (packet) => {
//     console.log(packet)
// })

// For debugging only!

client.on('position', (position) => {
    console.log(position)
})

// For debugging only!

Expected behavior

The bot should visibly move and the logging of the current position (see line 67 or 4 when counting backwards) should update to a newer position.

Additional context

I have tried many different syntaxes including relative position, position along with yaw and pitch, and positioning with only a decimal of difference from current position. None of them seem to work. The only code that ever worked was the following:

client.write('position', {
    position: {
        x: (something)
        y: (something)
        z: (something),
        onGround: true
    }
})

This one, however, produced the following message in the server console:

AFK_Bot1 Joined the Server
AFK_Bot1 Left the Server

The weirdest part was that the NodeJS program didn't quit! And when it logged the next time, it showed the update position. The server showed only 1 player as connected though (my PC). Hope you can solve my issue!

PS: I have also posted a variation of this on StackOverFlow

@Zo-Bro-23
Copy link
Author

I fixed it, for anyone who's looking for an answer! The problem was with the 1.17.1 update in the Minecraft protocol. You need to send 'teleport_confirm' with the 'teleportId' sent with the position update in order to actually move the bot.

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