Interface PayloadTypeRegistry<B extends net.minecraft.network.FriendlyByteBuf>

All Known Implementing Classes:
PayloadTypeRegistryImpl

@NonExtendable public interface PayloadTypeRegistry<B extends net.minecraft.network.FriendlyByteBuf>
A registry for payload types.
  • Method Summary

    Modifier and Type
    Method
    Description
    static PayloadTypeRegistry<net.minecraft.network.FriendlyByteBuf>
     
    static PayloadTypeRegistry<net.minecraft.network.RegistryFriendlyByteBuf>
     
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T>
    register(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec)
    Registers a custom payload type.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T>
    registerLarge(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec, int maxPacketSize)
    Registers a large custom payload type.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T>
    registerLarge(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec, IntSupplier maxPacketSizeSupplier)
    Registers a large custom payload type.
    static PayloadTypeRegistry<net.minecraft.network.FriendlyByteBuf>
     
    static PayloadTypeRegistry<net.minecraft.network.RegistryFriendlyByteBuf>
     
  • Method Details

    • register

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T> register(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec)
      Registers a custom payload type.

      This must be done on both the sending and receiving side, usually during mod initialization and before registering a packet handler.

      Type Parameters:
      T - the payload class
      Parameters:
      type - the payload type
      codec - the codec for the payload type
      Returns:
      the registered payload type
    • registerLarge

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T> registerLarge(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec, int maxPacketSize)
      Registers a large custom payload type.

      This must be done on both the sending and receiving side, usually during mod initialization and before registering a packet handler.

      Payload types registered with this method will be split into multiple packets, allowing to send packets larger than the vanilla limited size.

      Type Parameters:
      T - the payload class
      Parameters:
      type - the payload type
      codec - the codec for the payload type
      maxPacketSize - the maximum size of payload packet
      Returns:
      the registered payload type
    • registerLarge

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<? super B, T> registerLarge(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type, net.minecraft.network.codec.StreamCodec<? super B, T> codec, IntSupplier maxPacketSizeSupplier)
      Registers a large custom payload type.

      This must be done on both the sending and receiving side, usually during mod initialization and before registering a packet handler.

      Payload types registered with this method will be split into multiple packets, allowing to send packets larger than the vanilla limited size.

      The maxPacketSizeSupplier will be called once, right before the first packet of this payload type is sent/received on either side. This allows mods some leeway particularly during mod initialization to dynamically determine a suitable max size.

      Type Parameters:
      T - the payload type
      Parameters:
      type - the payload type
      codec - the codec for the payload type
      maxPacketSizeSupplier - the function that returns the max size of payload packet
      Returns:
      the registered payload type
    • serverboundConfiguration

      static PayloadTypeRegistry<net.minecraft.network.FriendlyByteBuf> serverboundConfiguration()
      Returns:
      the PayloadTypeRegistry instance for the serverbound (client to server) configuration channel.
    • clientboundConfiguration

      static PayloadTypeRegistry<net.minecraft.network.FriendlyByteBuf> clientboundConfiguration()
      Returns:
      the PayloadTypeRegistry instance for the clientbound (server to client) configuration channel.
    • serverboundPlay

      static PayloadTypeRegistry<net.minecraft.network.RegistryFriendlyByteBuf> serverboundPlay()
      Returns:
      the PayloadTypeRegistry instance for the serverbound (client to server) play channel.
    • clientboundPlay

      static PayloadTypeRegistry<net.minecraft.network.RegistryFriendlyByteBuf> clientboundPlay()
      Returns:
      the PayloadTypeRegistry instance for the clientbound (server to client) play channel.