PrismarineJS / bedrock-protocol

Minecraft Bedrock protocol library, with authentication and encryption
https://prismarinejs.github.io/minecraft-data/?v=bedrock_1.17.10&d=protocol
MIT License
311 stars 71 forks source link

Sending commands #355

Closed JanCantCode closed 1 year ago

JanCantCode commented 1 year ago

I am attempting to send commands with the bedrock protocol. According to wiki.vg, sending commands is not done through the text packet, but the command_request packet. I have tried sending it by using code similar to client.queue("command_request", {"command":"test", "command_type":"", "Unkown_UUID":"", "Request_Id": "", "Unkown": true}) (as obviously seen here i have little to no experience implementing arguments from wiki.vg) this tho does result in an error TypeError: SizeOf error for undefined : Cannot read properties of undefined (reading 'type') which makes me assume i have to specify a type argument in the packet, which i dont quite get as its not asked for on wiki.vg. Can anyone explain to me how to send commands in bedrock edition? Or tell me what i could potentially be doing wrong?

JanCantCode commented 1 year ago

Also i am uncertain wheter command request is actually spelled right or similar, on wiki.vg it even says that this packet is bound to server which makes me even more confused.

AnyBananaGAME commented 1 year ago

You can use a text packet to do it

 client.queue('text', {
            type: 'chat',
            needs_translation: false,
            source_name: client.username,
            xuid: '',
            platform_chat_id: '',
            message: `/help`
        })
AnyBananaGAME commented 1 year ago

for the command request it's

    client.queue('command_request', {
      command: "/help",
      origin: {
        type: 'player',
        uuid: '',
        request_id: '',
      },
      internal: false,
            version: 52,
    })
JanCantCode commented 1 year ago

i have attempted that already, it just sends the command as a message into chat

for the command request it's

    client.queue('command_request', {
      command,
      origin: {
        type: 'player',
        uuid: '',
        request_id: '',
      },
      internal: false,
            version: 52,
    })
JanCantCode commented 1 year ago

for the command request it's

    client.queue('command_request', {
      command,
      origin: {
        type: 'player',
        uuid: '',
        request_id: '',
      },
      internal: false,
            version: 52,
    })

oh thanks ill try that

JanCantCode commented 1 year ago

yay it works! thank you!

AnyBananaGAME commented 1 year ago

i have attempted that already, it just sends the command as a message into chat

for the command request it's

    client.queue('command_request', {
      command,
      origin: {
        type: 'player',
        uuid: '',
        request_id: '',
      },
      internal: false,
            version: 52,
    })

If you use a text packet and dont use type: "chat", it'll send you a text message only you can see