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
Modifier and TypeFieldDescriptionprivate final ResourceLocation
The field for theid
record component.private final int
The field for thepacketIndex
record component.private final FriendlyByteBuf
The field for thepayload
record component. -
Constructor Summary
ConstructorDescriptionSimplePayload
(byte[] payload, ResourceLocation id, int packetIndex) SimplePayload
(FriendlyByteBuf payload, ResourceLocation id, int packetIndex) Creates an instance of aSimplePayload
record class. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()
The buffer that created the query payload.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.id()
Returns the value of theid
record component.static SimplePayload
inbound
(FriendlyByteBuf byteBuf, ResourceLocation id) static SimplePayload
outbound
(byte[] payload, int packetIndex, ResourceLocation id) static SimplePayload
outbound
(FriendlyByteBuf byteBuf, int packetIndex, ResourceLocation id) int
Returns the value of thepacketIndex
record component.payload()
Returns the value of thepayload
record component.final String
toString()
Returns a string representation of this record class.void
write
(FriendlyByteBuf buf) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.network.ICustomPacketPayloadWithBuffer
getDirection
-
Field Details
-
payload
The field for thepayload
record component. -
id
The field for theid
record component. -
packetIndex
private final int packetIndexThe field for thepacketIndex
record component.
-
-
Constructor Details
-
SimplePayload
-
SimplePayload
Creates an instance of aSimplePayload
record class.- Parameters:
payload
- the value for thepayload
record componentid
- the value for theid
record componentpacketIndex
- the value for thepacketIndex
record component
-
-
Method Details
-
outbound
-
outbound
-
inbound
-
write
- Specified by:
write
in interfaceCustomPacketPayload
-
buffer
Description copied from interface:ICustomPacketPayloadWithBuffer
The buffer that created the query payload.- Specified by:
buffer
in interfaceICustomPacketPayloadWithBuffer
- Returns:
- The buffer
-
packetIndex
public int packetIndex()Returns the value of thepacketIndex
record component.- Specified by:
packetIndex
in interfaceICustomPacketPayloadWithBuffer
- Returns:
- the value of the
packetIndex
record component
-
payload
Returns the value of thepayload
record component.- Returns:
- the value of the
payload
record 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 theid
record component.- Specified by:
id
in interfaceCustomPacketPayload
- Returns:
- the value of the
id
record component
-