Interface INetworkHandler

All Known Implementing Classes:
NeoForgeNetworkHandler

public interface INetworkHandler
Provides platform specific implementations of network related code. Access using Services.NETWORK.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canSendPacket(net.minecraft.server.level.ServerPlayer recipient, IPacket<?> packet)
    Tests if a payload type can be sent to a player.
    default boolean
    canSendPacket(net.minecraft.server.level.ServerPlayer recipient, net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
    Tests if a payload type can be sent to a player.
    boolean
    canSendPacket(net.minecraft.server.level.ServerPlayer recipient, net.minecraft.resources.ResourceLocation payloadId)
    Tests if a payload type can be sent to a player.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    register(IPacket<T> packet)
    Registers a Bookshelf packet type to the packet registry.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToPlayer(net.minecraft.server.level.ServerPlayer recipient, T payload)
    Sends a packet from the server to a player.
    <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    sendToServer(T payload)
    Sends a payload from the client to the server.
  • Method Details

    • register

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void register(IPacket<T> packet)
      Registers a Bookshelf packet type to the packet registry.
      Type Parameters:
      T - The type of the payload.
      Parameters:
      packet - The packet type to register.
    • sendToServer

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToServer(T payload)
      Sends a payload from the client to the server.
      Type Parameters:
      T - The type of the payload.
      Parameters:
      payload - The payload to send.
    • sendToPlayer

      <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToPlayer(net.minecraft.server.level.ServerPlayer recipient, T payload)
      Sends a packet from the server to a player.
      Type Parameters:
      T - The type of the payload.
      Parameters:
      recipient - The recipient of the packet.
      payload - The payload to send.
    • canSendPacket

      default boolean canSendPacket(net.minecraft.server.level.ServerPlayer recipient, net.minecraft.network.protocol.common.custom.CustomPacketPayload payload)
      Tests if a payload type can be sent to a player.
      Parameters:
      recipient - The recipient of the packet.
      payload - The payload to test.
      Returns:
      If the payload can be sent to the recipient player.
    • canSendPacket

      default boolean canSendPacket(net.minecraft.server.level.ServerPlayer recipient, IPacket<?> packet)
      Tests if a payload type can be sent to a player.
      Parameters:
      recipient - The recipient of the packet.
      packet - The packet to test.
      Returns:
      If the payload can be sent to the recipient player.
    • canSendPacket

      boolean canSendPacket(net.minecraft.server.level.ServerPlayer recipient, net.minecraft.resources.ResourceLocation payloadId)
      Tests if a payload type can be sent to a player.
      Parameters:
      recipient - The recipient of the packet.
      payloadId - The payload type ID.
      Returns:
      If the payload can be sent to the recipient player.