You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/networking/README.md
+41-11Lines changed: 41 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,22 +17,39 @@ are also fired for connections to integrated servers.
17
17
## Networking
18
18
19
19
Sending and receiving data is done through the `ClientPlayNetworking` and `ServerPlayNetworking` classes.
20
-
Mods can register network listeners through the `registerListener` and `registerListenerAsync` methods,
21
-
allowing them to receive data through specific channels. Sending data is done through the `send` methods.
20
+
Mods can register packet listeners through the `registerListener` methods, and send data through the `send` methods.
22
21
23
-
Each custom payload is tied to a channel. Only connections that have listeners on that channel will receive the payload, and on the receiving end, the payload will only be handled by the listener on that channel. In Minecraft versions 1.13-pre2 and below, a channel can be any `String` of length 20 or less. In Minecraft versions 1.13-pre4 and above, a channel can be any valid `Identifier`. For `String` channels, the convention is `<(abbreviated) mod id>|<payload id>` (e.g. `Example|Cookie`), while for `Identifier` channels, the convention is `<mod id>:<payload id>` (e.g. `example:cookie`).
22
+
Custom payloads are sent over specific channels. Channels are namespaced identifiers, used to identify the payload being sent or received.
23
+
Channels identifiers should be constructed through the `ChannelIdentifieres` class. The convention is to use your mod id as the namespace,
24
+
and snake case for the identifier.
24
25
25
-
For ease of use data can be wrapped in custom payload objects. These must implement the `CustomPayload` interface
26
-
and must have a public construcor without parameters. An example can be seen below.
0 commit comments