Record Class PacketContainer<T>

java.lang.Object
java.lang.Record
commonnetwork.networking.data.PacketContainer<T>

public record PacketContainer<T>(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> classType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler, PacketContainer.PacketType packetType) extends Record
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PacketContainer(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> classType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler, PacketContainer.PacketType packetType)
    Creates an instance of a PacketContainer record class.
    PacketContainer(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> classType, net.minecraft.network.codec.StreamCodec<? super B,T> codec, Consumer<PacketContext<T>> handle, PacketContainer.PacketType packetType)
     
    PacketContainer(net.minecraft.resources.Identifier id, Class<T> classType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handle)
    Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the classType record component.
    net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.FriendlyByteBuf,T>
    Returns the value of the codec record component.
    Function<net.minecraft.network.FriendlyByteBuf,T>
    Returns the value of the decoder record component.
    BiConsumer<T,net.minecraft.network.FriendlyByteBuf>
    Returns the value of the encoder record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    <K extends net.minecraft.network.FriendlyByteBuf>
    net.minecraft.network.codec.StreamCodec<K,CommonPacketWrapper>
     
    <K extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<K>
     
    Returns the value of the handler record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the packetType record component.
    final String
    Returns a string representation of this record class.
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    Returns the value of the type record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PacketContainer

      @Deprecated(forRemoval=true) public PacketContainer(net.minecraft.resources.Identifier id, Class<T> classType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handle)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • PacketContainer

      public PacketContainer(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> classType, net.minecraft.network.codec.StreamCodec<? super B,T> codec, Consumer<PacketContext<T>> handle, PacketContainer.PacketType packetType)
    • PacketContainer

      public PacketContainer(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> classType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler, PacketContainer.PacketType packetType)
      Creates an instance of a PacketContainer record class.
      Parameters:
      type - the value for the type record component
      classType - the value for the classType record component
      encoder - the value for the encoder record component
      decoder - the value for the decoder record component
      codec - the value for the codec record component
      handler - the value for the handler record component
      packetType - the value for the packetType record component
  • Method Details

    • getType

      public <K extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<K> getType()
    • getCodec

      public <K extends net.minecraft.network.FriendlyByteBuf> net.minecraft.network.codec.StreamCodec<K,CommonPacketWrapper> getCodec()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • classType

      public Class<T> classType()
      Returns the value of the classType record component.
      Returns:
      the value of the classType record component
    • encoder

      public BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder()
      Returns the value of the encoder record component.
      Returns:
      the value of the encoder record component
    • decoder

      public Function<net.minecraft.network.FriendlyByteBuf,T> decoder()
      Returns the value of the decoder record component.
      Returns:
      the value of the decoder record component
    • codec

      public net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.FriendlyByteBuf,T> codec()
      Returns the value of the codec record component.
      Returns:
      the value of the codec record component
    • handler

      public Consumer<PacketContext<T>> handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component
    • packetType

      public PacketContainer.PacketType packetType()
      Returns the value of the packetType record component.
      Returns:
      the value of the packetType record component