Record Class SimplePayload
java.lang.Object
java.lang.Record
net.neoforged.neoforge.network.custom.payload.SimplePayload
- All Implemented Interfaces:
CustomPacketPayload,ICustomPacketPayloadWithBuffer
public record SimplePayload(FriendlyByteBuf payload, ResourceLocation id, int packetIndex)
extends Record
implements ICustomPacketPayloadWithBuffer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ResourceLocationThe field for theidrecord component.private final intThe field for thepacketIndexrecord component.private final FriendlyByteBufThe field for thepayloadrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionSimplePayload(byte[] payload, ResourceLocation id, int packetIndex) SimplePayload(FriendlyByteBuf payload, ResourceLocation id, int packetIndex) Creates an instance of aSimplePayloadrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()The buffer that created the query payload.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static SimplePayloadinbound(FriendlyByteBuf byteBuf, ResourceLocation id) static SimplePayloadoutbound(byte[] payload, int packetIndex, ResourceLocation id) static SimplePayloadoutbound(FriendlyByteBuf byteBuf, int packetIndex, ResourceLocation id) intReturns the value of thepacketIndexrecord component.payload()Returns the value of thepayloadrecord component.final StringtoString()Returns a string representation of this record class.voidwrite(FriendlyByteBuf buf) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.network.ICustomPacketPayloadWithBuffer
getDirection
-
Field Details
-
payload
The field for thepayloadrecord component. -
id
The field for theidrecord component. -
packetIndex
private final int packetIndexThe field for thepacketIndexrecord component.
-
-
Constructor Details
-
SimplePayload
-
SimplePayload
Creates an instance of aSimplePayloadrecord class.- Parameters:
payload- the value for thepayloadrecord componentid- the value for theidrecord componentpacketIndex- the value for thepacketIndexrecord component
-
-
Method Details
-
outbound
-
outbound
-
inbound
-
write
- Specified by:
writein interfaceCustomPacketPayload
-
buffer
Description copied from interface:ICustomPacketPayloadWithBufferThe buffer that created the query payload.- Specified by:
bufferin interfaceICustomPacketPayloadWithBuffer- Returns:
- The buffer
-
packetIndex
public int packetIndex()Returns the value of thepacketIndexrecord component.- Specified by:
packetIndexin interfaceICustomPacketPayloadWithBuffer- Returns:
- the value of the
packetIndexrecord component
-
payload
Returns the value of thepayloadrecord component.- Returns:
- the value of the
payloadrecord component
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
Returns the value of theidrecord component.- Specified by:
idin interfaceCustomPacketPayload- Returns:
- the value of the
idrecord component
-