Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. package net.logan31.poppiecraft.network;
  2.  
  3.  
  4. import net.minecraftforge.fml.common.network.NetworkRegistry;
  5. import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
  6. import net.minecraftforge.fml.relauncher.Side;
  7.  
  8. /**
  9. * Created by johanjulien on 09/01/2018.
  10. */
  11. public class PacketHandler {
  12.  
  13. /**
  14. * The instance of packet handler, for use to be able to send messages
  15. */
  16. public static SimpleNetworkWrapper INSTANCE;
  17.  
  18. /**
  19. * The unique ID tracker for our packets
  20. */
  21. private static int ID = 0;
  22.  
  23. /**
  24. * Get the next id
  25. *
  26. * @return The next id
  27. */
  28. private static int nextID() {
  29. return ID++;
  30. }
  31.  
  32. /**
  33. * Register all of our network messages on their appropriate side
  34. *
  35. * @param channelName
  36. * The name of the network channel
  37. */
  38. public static void registerMessages(String channelName) {
  39. INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName);
  40.  
  41. // Server packets
  42. INSTANCE.registerMessage(PacketGetWorker.Handler.class, PacketGetWorker.class, nextID(), Side.SERVER);
  43.  
  44.  
  45. // Client packets
  46. INSTANCE.registerMessage(PacketReturnWorker.Handler.class, PacketReturnWorker.class, nextID(), Side.CLIENT);
  47.  
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement