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

How to perform a "sleep" action? #161

Closed
laikee99 opened this issue Dec 8, 2021 · 3 comments
Closed

How to perform a "sleep" action? #161

laikee99 opened this issue Dec 8, 2021 · 3 comments

Comments

@laikee99
Copy link

laikee99 commented Dec 8, 2021

Hi, I've checked mineflayer, it's has a method bot.sleep using activateBlock to perform sleep action. But how to achieve this in bedrock?
I've check there is a datatype called Action which indicates that 5 is the action of sleeping, But when I used client.queue('player_action', {action: 5, runtime_entity_id: client.uuid, position:0, face: 0}) it goes wrong:

/mc/node_modules/protodef/src/compiler.js:99
        throw e
        ^

TypeError: SizeOf error for undefined : Cannot read properties of undefined (reading 'valueOf')
    at Object.sizeOfVarLong [as varint64] (/mc/node_modules/bedrock-protocol/src/datatypes/varlong.js:2:20)
    at Object.packet_player_action (eval at compile (/mc/node_modules/protodef/src/compiler.js:258:12), <anonymous>:2466:29)
    at eval (eval at compile (/mc/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1686:66)
    at mcpe_packet (eval at compile (/mc/node_modules/protodef/src/compiler.js:258:12), <anonymous>:1822:9)
    at CompiledProtodef.sizeOf (/mc/node_modules/protodef/src/compiler.js:89:14)
    at e.message (/mc/node_modules/protodef/src/compiler.js:96:40)
    at tryCatch (/mc/node_modules/protodef/src/utils.js:50:16)
    at CompiledProtodef.createPacketBuffer (/mc/node_modules/protodef/src/compiler.js:96:20)
    at Serializer.createPacketBuffer (/mc/node_modules/protodef/src/serializer.js:12:23)
    at Client.queue (/mc/node_modules/bedrock-protocol/src/connection.js:77:36)

If you could help me to solve this problem I will be appreciate. :)

@laikee99 laikee99 changed the title How to perform a "sleeping" action? How to perform a "sleep" action? Dec 8, 2021
@laikee99
Copy link
Author

laikee99 commented Dec 8, 2021

After change the code, it's working now, but the bot is not actual "sleeping" but sent the requests asking other players to sleep.
Is it a bug ?

@laikee99
Copy link
Author

laikee99 commented Dec 8, 2021

image

@extremeheat
Copy link
Member

please see https://github.com/PrismarineJS/bedrock-protocol/wiki/Using-bedrock-protocol, this is a protocol library and connects as a normal client does. Sending the correct packets to do the action you want is up to you, you can use the proxy example to see how something is done vanilla and then replicate it.

mineflayer for high level support is tracked in #116

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

2 participants