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

Modifying outgoing packets without changing node_modules? #233

Open
slonkazoid opened this issue Sep 7, 2022 · 8 comments
Open

Modifying outgoing packets without changing node_modules? #233

slonkazoid opened this issue Sep 7, 2022 · 8 comments

Comments

@slonkazoid
Copy link

I'm writing a bot and I need to modify every position packet (0x14 and 0x15 to be precise) but every way I found requires me to change code in node_modules (hell) and they all work half arsed and straight up don't with control state. Thank you in advance.

@rom1504
Copy link
Member

rom1504 commented Sep 7, 2022 via email

@slonkazoid
Copy link
Author

slonkazoid commented Sep 7, 2022

No, I just want to edit the X and Z of the position packets I'm sending.
Kinda like a mixin.

@rom1504
Copy link
Member

rom1504 commented Sep 7, 2022

Do you want to edit the type or the value ?

For the type you can use node-minecraft-protocol custom packets
For the value you can use a node-minecraft-protocol proxy, client or server depending on your use case

@slonkazoid
Copy link
Author

the value, I'm running a bot

Is the proxy only way to go in this case?

@rom1504
Copy link
Member

rom1504 commented Sep 7, 2022 via email

@slonkazoid
Copy link
Author

but bot.setControlState('...', true) will not get filtered by that. Also I'm interacting with both mineflayer and protocol.

@rom1504
Copy link
Member

rom1504 commented Sep 7, 2022

I think you should say more about what you want to do, it's not clear.
What is "filtered" ?
You dont need to hack things around, simply implement it directly the way you want it

@iCollin
Copy link

iCollin commented Jul 9, 2023

hook outgoing packets

const old_write = bot._client.write.bind(bot._client);
bot._client.write = (name, data) => {
  if (['position', 'position_look'].includes(name)) {
    data.x = /*modified value*/;
    data.z = /*modified value*/;
  }
  return old_write(name, data);
}

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

3 participants