Class AbstractPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>

java.lang.Object
net.darkhax.bookshelf.common.api.network.AbstractPacket<T>
Type Parameters:
T - The type of the payload.
All Implemented Interfaces:
IPacket<T>

public abstract class AbstractPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> extends Object implements IPacket<T>
A basic packet implementation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractPacket(net.minecraft.resources.ResourceLocation id, net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T> codec)
    A packet that is sent from the server to the client.
    AbstractPacket(net.minecraft.resources.ResourceLocation id, net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T> codec, Destination direction)
    A simple packet type.
  • Method Summary

    Modifier and Type
    Method
    Description
    Defines how the packet is meant to be sent and where it should be handled.
    net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T>
    Gets a stream codec that can serialize the payload across the network.
    net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T>
    Gets the payload type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.darkhax.bookshelf.common.api.network.IPacket

    handle, toAllPlayers, toAllPlayers, toAllPlayers, toPlayer, toServer
  • Constructor Details

    • AbstractPacket

      public AbstractPacket(net.minecraft.resources.ResourceLocation id, net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T> codec)
      A packet that is sent from the server to the client.
      Parameters:
      id - The packet ID.
      codec - The payload codec.
    • AbstractPacket

      public AbstractPacket(net.minecraft.resources.ResourceLocation id, net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T> codec, Destination direction)
      A simple packet type.
      Parameters:
      id - The packet ID.
      codec - The payload codec.
      direction - The intended destination of the packet.
  • Method Details

    • type

      public net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> type()
      Description copied from interface: IPacket
      Gets the payload type.
      Specified by:
      type in interface IPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
      Returns:
      The payload type.
    • streamCodec

      public net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,T> streamCodec()
      Description copied from interface: IPacket
      Gets a stream codec that can serialize the payload across the network.
      Specified by:
      streamCodec in interface IPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
      Returns:
      The stream coded used to serialize the payload.
    • destination

      public Destination destination()
      Description copied from interface: IPacket
      Defines how the packet is meant to be sent and where it should be handled.
      Specified by:
      destination in interface IPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
      Returns:
      The intended destination of the packet.