Class ModdedPacketRegistrar
- All Implemented Interfaces:
IPayloadRegistrar
IPayloadRegistrar
for modded packets.-
Field Summary
Modifier and TypeFieldDescriptionprivate final Map<ResourceLocation,
ConfigurationRegistration<?>> private final String
private boolean
private final Map<ResourceLocation,
PlayRegistration<?>> private boolean
-
Constructor Summary
-
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 void
configuration
(ResourceLocation id, ConfigurationRegistration<?> registration) void
optional()
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 void
play
(ResourceLocation id, PlayRegistration<?> registration) private void
validatePayload
(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, wait
Methods 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:IPayloadRegistrar
Registers a new payload type for the play phase.- Specified by:
play
in 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:IPayloadRegistrar
Registers a new payload type for the configuration phase.- Specified by:
configuration
in 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:IPayloadRegistrar
Registers 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:
play
in 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:IPayloadRegistrar
Registers 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:
configuration
in 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:IPayloadRegistrar
Registers 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:
common
in 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:IPayloadRegistrar
Defines 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:
versioned
in interfaceIPayloadRegistrar
- Parameters:
version
- The version to use.- Returns:
- A new registrar, ready to configure payloads with that version.
-
optional
Description copied from interface:IPayloadRegistrar
Defines 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:
optional
in interfaceIPayloadRegistrar
- Returns:
- A new registrar, ready to configure payloads as optional.
-
invalidate
public void invalidate()
-