Changes

1,508 bytes added ,  16:11, 27 May 2023
Move distributor list into a table
Line 16: Line 16:  
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.
 
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 ==
+
==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.
+
* 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:
+
Here is a list of Forge provided <code>PacketDistributor</code>s:
 +
 
 +
{| class="wikitable sortable" border=1
 +
!<code>PacketDistributor</code> !!Supplied Value !!Description
 +
|-
 +
|  <code>PLAYER</code>                    || <code>ServerPlayer</code>      || Send to the specified player .
 +
|-
 +
|  <code>DIMENSION</code>                  || <code>ResourceKey<Level></code> || Send to all players within the specified dimension.
 +
|-
 +
|  <code>NEAR</code>                      || <code>TargetPoint</code>        || Send to all players within the range of the target point.
 +
|-
 +
|  <code>ALL</code>                        || None                            || Send to all currently logged in players.
 +
|-
 +
|  <code>SERVER</code>                    || None                            || Send from the player client to the server. This is the only distributor that should be used for client -> server communication.
 +
|-
 +
|  <code>TRACKING_ENTITY</code>            || <code>Entity</code>            || Send to all players currently tracking the specified entity.
 +
|-
 +
|  <code>TRACKING_ENTITY_AND_SELF</code>  || <code>Entity</code>            || Send to all players currently tracking the specified entity and the entity itself, if it is a player.
 +
|-
 +
|  <code>TRACKING_CHUNK</code>            || <code>LevelChunk</code>        || Send to all players tracking the specified chunk.
 +
|-
 +
|  <code>NMLIST</code>                    || <code>List<Connection></code>  || Send to the listed connections. Each connection is typically an individual player.
 +
|-
 +
|}