Interface VeilPacketManager


public interface VeilPacketManager
Manages packet registration and sending.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Factory class for registration providers.
    static interface 
    VeilPacketManager.PacketHandler<T extends PacketContext,P extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    Handles packets from the client/server.
    static interface 
    Sends packets to players and automatically bundles payloads together.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The singleton instance of the VeilPacketManager.Factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    all(net.minecraft.server.MinecraftServer server)
    Sends packets to all players in the server.
    around(@Nullable net.minecraft.server.level.ServerPlayer excluded, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius)
    Sends packets to all players in the area covered by the specified radius, around the specified coordinates, in the specified dimension, excluding the specified excluded player if present.
    create(String modId, String version)
    level(net.minecraft.server.level.ServerLevel level)
    Sends packets to all players in the specified level.
    player(net.minecraft.server.level.ServerPlayer player)
     
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    registerClientbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ClientPacketContext,T> handler)
    Registers a new packet from the client to the server.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    registerClientbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ClientPacketContext,T> handler, boolean optional)
    Registers a new packet from the client to the server.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    registerServerbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ServerPacketContext,T> handler)
    Registers a new packet from the server to the client.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    registerServerbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ServerPacketContext,T> handler, boolean optional)
    Registers a new packet from the server to the client.
     
    tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Sends packets to all players tracking the chunk at the specified position in the specified level
    tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos min, net.minecraft.core.BlockPos max)
    Sends packets to all players tracking the chunks at the specified positions in the specified level
    tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
    Sends packets to all players tracking the chunk at the specified position in the specified level
    tracking(net.minecraft.world.entity.Entity entity)
    Sends packets to all players tracking the specified entity, excluding the entity.
    tracking(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
    Sends packets to all players tracking the specified block entity.
    trackingAndSelf(net.minecraft.world.entity.Entity entity)
    Sends packets to all players tracking the specified entity, including the entity.
  • Field Details

  • Method Details

    • create

      static VeilPacketManager create(String modId, String version)
      Parameters:
      modId - The id of the mod creating the channel
      version - The NeoForge channel version
      Returns:
      The packet manager
    • registerClientbound

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerClientbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ClientPacketContext,T> handler)
      Registers a new packet from the client to the server.
      Type Parameters:
      T - The type of packet to register
      Parameters:
      id - The id of the packet
      codec - The codec for encoding and decoding the packet
      handler - The handler method for the packet on the client
    • registerClientbound

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerClientbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ClientPacketContext,T> handler, boolean optional)
      Registers a new packet from the client to the server.
      Type Parameters:
      T - The type of packet to register
      Parameters:
      id - The id of the packet
      codec - The codec for encoding and decoding the packet
      handler - The handler method for the packet on the client
      optional - Whether a handler for this packet needs to exist on the client
      Since:
      4.0.0
    • registerServerbound

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerServerbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ServerPacketContext,T> handler)
      Registers a new packet from the server to the client.
      Type Parameters:
      T - The type of packet to register
      Parameters:
      id - The id of the packet
      codec - The codec for encoding and decoding the packet
      handler - The handler method for the packet on the server
    • registerServerbound

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerServerbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf,T> codec, VeilPacketManager.PacketHandler<ServerPacketContext,T> handler, boolean optional)
      Registers a new packet from the server to the client.
      Type Parameters:
      T - The type of packet to register
      Parameters:
      id - The id of the packet
      codec - The codec for encoding and decoding the packet
      handler - The handler method for the packet on the server
      optional - Whether a handler for this packet needs to exist on the server
      Since:
      4.0.0
    • server

      Returns:
      A sink to send packets to the server
    • player

      static VeilPacketManager.PacketSink player(net.minecraft.server.level.ServerPlayer player)
      Returns:
      A sink to send packets to the specified player
    • level

      static VeilPacketManager.PacketSink level(net.minecraft.server.level.ServerLevel level)
      Sends packets to all players in the specified level.
      Parameters:
      level - The level to send the packet to
      Returns:
      A sink to send packets to all players in the dimension
    • around

      static VeilPacketManager.PacketSink around(@Nullable @Nullable net.minecraft.server.level.ServerPlayer excluded, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius)
      Sends packets to all players in the area covered by the specified radius, around the specified coordinates, in the specified dimension, excluding the specified excluded player if present.
      Parameters:
      excluded - The player to exclude when sending the packet or null to send to all players
      level - the level to send the packet around
      x - the X position
      y - the Y position
      z - the Z position
      radius - the maximum distance from the position in blocks
      Returns:
      A sink to send packets to all players in the area
    • all

      static VeilPacketManager.PacketSink all(net.minecraft.server.MinecraftServer server)
      Sends packets to all players in the server.
      Parameters:
      server - The server instance
      Returns:
      A sink to send packets to all players
    • tracking

      static VeilPacketManager.PacketSink tracking(net.minecraft.world.entity.Entity entity)
      Sends packets to all players tracking the specified entity, excluding the entity.
      Parameters:
      entity - The entity to send tracking packets to
      Returns:
      A sink to send packets to all players tracking the entity
      Throws:
      IllegalArgumentException - if the entity is not in a server world
    • trackingAndSelf

      static VeilPacketManager.PacketSink trackingAndSelf(net.minecraft.world.entity.Entity entity)
      Sends packets to all players tracking the specified entity, including the entity.
      Parameters:
      entity - The entity to send tracking packets to
      Returns:
      A sink to send packets to all players tracking the entity and the entity
      Throws:
      IllegalArgumentException - if the entity is not in a server world
    • tracking

      static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
      Sends packets to all players tracking the chunk at the specified position in the specified level
      Parameters:
      level - The level to send the packet to
      pos - The chunk to send to
      Returns:
      A sink to send packets to all players tracking that chunk
    • tracking

      static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Sends packets to all players tracking the chunk at the specified position in the specified level
      Parameters:
      level - The level to send the packet to
      pos - The position to send to
      Returns:
      A sink to send packets to all players tracking that chunk
    • tracking

      static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos min, net.minecraft.core.BlockPos max)
      Sends packets to all players tracking the chunks at the specified positions in the specified level
      Parameters:
      level - The level to send the packet to
      min - The minimum position to send to
      max - The maximum position to send to
      Returns:
      A sink to send packets to all players tracking that chunk
    • tracking

      static VeilPacketManager.PacketSink tracking(net.minecraft.world.level.block.entity.BlockEntity blockEntity)
      Sends packets to all players tracking the specified block entity.
      Parameters:
      blockEntity - The block entity to send the packet to
      Returns:
      A sink to send packets to all players tracking that block entity
      Throws:
      IllegalArgumentException - if the block entity is not in a server level