node-minecraft-protocol icon indicating copy to clipboard operation
node-minecraft-protocol copied to clipboard

Handle official (MC| - prefixed) Custom Payload packets

Open roblabla opened this issue 10 years ago • 8 comments

Minecraft defines a couple of packets through the Custom Payload mechanism. Currently, node-mc-proto decodes every custom payload as a simple byte array, and API users are left to decode those themselves. This issues proposes two things

  1. Add a new mechanism for API users to write their own custom payload decoder.
  2. Add a custom payload decoder for all the official channels.

We might want to support and manage the "Register/Unregister" channel automagically for this.

In 1.8, the official channels (Ignoring the custom channel management ones) are :

MC|AdvCdm

Name Type Description
Mode Byte
X Int If Mode == 0
Y Int If Mode == 0
Z Int If Mode == 0
EntityID Int If Mode == 1
Command String
### `MC Beacon`
Name Type Description
Effect1 Int
Effect2 Int
### `MC BEdit`
Name Type Description
Book Slot?
### `MC BSign`
Name Type Description
Book Slot ?
### `MC BOpen`
Name Type Description
### `MC ItemName`
Name Type Description
ItemName String
### `MC RPack`

(Deprecated, use Resource Pack Send (Play, 0x48, clientbound) and Resource Pack Status (Play, 0x19, serverbound) packets)

Name Type Description
URL String
### `MC TrList`
Name Type Description
???
### `MC TrSel`
Name Type Description
Slot ID Int The selected slot id of the trading inventory
### `MC PingHost`

(Deprecated in 1.7)

Name Type Description
???
### `MC Brand`
Name Type Description
Implementation String

roblabla avatar Apr 05 '15 05:04 roblabla

See https://github.com/SpockBotMC/SpockBot/pull/172/files on that topic

rom1504 avatar Oct 05 '15 12:10 rom1504

This is needed to support command block updating. An example of updating is:

client->server: play custom_payload : 
{"channel":"MC|AdvCdm","data":{"type":"Buffer","data":[0,0,0,0,0,0,0,0,71,255,255,255,189,17,47,116,112,32,114,111,109,49,53,48,52,32,48,32,48,32,48,1]}}

rom1504 avatar Jan 17 '16 20:01 rom1504

https://gist.github.com/rom1504/742a400592260329bcb1 : started to work on it

rom1504 avatar Jan 17 '16 21:01 rom1504

http://wiki.vg/Plugin_channel is more up to date

rom1504 avatar Jan 17 '16 21:01 rom1504

Some of that currently put in mineflayer, https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/command_block.js, it will move here when ready I think.

rom1504 avatar Jan 17 '16 22:01 rom1504

and/or to https://github.com/PrismarineJS/minecraft-data right? (protocol definition)

Plugin channels would also be useful for https://github.com/PrismarineJS/node-minecraft-protocol/issues/114 Forge Support - FML/Forge has several of its own used during handshaking

deathcap avatar Jan 23 '16 20:01 deathcap

yeah and minecraft-data

rom1504 avatar Jan 23 '16 21:01 rom1504

https://github.com/PrismarineJS/node-minecraft-protocol/pull/423 brings parsing of channel to the client and server with registration/unregistration. Missing for this issue:

  • [x] the serialization/writing side : a client.writeChannel (example implementation client.write("custom_payload",{channel:channel,data:proto.createPacketBuffer(channel,packet)}); )
  • [ ] enabling vanilla channels : require adding the corresponding data in minecraft-data
  • [ ] using this in various projects (mineflayer, node-minecraft-protocol-forge at least)

edit : checking things in https://github.com/rom1504/node-minecraft-protocol/commit/a0717a1232f83799bd87fb7e918392cb175183d4

rom1504 avatar Aug 10 '16 15:08 rom1504