Class PacketRegistrationHandler
java.lang.Object
commonnetwork.networking.PacketRegistrationHandler
- All Implemented Interfaces:
NetworkHandler, PacketRegistrar
public abstract class PacketRegistrationHandler
extends Object
implements NetworkHandler, PacketRegistrar
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable PacketContainer<?> getPacketContainer(net.minecraft.resources.Identifier id) <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
@Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacketgetRawClientboundPacket(T packet) Generates a ClientboundCustomPayloadPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
@Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacketgetRawServerboundPacket(T packet) Generates a ServerboundCustomPayloadPacketgetSide()protected abstract <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidonRegister(PacketContainer<T> container) Loader-specific wiring for a freshly-registered packet.<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
PacketRegistrarregisterConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registration, registers a CONFIGURATION packet<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
PacketRegistrarregisterPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Packet Registration, registers a PLAY packetprotected <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
PacketContainer<T> requireContainer(T packet) Looks up the registeredPacketContainerfor the given packet, throwing if it is not registered.protected booleanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NetworkHandler
send, sendToAllClients, sendToAllClients, sendToClient, sendToClient, sendToClients, sendToClients, sendToClientsInLevel, sendToClientsInLevel, sendToClientsInRange, sendToClientsInRange, sendToClientsLoadingChunk, sendToClientsLoadingChunk, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToServer, sendToServer
-
Field Details
-
side
-
-
Constructor Details
-
PacketRegistrationHandler
-
-
Method Details
-
registerPacket
public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> PacketRegistrar registerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Description copied from interface:PacketRegistrarPacket Registration, registers a PLAY packet- Specified by:
registerPacketin interfacePacketRegistrar- Type Parameters:
T- - The packet type- Parameters:
type- - The packet type.codec- - The StreamCodec.handler- - The handler method.- Returns:
- The registrar for chaining registrations.
-
registerConfigurationPacket
public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> PacketRegistrar registerConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf, T> codec, Consumer<PacketContext<T>> handler) Description copied from interface:PacketRegistrarPacket Registration, registers a CONFIGURATION packet- Specified by:
registerConfigurationPacketin interfacePacketRegistrar- Type Parameters:
T- - The packet type- Parameters:
type- - The packet type.codec- - The StreamCodec.handler- - The handler method.- Returns:
- The registrar for chaining registrations.
-
supports
-
getPacketContainer
@Nullable protected @Nullable PacketContainer<?> getPacketContainer(net.minecraft.resources.Identifier id) -
getSide
- Specified by:
getSidein interfacePacketRegistrar- Returns:
- the side
-
getRawClientboundPacket
@Nullable public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket getRawClientboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ClientboundCustomPayloadPacket- Specified by:
getRawClientboundPacketin interfaceNetworkHandler- Type Parameters:
T- - The packet type- Parameters:
packet- - the packet- Returns:
- The packet wrapped into a ClientboundCustomPayloadPacket
-
getRawServerboundPacket
@Nullable public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket getRawServerboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ServerboundCustomPayloadPacket- Specified by:
getRawServerboundPacketin interfaceNetworkHandler- Type Parameters:
T- - The packet type- Parameters:
packet- - the packet- Returns:
- The packet wrapped into a ServerboundCustomPayloadPacket
-
requireContainer
protected <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> PacketContainer<T> requireContainer(T packet) Looks up the registeredPacketContainerfor the given packet, throwing if it is not registered. -
onRegister
protected abstract <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void onRegister(PacketContainer<T> container) Loader-specific wiring for a freshly-registered packet. May be a no-op if the loader defers registration to its own lifecycle event.
-