Class NetworkHelper
java.lang.Object
com.pixelmonmod.tcg.api.util.helper.NetworkHelper
Static utility class to abstract and simplify sending packets (weird
PacketDistributor
is ugly)-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
sendNearbyPacket
(TargetPoint targetPoint, Function<net.minecraft.server.level.ServerPlayer, TCGPacket> packetFunction) Sends a packet to all nearby players, with a function to modify the packet based on the specific player.static void
sendNearbyPacket
(TCGPacket packet, net.minecraftforge.network.PacketDistributor.TargetPoint targetPoint) Sends a packet to all nearby playersstatic void
sendNearbyPacket
(net.minecraftforge.network.PacketDistributor.TargetPoint targetPoint, TCGPacket packet) Sends a packet to all nearby playersstatic void
sendPacket
(TCGPacket packet, net.minecraft.server.level.ServerPlayer serverPlayer) Sends the packet to the playerstatic void
sendPacket
(net.minecraft.server.level.ServerPlayer serverPlayer, TCGPacket packet) Sends the packet to the playerstatic void
Sends a packet to all playersstatic void
sendToAllTracking
(TCGPacket packet, net.minecraft.world.entity.Entity entity) Sends a packet to all nearby playersstatic void
sendToDimension
(TCGPacket packet, net.minecraft.world.level.Level level) Sends a packet to all nearby playersstatic void
sendToServer
(TCGPacket packet) Sends a packet to the serverstatic net.minecraft.network.protocol.Packet<?>
toClientBoundVanillaPacket
(TCGPacket packet) Converts thePixelmonPacket
to aPacket
that can be sent to the client using vanilla methods, and theConfigurationTask
method
-
Constructor Details
-
NetworkHelper
public NetworkHelper()
-
-
Method Details
-
sendPacket
public static void sendPacket(TCGPacket packet, net.minecraft.server.level.ServerPlayer serverPlayer) Sends the packet to the player- Parameters:
serverPlayer
- The player implementationpacket
- The packet to send to the player
-
sendPacket
public static void sendPacket(net.minecraft.server.level.ServerPlayer serverPlayer, TCGPacket packet) Sends the packet to the player- Parameters:
serverPlayer
- The player implementationpacket
- The packet to send to the player
-
sendNearbyPacket
public static void sendNearbyPacket(TCGPacket packet, net.minecraftforge.network.PacketDistributor.TargetPoint targetPoint) Sends a packet to all nearby players- Parameters:
targetPoint
- The point to get nearby players frompacket
- The packet to send
-
sendNearbyPacket
public static void sendNearbyPacket(net.minecraftforge.network.PacketDistributor.TargetPoint targetPoint, TCGPacket packet) Sends a packet to all nearby players- Parameters:
targetPoint
- The point to get nearby players frompacket
- The packet to send
-
sendNearbyPacket
public static void sendNearbyPacket(TargetPoint targetPoint, Function<net.minecraft.server.level.ServerPlayer, TCGPacket> packetFunction) Sends a packet to all nearby players, with a function to modify the packet based on the specific player. -
sendToDimension
Sends a packet to all nearby players- Parameters:
level
- The world to get all players frompacket
- The packet to send
-
sendToAllTracking
Sends a packet to all nearby players- Parameters:
entity
- The entity to get all players trackingpacket
- The packet to send
-
sendToAll
Sends a packet to all players- Parameters:
packet
- The packet to send
-
sendToServer
Sends a packet to the server- Parameters:
packet
- The packet to send
-
toClientBoundVanillaPacket
Converts thePixelmonPacket
to aPacket
that can be sent to the client using vanilla methods, and theConfigurationTask
method- Parameters:
packet
- The packet to convert- Returns:
- The converted vanilla packet
-