Class ClientNetworkRegistry

java.lang.Object
net.neoforged.neoforge.network.registration.NetworkRegistry
net.neoforged.neoforge.client.network.registration.ClientNetworkRegistry

@Internal public final class ClientNetworkRegistry extends NetworkRegistry
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • setupClient

      private static boolean setupClient
  • Constructor Details

    • ClientNetworkRegistry

      private ClientNetworkRegistry()
  • Method Details

    • setup

      public static void setup()
      Sets up the client network registry by firing RegisterClientPayloadHandlersEvent, updating the payload registrations for clientbound payloads in NetworkRegistry.PAYLOAD_REGISTRATIONS.
    • register

      public static <T extends CustomPacketPayload> void register(CustomPacketPayload.Type<T> type, HandlerThread thread, IPayloadHandler<T> handler)
    • handleModdedPayload

      public static void handleModdedPayload(ClientCommonPacketListener listener, ClientboundCustomPayloadPacket packet)
      Handles modded payloads on the client. Invoked after built-in handling.

      Called on the network thread.

      Parameters:
      listener - The listener which received the packet.
      packet - The packet that was received.
    • onNetworkQuery

      public static void onNetworkQuery(ClientConfigurationPacketListener listener)
      Invoked by the client when a modded server queries it for its available channels. The negotiation happens solely on the server side, and the result is later transmitted to the client.

      Invoked on the network thread.

      Parameters:
      listener - The listener which received the query.
    • initializeNeoForgeConnection

      public static void initializeNeoForgeConnection(ClientConfigurationPacketListener listener, NetworkPayloadSetup setup)
      Invoked by the client to indicate that it detect a connection to a modded server, by receiving a ModdedNetworkPayload. This will configure the active connection to the server to use the channels that were negotiated.

      Once this method completes a NetworkPayloadSetup will be present on the connection.

      Invoked on the network thread.

      Parameters:
      listener - The listener which received the payload.
      setup - The network channels that were negotiated.
    • initializeOtherConnection

      public static void initializeOtherConnection(ClientConfigurationPacketListener listener)
      Invoked by the client when no ModdedNetworkQueryPayload has been received, but instead a BrandPayload has been received as the first packet during negotiation in the configuration phase.

      If this happens then the client will do a negotiation of its own internal channel configuration, to check if any mods are installed that require a modded connection to the server. If those are found then the connection is aborted and the client disconnects from the server.

      This method should never be invoked on a connection where the server is ConnectionType.NEOFORGE.

      Invoked on the network thread.

      Parameters:
      listener - The listener which received the brand payload.
    • dumpStackToLog

      private static void dumpStackToLog()
      Used in place of Thread.dumpStack() as that logs to System.err.