Changes

1,547 bytes added ,  12:41, 25 October 2020
Inital Import dokuwiki
Once a packet has been added to the network, it can be called to send a message to the side it refers to. Usually there are four different directions a packet can be sent:

{| class="wikitable sortable" border=1
!Direction !!Description
|-
| <code>PLAY_TO_CLIENT</code> || A packet is sent from the server to the client during gameplay.
|-
| <code>PLAY_TO_SERVER</code> || A packet is sent from the client to the server during gameplay.
|-
| <code>LOGIN_TO_CLIENT</code> || A packet is sent to the client on initial login.
|-
| <code>LOGIN_TO_SERVER</code> || A packet is sent to the server on initial login.
|-
|}

The two login packets are handled internally by forge itself. However, the other two need to be sent using <code>SimpleChannel#send</code> for <code>SimpleChannel#sendToServer</code>. Each method takes a new instance of the message to send.

== Client Packet Locations ==

It might not always be necessary to update every single client with a packet if they are not viewing the entity or are not affected by it. To specify which clients to send a packet from the server to, a <code>PacketDistributor$PacketTarget</code> must also be passed in as a parameter. There are many helpful fields that hold simple implementations of where to send which packet within <code>PacketDistributor</code>. However, they must be supplied with the required input either via <code>PacketDistributor#with</code> or <code>PacketDistributor#noArg</code> if it is going to all players.

Here is a list of distributors available: