Class RegisterPayloadHandlersEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent
All Implemented Interfaces:
net.neoforged.fml.event.IModBusEvent

public class RegisterPayloadHandlersEvent extends net.neoforged.bus.api.Event implements net.neoforged.fml.event.IModBusEvent
Event fired when the NetworkRegistry is being set up.

This event is used to collect all the payload types and their handlers that should be used on the network.

There are a few base rules for custom payloads:

  • Payloads should not write their ids within their StreamCodec, as this will be done automatically.
  • Payloads must be registered before they can be sent over the network.
  • Payloads may only be sent over the ConnectionProtocol they were registered for.
  • By default, PayloadRegistrar will wrap handlers so they execute on the main thread instead of the network thread.
  • Payloads are always serialized, including for memory connections (singleplayer and LAN hosts).
    • Constructor Details

      • RegisterPayloadHandlersEvent

        @Internal public RegisterPayloadHandlersEvent()
    • Method Details

      • registrar

        public PayloadRegistrar registrar(String version)
        Creates a new PayloadRegistrar, a utility for registering payloads using a builder-style format.
        Parameters:
        version - The network version. May not be empty