Class ModdedPacketRegistrar
- All Implemented Interfaces:
IPayloadRegistrar
IPayloadRegistrar for modded packets.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<ResourceLocation,ConfigurationRegistration<?>> private final Stringprivate booleanprivate final Map<ResourceLocation,PlayRegistration<?>> private boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends CustomPacketPayload>
IPayloadRegistrarcommon(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IPayloadHandler<T>>> handler) Registers a new payload type for all supported phases.<T extends CustomPacketPayload>
IPayloadRegistrarconfiguration(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IConfigurationPayloadHandler<T>>> handler) Registers a new payload type for the configuration phase.<T extends CustomPacketPayload>
IPayloadRegistrarconfiguration(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, IConfigurationPayloadHandler<T> handler) Registers a new payload type for the configuration phase.private voidconfiguration(ResourceLocation id, ConfigurationRegistration<?> registration) voidoptional()Defines that the payloads registered by this registrar are optional.<T extends CustomPacketPayload>
IPayloadRegistrarplay(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IPlayPayloadHandler<T>>> handler) Registers a new payload type for the play phase.<T extends CustomPacketPayload>
IPayloadRegistrarplay(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, IPlayPayloadHandler<T> handler) Registers a new payload type for the play phase.private voidplay(ResourceLocation id, PlayRegistration<?> registration) private voidvalidatePayload(ResourceLocation id, Map<ResourceLocation, ?> payloads) Defines that the payloads registered by this registrar have a specific version associated with them.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.network.registration.IPayloadRegistrar
common
-
Field Details
-
modId
-
configurationPayloads
-
playPayloads
-
version
-
optional
private boolean optional -
valid
private boolean valid
-
-
Constructor Details
-
ModdedPacketRegistrar
-
ModdedPacketRegistrar
-
-
Method Details
-
getConfigurationRegistrations
-
getPlayRegistrations
-
play
public <T extends CustomPacketPayload> IPayloadRegistrar play(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, IPlayPayloadHandler<T> handler) Description copied from interface:IPayloadRegistrarRegisters a new payload type for the play phase.- Specified by:
playin interfaceIPayloadRegistrar- Type Parameters:
T- The type of the payload.- Parameters:
id- The id of the payload.reader- The reader for the payload.handler- The handler for the payload.- Returns:
- The registrar.
-
configuration
public <T extends CustomPacketPayload> IPayloadRegistrar configuration(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, IConfigurationPayloadHandler<T> handler) Description copied from interface:IPayloadRegistrarRegisters a new payload type for the configuration phase.- Specified by:
configurationin interfaceIPayloadRegistrar- Type Parameters:
T- The type of the payload.- Parameters:
id- The id of the payload.reader- The reader for the payload.handler- The handler for the payload.- Returns:
- The registrar.
-
play
public <T extends CustomPacketPayload> IPayloadRegistrar play(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IPlayPayloadHandler<T>>> handler) Description copied from interface:IPayloadRegistrarRegisters a new payload type for the play phase.This method allows different handlers to be registered for different packet-flows.
In practice this means that you can register a different handler for clientbound and serverbound packets, which allows you to handle them differently on the client and server side.- Specified by:
playin interfaceIPayloadRegistrar- Type Parameters:
T- The type of the payload.- Parameters:
id- The id of the payload.reader- The reader for the payload.handler- The handler for the payload.- Returns:
- The registrar.
-
configuration
public <T extends CustomPacketPayload> IPayloadRegistrar configuration(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IConfigurationPayloadHandler<T>>> handler) Description copied from interface:IPayloadRegistrarRegisters a new payload type for the configuration phase.This method allows different handlers to be registered for different packet-flows.
In practice this means that you can register a different handler for clientbound and serverbound packets, which allows you to handle them differently on the client and server side.- Specified by:
configurationin interfaceIPayloadRegistrar- Type Parameters:
T- The type of the payload.- Parameters:
id- The id of the payload.reader- The reader for the payload.handler- The handler for the payload.- Returns:
- The registrar.
-
common
public <T extends CustomPacketPayload> IPayloadRegistrar common(ResourceLocation id, FriendlyByteBuf.Reader<T> reader, Consumer<IDirectionAwarePayloadHandlerBuilder<T, IPayloadHandler<T>>> handler) Description copied from interface:IPayloadRegistrarRegisters a new payload type for all supported phases.This method allows different handlers to be registered for different packet-flows.
In practice this means that you can register a different handler for clientbound and serverbound packets, which allows you to handle them differently on the client and server side.- Specified by:
commonin interfaceIPayloadRegistrar- Type Parameters:
T- The type of the payload.- Parameters:
id- The id of the payload.reader- The reader for the payload.handler- The handler for the payload.- Returns:
- The registrar.
-
configuration
-
play
-
validatePayload
-
versioned
Description copied from interface:IPayloadRegistrarDefines that the payloads registered by this registrar have a specific version associated with them. Clients connecting to a server with these payloads, will only be able to connect if they have the same version.- Specified by:
versionedin interfaceIPayloadRegistrar- Parameters:
version- The version to use.- Returns:
- A new registrar, ready to configure payloads with that version.
-
optional
Description copied from interface:IPayloadRegistrarDefines that the payloads registered by this registrar are optional. Clients connecting to a server which do not have the payloads registered, will still be able to connect.If clients have also a version set, and a version mismatch occurs (so both client and server have the payloads registered, yet have different versions), the connection attempt will fail. In other words, marking a payload as optional does not exempt it from versioning, if it has that configured.
- Specified by:
optionalin interfaceIPayloadRegistrar- Returns:
- A new registrar, ready to configure payloads as optional.
-
invalidate
public void invalidate()
-