@ChannelHandler.Sharable
public final class PacketHandler
extends java.lang.Object
PacketBase instances.
An alternative would be SimpleNetworkWrapper.
Partially based on the SecretRooms mod packet handling:
https://github.com/AbrarSyed/SecretRoomsMod-forge| Modifier and Type | Method and Description |
|---|---|
static cpw.mods.fml.common.network.FMLEmbeddedChannel |
getClientChannel()
Get the client-side channel.
|
static cpw.mods.fml.common.network.FMLEmbeddedChannel |
getServerChannel()
Get the server-side channel.
|
static void |
init()
Initialize the packet handler.
|
static void |
register(java.lang.Class<? extends PacketBase> packetType)
Register a new packet.
|
static void |
sendToAll(PacketBase packet)
Send a packet to everything.
|
static void |
sendToAllAround(PacketBase packet,
cpw.mods.fml.common.network.NetworkRegistry.TargetPoint point)
Send a packet to all in the target range.
|
static void |
sendToDimension(PacketBase packet,
int dimension)
Send a packet to everything in the given dimension.
|
static void |
sendToPlayer(PacketBase packet,
net.minecraft.entity.player.EntityPlayer player)
Send a packet to the player.
|
static void |
sendToServer(PacketBase packet)
Send a packet to the server.
|
static net.minecraft.network.Packet |
toMcPacket(PacketBase packet)
Convert the given packet to a minecraft packet.
|
public static void init()
public static void register(java.lang.Class<? extends PacketBase> packetType)
packetType - The class of the packet.public static cpw.mods.fml.common.network.FMLEmbeddedChannel getClientChannel()
public static cpw.mods.fml.common.network.FMLEmbeddedChannel getServerChannel()
public static void sendToServer(PacketBase packet)
packet - The packet.public static void sendToPlayer(PacketBase packet, net.minecraft.entity.player.EntityPlayer player)
packet - The packet.player - The player.public static void sendToAllAround(PacketBase packet, cpw.mods.fml.common.network.NetworkRegistry.TargetPoint point)
packet - The packet.point - The area to send to.public static void sendToDimension(PacketBase packet, int dimension)
packet - The packet.dimension - The dimension to send to.public static void sendToAll(PacketBase packet)
packet - The packet.public static net.minecraft.network.Packet toMcPacket(PacketBase packet)
packet - The packet.