Package commonnetwork.networking.data
Record Class PacketContainer<T>
java.lang.Object
java.lang.Record
commonnetwork.networking.data.PacketContainer<T>
public record PacketContainer<T>(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handler)
extends Record
-
Constructor Summary
ConstructorsConstructorDescriptionPacketContainer(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T, net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) Creates an instance of aPacketContainerrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondecoder()Returns the value of thedecoderrecord component.BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder()Returns the value of theencoderrecord component.final booleanIndicates whether some other object is "equal to" this one.handler()Returns the value of thehandlerrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of themessageTyperecord component.net.minecraft.resources.ResourceLocationReturns the value of thepacketIdentifierrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PacketContainer
public PacketContainer(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T, net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf, T> decoder, Consumer<PacketContext<T>> handler) Creates an instance of aPacketContainerrecord class.- Parameters:
packetIdentifier- the value for thepacketIdentifierrecord componentmessageType- the value for themessageTyperecord componentencoder- the value for theencoderrecord componentdecoder- the value for thedecoderrecord componenthandler- the value for thehandlerrecord component
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
packetIdentifier
public net.minecraft.resources.ResourceLocation packetIdentifier()Returns the value of thepacketIdentifierrecord component.- Returns:
- the value of the
packetIdentifierrecord component
-
messageType
Returns the value of themessageTyperecord component.- Returns:
- the value of the
messageTyperecord component
-
encoder
Returns the value of theencoderrecord component.- Returns:
- the value of the
encoderrecord component
-
decoder
Returns the value of thedecoderrecord component.- Returns:
- the value of the
decoderrecord component
-
handler
Returns the value of thehandlerrecord component.- Returns:
- the value of the
handlerrecord component
-