Class NetworkHelper

java.lang.Object
com.pixelmonmod.pixelmon.api.util.helpers.NetworkHelper

public class NetworkHelper extends Object
Static utility class to abstract and simplify sending packets (weird PacketDistributor is ugly)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    sendNearbyPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius)
    Sends a packet to all nearby players
    static void
    sendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.entity.player.Player serverPlayer)
    Sends the packet to the player
    static void
    sendPacket(net.minecraft.world.entity.player.Player serverPlayer, net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
    Sends the packet to the player
    static void
    sendToAll(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
    Sends a packet to all players
    static void
    sendToAllTracking(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.entity.Entity entity)
    Sends a packet to all nearby players
    static void
    sendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.level.Level world)
    Sends a packet to all nearby players
    static void
    sendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
    Sends a packet to the server
    static net.minecraft.network.protocol.Packet<?>
    toClientBoundVanillaPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
    Converts the CustomPacketPayload to a Packet that can be sent to the client using vanilla methods, and the ConfigurationTask method

    Methods inherited from class java.lang.Object

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

    • NetworkHelper

      public NetworkHelper()
  • Method Details

    • sendPacket

      public static void sendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.entity.player.Player serverPlayer)
      Sends the packet to the player
      Parameters:
      packet - The packet to send to the player
      serverPlayer - The player implementation
    • sendPacket

      public static void sendPacket(net.minecraft.world.entity.player.Player serverPlayer, net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
      Sends the packet to the player
      Parameters:
      serverPlayer - The player implementation
      packet - The packet to send to the player
    • sendNearbyPacket

      public static void sendNearbyPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius)
      Sends a packet to all nearby players
      Parameters:
      packet - The packet to send
    • sendToDimension

      public static void sendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.level.Level world)
      Sends a packet to all nearby players
      Parameters:
      packet - The packet to send
      world - The world to get all players from
    • sendToAllTracking

      public static void sendToAllTracking(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet, net.minecraft.world.entity.Entity entity)
      Sends a packet to all nearby players
      Parameters:
      packet - The packet to send
      entity - The entity to get all players tracking
    • sendToAll

      public static void sendToAll(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
      Sends a packet to all players
      Parameters:
      packet - The packet to send
    • sendToServer

      public static void sendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
      Sends a packet to the server
      Parameters:
      packet - The packet to send
    • toClientBoundVanillaPacket

      public static net.minecraft.network.protocol.Packet<?> toClientBoundVanillaPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload packet)
      Converts the CustomPacketPayload to a Packet that can be sent to the client using vanilla methods, and the ConfigurationTask method
      Parameters:
      packet - The packet to convert
      Returns:
      The converted vanilla packet