Interface NetworkHandler

All Known Implementing Classes:
PacketRegistrationHandler, PaperNetworkHandler

public interface NetworkHandler
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket
    Generates a ClientboundCustomPayloadPacket
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket
    Generates a ServerboundCustomPayloadPacket
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    send(T packet, net.minecraft.network.Connection connection)
    Sends the packet to the connection.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToAllClients(T packet, net.minecraft.server.MinecraftServer server)
    Sends the packet to all the client players in the server, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToAllClients(T packet, net.minecraft.server.MinecraftServer server, boolean ignoreCheck)
    Sends the packet to all the client players in the server
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClient(T packet, net.minecraft.server.level.ServerPlayer player)
    Sends the packet to the client player, only if the player has the packet registered.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck)
    Sends the packet to the client player.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players)
    Sends the packet to the client players, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players, boolean ignoreCheck)
    Sends the packet to the client players.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level)
    Sends the packet to all the client players in the level, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level, boolean ignoreCheck)
    Sends the packet to all the client players in the level.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range)
    Sends the packet to all the client players in range of a position, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range, boolean ignoreCheck)
    Sends the packet to all the client players in range of a position.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk)
    Sends the packet to all the client players loading a chunk, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk, boolean ignoreCheck)
    Sends the packet to all the client players loading a chunk.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Sends the packet to all the client players loading a position, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, boolean ignoreCheck)
    Sends the packet to all the client players loading a position
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
    Sends the packet to all the client players loading a position, only if the players has the packet registered.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos, boolean ignoreCheck)
    Sends the packet to all the client players loading a position.
    default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToServer(T packet)
    Sends the packet to the server, if the server has the packet registered.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToServer(T packet, boolean ignoreCheck)
    Sends the packet to the server.
  • Method Details

    • sendToServer

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToServer(T packet)
      Sends the packet to the server, if the server has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
    • sendToServer

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToServer(T packet, boolean ignoreCheck)
      Sends the packet to the server. Can ignore the check if the server has the packet registered. Likely use case for this is talking to bukkit/spigot/paper servers.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      ignoreCheck - - ignore the check if the server has the packet registered.
    • sendToClient

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player)
      Sends the packet to the client player, only if the player has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      player - - the player
    • sendToClient

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck)
      Sends the packet to the client player.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      player - - the player
      ignoreCheck - - ignore the check if the client has the packet registered.
    • send

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void send(T packet, net.minecraft.network.Connection connection)
      Sends the packet to the connection.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      connection - - the connection
    • getRawClientboundPacket

      @Nullable <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket getRawClientboundPacket(T packet)
      Generates a ClientboundCustomPayloadPacket
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      Returns:
      The packet wrapped into a ClientboundCustomPayloadPacket
    • getRawServerboundPacket

      @Nullable <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket getRawServerboundPacket(T packet)
      Generates a ServerboundCustomPayloadPacket
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      Returns:
      The packet wrapped into a ServerboundCustomPayloadPacket
    • sendToClients

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players)
      Sends the packet to the client players, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      players - - the players
    • sendToClients

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClients(T packet, List<net.minecraft.server.level.ServerPlayer> players, boolean ignoreCheck)
      Sends the packet to the client players.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      players - - the players
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToAllClients

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToAllClients(T packet, net.minecraft.server.MinecraftServer server)
      Sends the packet to all the client players in the server, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      server - - the server
    • sendToAllClients

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToAllClients(T packet, net.minecraft.server.MinecraftServer server, boolean ignoreCheck)
      Sends the packet to all the client players in the server
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      server - - the server
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToClientsInLevel

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level)
      Sends the packet to all the client players in the level, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
    • sendToClientsInLevel

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsInLevel(T packet, net.minecraft.server.level.ServerLevel level, boolean ignoreCheck)
      Sends the packet to all the client players in the level.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToClientsLoadingChunk

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk)
      Sends the packet to all the client players loading a chunk, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      chunk - - the chunk
    • sendToClientsLoadingChunk

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingChunk(T packet, net.minecraft.world.level.chunk.LevelChunk chunk, boolean ignoreCheck)
      Sends the packet to all the client players loading a chunk.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      chunk - - the chunk
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToClientsLoadingPos

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
      Sends the packet to all the client players loading a position, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the chunkpos
    • sendToClientsLoadingPos

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos, boolean ignoreCheck)
      Sends the packet to all the client players loading a position.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the chunkpos
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToClientsLoadingPos

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Sends the packet to all the client players loading a position, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the blockpos
    • sendToClientsLoadingPos

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsLoadingPos(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, boolean ignoreCheck)
      Sends the packet to all the client players loading a position
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the blockpos
      ignoreCheck - - ignore the check if the client has the packet registered.
    • sendToClientsInRange

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range)
      Sends the packet to all the client players in range of a position, only if the players has the packet registered.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the blockpos
      range - - the range
    • sendToClientsInRange

      default <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClientsInRange(T packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos, double range, boolean ignoreCheck)
      Sends the packet to all the client players in range of a position.
      Type Parameters:
      T - - The packet type
      Parameters:
      packet - - the packet
      level - - the level
      pos - - the blockpos
      range - - the range
      ignoreCheck - - ignore the check if the client has the packet registered.