Interface VeilPacketManager


public interface VeilPacketManager
Manages packet registration and sending.
  • 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

      <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
    • 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)
      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
    • 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