Repository navigation
Network manager
This class simplifies the registering and working with the packets.
So, you need to worry only about implementing the classes to handle packets
Registering packets:
The registering of the packets has to be made on FMLInitializationEvent.
If you do that before the FMLInitializationEvent, you will get an error. Cause this feature initializes on FMLPreInitializationEventevent.
The method to register the packet: AtumMod#getNetworkManager#registerMessage(IMessageHandlerclass, IMessage class, Side)
Example:
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
getNetworkManager().registerMessage(PacketHandlerPerformDisplayAction.class,
PacketPerformDisplayAction.class,
Side.CLIENT
);
getNetworkManager().registerMessage(PacketHandlerDisplayEvent.class,
PacketDisplayEvent.class,
Side.SERVER
);
}
Sending the packets
Important: You have to register packet first
You can use the following methods to send packets:
-
sendToServer(IMessage packet)
-
sendTo(IMessage message, EntityPlayerMP player)
-
sendToAll(IMessage message)
These are the basic methods, the class contains few extra methods you can check.
Here you can learn extra methods to use, which are mostly attached to atummod features like display.
Currently, you can send display events to the server and catch them on a server with events.
Also, you can send actions to perform on a client side.