Class PacketType<T extends FabricPacket>
java.lang.Object
net.fabricmc.fabric.api.networking.v1.PacketType<T>
- Type Parameters:
T
- the type of the packet
A type of packet. An instance of this should be created per a
FabricPacket
implementation.
This holds the channel ID used for the packet.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P extends FabricPacket>
PacketType<P>create
(Identifier id, Function<PacketByteBuf, P> constructor) Creates a new packet type.getId()
Returns the identifier of the channel used to send the packet.read
(PacketByteBuf buf) Reads the packet from the buffer.
-
Method Details
-
create
public static <P extends FabricPacket> PacketType<P> create(Identifier id, Function<PacketByteBuf, P> constructor) Creates a new packet type.- Type Parameters:
P
- the type of the packet- Parameters:
id
- the channel ID used for the packetsconstructor
- the reader that reads the received buffer- Returns:
- the newly created type
-
getId
Returns the identifier of the channel used to send the packet.- Returns:
- the identifier of the associated channel.
-
read
Reads the packet from the buffer.- Parameters:
buf
- the buffer- Returns:
- the packet
-