Class PacketSender

java.lang.Object
codechicken.lib.packet.PacketSender

public class PacketSender extends Object
Created by covers1624 on 17/9/24.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Overload of sendToAllAround(Packet, double, double, double, double, ResourceKey) first wrapping payload to a client bound packet.
    static void
    sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Overload of sendToAllAround(Packet, BlockPos, double, ResourceKey) first wrapping payload to a client bound packet.
    static void
    sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.
    static void
    sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.
    static void
    sendToAllPlayers(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Overload of sendToAllPlayers(Packet) first wrapping payload to a client bound packet.
    static void
    sendToAllPlayers(net.minecraft.network.protocol.Packet<?> packet)
    Sends the given packet to all connected clients.
    static void
    sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
    Overload of sendToChunk(Packet, ServerLevel, int, int) first wrapping payload to a client bound packet.
    static void
    sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Overload of sendToChunk(Packet, ServerLevel, BlockPos) first wrapping payload to a client bound packet.
    static void
    sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
    Overload of sendToChunk(Packet, ServerLevel, ChunkPos) first wrapping payload to a client bound packet.
    static void
    sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.world.level.block.entity.BlockEntity tile)
    Overload of sendToChunk(Packet, BlockEntity) first wrapping payload to a client bound packet.
    static void
    sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
    Send the given packet to all players watching the specified chunk in the specified dimension.
    static void
    sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Send the given packet to all players watching the chunk specified by the given BlockPos in the specified dimension.
    static void
    sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
    Send the given packet to all players watching the specified chunk in the specified dimension.
    static void
    sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.world.level.block.entity.BlockEntity tile)
    Send the given packet to all players watching the chunk, that the given BlockEntity is within.
    static void
    sendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Overload of sendToDimension(Packet, ResourceKey) first wrapping payload to a client bound packet.
    static void
    sendToDimension(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Send the given packet to all players within the given dimension.
    static void
    sendToOps(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Overload of sendToOps(Packet) first wrapping payload to a client bound packet.
    static void
    sendToOps(net.minecraft.network.protocol.Packet<?> packet)
    Send the given packet to all server operators.
    static void
    sendToPlayer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable net.minecraft.server.level.ServerPlayer player)
    Overload of sendToPlayer(Packet, ServerPlayer) first wrapping payload to a client bound packet.
    static void
    sendToPlayer(net.minecraft.network.protocol.Packet<?> packet, @Nullable net.minecraft.server.level.ServerPlayer player)
    Send the given packet to the specified player.
    static void
    sendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Overload of sendToServer(Packet) first wrapping payload to a server bound packet.
    static void
    sendToServer(net.minecraft.network.protocol.Packet<?> packet)
    Send the given packet to the server.
    static net.minecraft.network.protocol.Packet<?>
    toClientPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Create a client bound packet for the given custom payload.
    static net.minecraft.network.protocol.Packet<?>
    toServerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Create a server bound packet for the given custom payload.

    Methods inherited from class java.lang.Object

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

    • PacketSender

      public PacketSender()
  • Method Details

    • toClientPacket

      public static net.minecraft.network.protocol.Packet<?> toClientPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Create a client bound packet for the given custom payload.
      Parameters:
      payload - The payload.
      Returns:
      The packet.
    • sendToPlayer

      public static void sendToPlayer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable @Nullable net.minecraft.server.level.ServerPlayer player)
      Overload of sendToPlayer(Packet, ServerPlayer) first wrapping payload to a client bound packet.
    • sendToPlayer

      public static void sendToPlayer(net.minecraft.network.protocol.Packet<?> packet, @Nullable @Nullable net.minecraft.server.level.ServerPlayer player)
      Send the given packet to the specified player. If the specified player is null, sends the packet to all connected clients.
      Parameters:
      packet - The packet to send.
      player - The receiver. null for all players.
    • sendToAllPlayers

      public static void sendToAllPlayers(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Overload of sendToAllPlayers(Packet) first wrapping payload to a client bound packet.
    • sendToAllPlayers

      public static void sendToAllPlayers(net.minecraft.network.protocol.Packet<?> packet)
      Sends the given packet to all connected clients.
      Parameters:
      packet - The packet to send.
    • sendToAllAround

      public static void sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Overload of sendToAllAround(Packet, BlockPos, double, ResourceKey) first wrapping payload to a client bound packet.
    • sendToAllAround

      public static void sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.

      For blocks, it is advised to instead use one of the sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload, net.minecraft.world.level.block.entity.BlockEntity) methods.

      Parameters:
      packet - The packet to send.
      pos - The origin point to send around.
      range - The range in which to send.
      dim - The dimension to send to.
    • sendToAllAround

      public static void sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Overload of sendToAllAround(Packet, double, double, double, double, ResourceKey) first wrapping payload to a client bound packet.
    • sendToAllAround

      public static void sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.

      For blocks, it is advised to instead use one of the sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload, net.minecraft.world.level.block.entity.BlockEntity) methods.

      Parameters:
      packet - The packet to send.
      x - The X origin point to send around.
      y - The Y origin point to send around.
      z - The Z origin point to send around.
      range - The range in which to send.
      dim - The dimension to send to.
    • sendToDimension

      public static void sendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Overload of sendToDimension(Packet, ResourceKey) first wrapping payload to a client bound packet.
    • sendToDimension

      public static void sendToDimension(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Send the given packet to all players within the given dimension.
      Parameters:
      packet - The packet to send.
      dim - The dimension to send to.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.world.level.block.entity.BlockEntity tile)
      Overload of sendToChunk(Packet, BlockEntity) first wrapping payload to a client bound packet.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.world.level.block.entity.BlockEntity tile)
      Send the given packet to all players watching the chunk, that the given BlockEntity is within.
      Parameters:
      packet - The packet to send.
      tile - The BlockEntity of the watched chunk to send to.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Overload of sendToChunk(Packet, ServerLevel, BlockPos) first wrapping payload to a client bound packet.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Send the given packet to all players watching the chunk specified by the given BlockPos in the specified dimension.
      Parameters:
      packet - The packet to send.
      level - The level containing the chunk to send to.
      pos - The BlockPos specifying the chunk to send to.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
      Overload of sendToChunk(Packet, ServerLevel, int, int) first wrapping payload to a client bound packet.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
      Send the given packet to all players watching the specified chunk in the specified dimension.
      Parameters:
      packet - The packet to send.
      level - The level containing the chunk to send to.
      chunkX - The chunk X coordinate to send to.
      chunkZ - The chunk Z coordinate to send to.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
      Overload of sendToChunk(Packet, ServerLevel, ChunkPos) first wrapping payload to a client bound packet.
    • sendToChunk

      public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
      Send the given packet to all players watching the specified chunk in the specified dimension.
      Parameters:
      packet - The packet to send.
      level - The level containing the chunk to send to.
      pos - The ChunkPos to send to.
    • sendToOps

      public static void sendToOps(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Overload of sendToOps(Packet) first wrapping payload to a client bound packet.
    • sendToOps

      public static void sendToOps(net.minecraft.network.protocol.Packet<?> packet)
      Send the given packet to all server operators.
      Parameters:
      packet - The packet to send.
    • toServerPacket

      public static net.minecraft.network.protocol.Packet<?> toServerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Create a server bound packet for the given custom payload.
      Parameters:
      payload - The payload.
      Returns:
      The packet.
    • sendToServer

      public static void sendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Overload of sendToServer(Packet) first wrapping payload to a server bound packet.
    • sendToServer

      public static void sendToServer(net.minecraft.network.protocol.Packet<?> packet)
      Send the given packet to the server.
      Parameters:
      packet - The packet to send.