Class PayloadTypeRegistryImpl<B extends net.minecraft.network.FriendlyByteBuf>

java.lang.Object
net.fabricmc.fabric.impl.networking.PayloadTypeRegistryImpl<B>
All Implemented Interfaces:
PayloadTypeRegistry<B>

public class PayloadTypeRegistryImpl<B extends net.minecraft.network.FriendlyByteBuf> extends Object implements PayloadTypeRegistry<B>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PayloadTypeRegistryImpl<net.minecraft.network.FriendlyByteBuf>
     
    static final PayloadTypeRegistryImpl<net.minecraft.network.RegistryFriendlyByteBuf>
     
    static final PayloadTypeRegistryImpl<net.minecraft.network.FriendlyByteBuf>
     
    static final PayloadTypeRegistryImpl<net.minecraft.network.RegistryFriendlyByteBuf>
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    @Nullable net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B,T>
    get(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type)
     
    static @Nullable PayloadTypeRegistryImpl<?>
    get(net.minecraft.network.ProtocolInfo<?> state)
     
    @Nullable net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B, ? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    get(net.minecraft.resources.Identifier id)
     
    net.minecraft.network.protocol.PacketFlow
     
    int
    getMaxPacketSizeForSplitting(net.minecraft.resources.Identifier id)
     
    net.minecraft.network.ConnectionProtocol
     
    <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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SERVERBOUND_CONFIGURATION

      public static final PayloadTypeRegistryImpl<net.minecraft.network.FriendlyByteBuf> SERVERBOUND_CONFIGURATION
    • CLIENTBOUND_CONFIGURATION

      public static final PayloadTypeRegistryImpl<net.minecraft.network.FriendlyByteBuf> CLIENTBOUND_CONFIGURATION
    • SERVERBOUND_PLAY

      public static final PayloadTypeRegistryImpl<net.minecraft.network.RegistryFriendlyByteBuf> SERVERBOUND_PLAY
    • CLIENTBOUND_PLAY

      public static final PayloadTypeRegistryImpl<net.minecraft.network.RegistryFriendlyByteBuf> CLIENTBOUND_PLAY
  • Method Details

    • get

      public static @Nullable PayloadTypeRegistryImpl<?> get(net.minecraft.network.ProtocolInfo<?> state)
    • register

      public <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)
      Description copied from interface: PayloadTypeRegistry
      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.

      Specified by:
      register in interface PayloadTypeRegistry<B extends net.minecraft.network.FriendlyByteBuf>
      Type Parameters:
      T - the payload class
      Parameters:
      type - the payload type
      codec - the codec for the payload type
      Returns:
      the registered payload type
    • registerLarge

      public <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)
      Description copied from interface: PayloadTypeRegistry
      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.

      Specified by:
      registerLarge in interface PayloadTypeRegistry<B extends net.minecraft.network.FriendlyByteBuf>
      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

      public <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)
      Description copied from interface: PayloadTypeRegistry
      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.

      Specified by:
      registerLarge in interface PayloadTypeRegistry<B extends net.minecraft.network.FriendlyByteBuf>
      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
    • get

      public @Nullable net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B, ? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> get(net.minecraft.resources.Identifier id)
    • get

      public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B,T> get(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type)
    • getMaxPacketSizeForSplitting

      public int getMaxPacketSizeForSplitting(net.minecraft.resources.Identifier id)
      Returns:
      the max packet size, or -1 if the payload type does not need splitting.
    • getProtocol

      public net.minecraft.network.ConnectionProtocol getProtocol()
    • getFlow

      public net.minecraft.network.protocol.PacketFlow getFlow()