Package org.cyclops.cyclopscore.network
Class PacketCodec
java.lang.Object
org.cyclops.cyclopscore.network.PacketBase
org.cyclops.cyclopscore.network.PacketCodec
- Direct Known Subclasses:
AdvancementRewardsObtainPacket
,ButtonClickPacket
,PingPongPacketAsync
,PlayerPositionPacket
,ReloadResourcesPacket
,RequestPlayerAdvancementUnlockedPacket
,RequestPlayerNbtPacket
,SendPlayerAdvancementUnlockedPacket
,SendPlayerNbtPacket
,ValueNotifyPacket
Packet with automatic coding and decoding of basic fields annotated with
CodecField
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCodedAction
(Class<?> clazz, PacketCodec.ICodecAction action) Register a new coded action.void
decode
(net.minecraft.network.FriendlyByteBuf input) Decode for this packet.void
encode
(net.minecraft.network.FriendlyByteBuf output) Encode this packet.static PacketCodec.ICodecAction
protected static PacketCodec.ICodecAction
getActionSuper
(Class<?> clazz) static <T> T
Read the an object of the given type from the packet buffer.static void
Write the given object into the packet buffer.Methods inherited from class org.cyclops.cyclopscore.network.PacketBase
actionClient, actionServer, isAsync
-
Field Details
-
READ_STRING_MAX_LENGTH
public static final int READ_STRING_MAX_LENGTH- See Also:
-
fieldCache
-
-
Constructor Details
-
PacketCodec
public PacketCodec()
-
-
Method Details
-
addCodedAction
Register a new coded action.- Parameters:
clazz
- A class type.action
- A codec action for the given type.
-
getActionSuper
-
getAction
-
encode
public void encode(net.minecraft.network.FriendlyByteBuf output) Description copied from class:PacketBase
Encode this packet.- Specified by:
encode
in classPacketBase
- Parameters:
output
- The byte array to encode to.
-
decode
public void decode(net.minecraft.network.FriendlyByteBuf input) Description copied from class:PacketBase
Decode for this packet.- Specified by:
decode
in classPacketBase
- Parameters:
input
- The byte array to decode from.
-
write
Write the given object into the packet buffer.- Parameters:
packetBuffer
- A packet buffer.object
- An object.
-
read
Read the an object of the given type from the packet buffer.- Type Parameters:
T
- The type of object.- Parameters:
packetBuffer
- A packet buffer.clazz
- The class type to read.- Returns:
- The read object.
-