Class PacketBase

java.lang.Object
org.cyclops.cyclopscore.network.PacketBase
All Implemented Interfaces:
net.minecraft.network.protocol.common.custom.CustomPacketPayload
Direct Known Subclasses:
PacketCodec

public abstract class PacketBase extends Object implements net.minecraft.network.protocol.common.custom.CustomPacketPayload
The base packet for packets. All packets must have a default constructor.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    PacketBase(net.minecraft.resources.ResourceLocation id)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    actionClient(net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player)
    Actions for client-side.
    abstract void
    actionServer(net.minecraft.world.level.Level level, net.minecraft.server.level.ServerPlayer player)
    Actions for server-side.
    abstract void
    decode(net.minecraft.network.FriendlyByteBuf input)
    Decode for this packet.
    abstract void
    encode(net.minecraft.network.FriendlyByteBuf output)
    Encode this packet.
    net.minecraft.resources.ResourceLocation
    id()
     
    abstract boolean
     
    void
    write(net.minecraft.network.FriendlyByteBuf buf)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PacketBase

      protected PacketBase(net.minecraft.resources.ResourceLocation id)
  • Method Details

    • write

      public void write(net.minecraft.network.FriendlyByteBuf buf)
      Specified by:
      write in interface net.minecraft.network.protocol.common.custom.CustomPacketPayload
    • id

      public net.minecraft.resources.ResourceLocation id()
      Specified by:
      id in interface net.minecraft.network.protocol.common.custom.CustomPacketPayload
    • isAsync

      public abstract boolean isAsync()
      Returns:
      If this packet can run on a thread other than the main-thread of Minecraft. If this is asynchronous, the player parameter inside the action is not guaranteed to be defined.
    • encode

      public abstract void encode(net.minecraft.network.FriendlyByteBuf output)
      Encode this packet.
      Parameters:
      output - The byte array to encode to.
    • decode

      public abstract void decode(net.minecraft.network.FriendlyByteBuf input)
      Decode for this packet.
      Parameters:
      input - The byte array to decode from.
    • actionClient

      public abstract void actionClient(net.minecraft.world.level.Level level, net.minecraft.world.entity.player.Player player)
      Actions for client-side.
      Parameters:
      level - The world.
      player - The player. Can be null if this packet is asynchronous.
    • actionServer

      public abstract void actionServer(net.minecraft.world.level.Level level, net.minecraft.server.level.ServerPlayer player)
      Actions for server-side.
      Parameters:
      level - The world.
      player - The player.