Class ClientNetworkRegistry
java.lang.Object
net.neoforged.neoforge.network.registration.NetworkRegistry
net.neoforged.neoforge.client.network.registration.ClientNetworkRegistry
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private static boolean
Fields inherited from class net.neoforged.neoforge.network.registration.NetworkRegistry
BUILTIN_PAYLOADS, CLIENTBOUND_HANDLERS, PAYLOAD_REGISTRATIONS, SERVERBOUND_HANDLERS, setup, SUPPORTED_COMMON_NETWORKING_VERSIONS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
Used in place ofThread.dumpStack()
as that logs toSystem.err
.static void
handleModdedPayload
(ClientCommonPacketListener listener, ClientboundCustomPayloadPacket packet) Handles modded payloads on the client.static void
Invoked by the client to indicate that it detect a connection to a modded server, by receiving aModdedNetworkPayload
.static void
Invoked by the client when noModdedNetworkQueryPayload
has been received, but instead aBrandPayload
has been received as the first packet during negotiation in the configuration phase.static void
Invoked by the client when a modded server queries it for its available channels.static <T extends CustomPacketPayload>
voidregister
(CustomPacketPayload.Type<T> type, HandlerThread thread, IPayloadHandler<T> handler) static void
setup()
Sets up the client network registry by firingRegisterClientPayloadHandlersEvent
, updating the payload registrations for clientbound payloads inNetworkRegistry.PAYLOAD_REGISTRATIONS
.Methods inherited from class net.neoforged.neoforge.network.registration.NetworkRegistry
checkCommonVersion, checkPacket, checkPacket, configureMockConnection, filterGameBundlePackets, getCodec, getCommonPlayChannels, getConnectionType, getInitialListeningChannels, getInitialServerUnregisterChannels, guard, handleModdedPayload, handlePacketUnchecked, hasAdhocChannel, hasChannel, hasChannel, initializeNeoForgeConnection, initializeOtherConnection, isModdedPayload, onCommonRegister, onConfigurationFinished, onMinecraftRegister, onMinecraftUnregister, register, registerHandler
-
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 firingRegisterClientPayloadHandlersEvent
, updating the payload registrations for clientbound payloads inNetworkRegistry.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
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 aModdedNetworkPayload
. 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
Invoked by the client when noModdedNetworkQueryPayload
has been received, but instead aBrandPayload
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 ofThread.dumpStack()
as that logs toSystem.err
.
-