Package net.minecraftforge.network
Record Class PayloadChannel.Builder.HandlerFlow<BUF extends FriendlyByteBuf,CTX,BASE extends CustomPacketPayload & SimplePacket<CTX>>
java.lang.Object
java.lang.Record
net.minecraftforge.network.PayloadChannel.Builder.HandlerFlow<BUF,CTX,BASE>
- All Implemented Interfaces:
ChannelBuildable<CustomPacketPayload>
,PayloadHandlerFlow<BUF,
,BASE> PayloadHandlerProtocol<BUF,
,BASE> PayloadConnection<BASE>
,PayloadChannel.Builder.ProtocolFactory<BUF,
,BASE> BaseProtocol<PayloadHandlerFlow<BUF,
BASE>, PayloadHandlerProtocol<BUF, BASE>>
- Enclosing class:
PayloadChannel.Builder
private static record PayloadChannel.Builder.HandlerFlow<BUF extends FriendlyByteBuf,CTX,BASE extends CustomPacketPayload & SimplePacket<CTX>> (io.netty.util.AttributeKey<CTX> key, PayloadChannel.Builder.BuilderContext<BUF extends FriendlyByteBuf,BASE extends CustomPacketPayload & SimplePacket<CTX>> ctx)
extends Record
implements PayloadChannel.Builder.ProtocolFactory<BUF,BASE>, PayloadHandlerFlow<BUF,BASE>
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
HandlerFlow
(io.netty.util.AttributeKey<CTX> key, PayloadChannel.Builder.BuilderContext<BUF, BASE> ctx) Creates an instance of aHandlerFlow
record class. -
Method Summary
Modifier and TypeMethodDescription<MSG extends BASE>
PayloadHandlerFlow<BUF, BASE> add
(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec) Adds a packet to this channel that has it's protocol validated whenever sent or received.<MSG extends BASE>
PayloadHandlerFlow<BUF, BASE> add
(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec, BiConsumer<MSG, CustomPayloadEvent.Context> consumer) Adds a packet to this channel that has it's protocol validated whenever sent or received.<MSG extends BASE>
PayloadHandlerFlow<BUF, BASE> addMain
(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec) Adds a packet to this channel that has it's protocol validated whenever sent or received.ctx()
Returns the value of thectx
record component.final boolean
Indicates whether some other object is "equal to" this one.flow
(@Nullable PacketFlow flow) final int
hashCode()
Returns a hash code value for this object.io.netty.util.AttributeKey
<CTX> key()
Returns the value of thekey
record component.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraftforge.network.simple.BaseProtocol
bidirectional, bidirectional, clientbound, clientbound, flow, flow, serverbound, serverbound
Methods inherited from interface net.minecraftforge.network.PayloadChannel.Builder.ProtocolFactory
build, protocol, protocol
Methods inherited from interface net.minecraftforge.network.payload.PayloadConnection
any, any, any, any, configuration, configuration, configuration, configuration, login, login, login, login, play, play, play, play, protocol, protocol
-
Field Details
-
key
The field for thekey
record component. -
ctx
private final PayloadChannel.Builder.BuilderContext<BUF extends FriendlyByteBuf,BASE extends CustomPacketPayload & SimplePacket<CTX>> ctxThe field for thectx
record component.
-
-
Constructor Details
-
HandlerFlow
private HandlerFlow(io.netty.util.AttributeKey<CTX> key, PayloadChannel.Builder.BuilderContext<BUF, BASE> ctx) Creates an instance of aHandlerFlow
record class.- Parameters:
key
- the value for thekey
record componentctx
- the value for thectx
record component
-
-
Method Details
-
add
public <MSG extends BASE> PayloadHandlerFlow<BUF,BASE> add(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec) Description copied from interface:PayloadHandlerFlow
Adds a packet to this channel that has it's protocol validated whenever sent or received.The handler is called on the network thread, and so should not interact with most game state by default.
CustomPayloadEvent.Context.enqueueWork(Runnable)
can be used to handle the message on the main server or client thread. Alternatively one can useinvalid reference
#addMain(Class, StreamCodec)
- Specified by:
add
in interfacePayloadHandlerFlow<BUF extends FriendlyByteBuf,
CTX>
-
addMain
public <MSG extends BASE> PayloadHandlerFlow<BUF,BASE> addMain(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec) Description copied from interface:PayloadHandlerFlow
Adds a packet to this channel that has it's protocol validated whenever sent or received.Unlike
PayloadHandlerFlow.add(Type,StreamCodec)
, the consumer is called on the main thread, and so can interact with most game state by default.- Specified by:
addMain
in interfacePayloadHandlerFlow<BUF extends FriendlyByteBuf,
CTX>
-
add
public <MSG extends BASE> PayloadHandlerFlow<BUF,BASE> add(CustomPacketPayload.Type<MSG> type, StreamCodec<BUF, MSG> codec, BiConsumer<MSG, CustomPayloadEvent.Context> consumer) Description copied from interface:PayloadHandlerFlow
Adds a packet to this channel that has it's protocol validated whenever sent or received.The handler is called on the network thread, and so should not interact with most game state by default.
CustomPayloadEvent.Context.enqueueWork(Runnable)
can be used to handle the message on the main server or client thread.- Specified by:
add
in interfacePayloadHandlerFlow<BUF extends FriendlyByteBuf,
CTX>
-
flow
- Specified by:
flow
in interfaceBaseProtocol<BUF extends FriendlyByteBuf,
CTX>
-
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)
. -
key
Returns the value of thekey
record component.- Returns:
- the value of the
key
record component
-
ctx
Returns the value of thectx
record component.- Specified by:
ctx
in interfacePayloadChannel.Builder.ProtocolFactory<BUF extends FriendlyByteBuf,
CTX> - Returns:
- the value of the
ctx
record component
-