Class PacketCodec

java.lang.Object
org.cyclops.cyclopscore.network.PacketBase
org.cyclops.cyclopscore.network.PacketCodec
All Implemented Interfaces:
net.minecraft.network.protocol.common.custom.CustomPacketPayload
Direct Known Subclasses:
AdvancementRewardsObtainPacket, ButtonClickPacket, PingPongPacketAsync, PlayerPositionPacket, ReloadResourcesPacket, RequestPlayerAdvancementUnlockedPacket, RequestPlayerNbtPacket, SendPlayerAdvancementUnlockedPacket, SendPlayerNbtPacket, ValueNotifyPacket

public abstract class PacketCodec extends PacketBase
Packet with automatic coding and decoding of basic fields annotated with CodecField.
  • Field Details

  • Constructor Details

    • PacketCodec

      public PacketCodec(net.minecraft.resources.ResourceLocation id)
  • Method Details

    • addCodedAction

      public static void addCodedAction(Class<?> clazz, PacketCodec.ICodecAction action)
      Register a new coded action.
      Parameters:
      clazz - A class type.
      action - A codec action for the given type.
    • getActionSuper

      @Nullable protected static PacketCodec.ICodecAction getActionSuper(Class<?> clazz)
    • getAction

      public static PacketCodec.ICodecAction getAction(Class<?> clazz)
    • encode

      public void encode(net.minecraft.network.FriendlyByteBuf output)
      Description copied from class: PacketBase
      Encode this packet.
      Specified by:
      encode in class PacketBase
      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 class PacketBase
      Parameters:
      input - The byte array to decode from.
    • write

      public static void write(net.minecraft.network.FriendlyByteBuf packetBuffer, Object object)
      Write the given object into the packet buffer.
      Parameters:
      packetBuffer - A packet buffer.
      object - An object.
    • read

      public static <T> T read(net.minecraft.network.FriendlyByteBuf packetBuffer, Class<T> clazz)
      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.