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 interfacestatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCodedAction(Class<?> clazz, PacketCodec.ICodecAction action) Register a new coded action.voiddecode(net.minecraft.network.FriendlyByteBuf input) Decode for this packet.voidencode(net.minecraft.network.FriendlyByteBuf output) Encode this packet.static PacketCodec.ICodecActionprotected static PacketCodec.ICodecActiongetActionSuper(Class<?> clazz) static <T> TRead the an object of the given type from the packet buffer.static voidWrite 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:PacketBaseEncode this packet.- Specified by:
encodein classPacketBase- Parameters:
output- The byte array to encode to.
-
decode
public void decode(net.minecraft.network.FriendlyByteBuf input) Description copied from class:PacketBaseDecode for this packet.- Specified by:
decodein 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.
-