ProtocolLib / Packets Help

Discussion in 'Spigot Plugin Development' started by BuildersRealm, May 29, 2015.

  1. Hi I want to get into packets. I have no idea where to start though. I have created packets/sent them without protocol. But now I have no idea how to send packets and edit them with Protocol. For instance, making a NPC. How can I create the NAMED_ENTITY_SPAWN then apply a skin to it. I'll appreciate any help I can get. Thanks


    ~Extended
     
    #1 BuildersRealm, May 29, 2015
    Last edited: May 30, 2015
  2. I'd suggest looking into ProtocolLib. It's possible to do this without using it but it'll make your life a LOT easier!
     
  3. Have you read anything. The title says ProtocolLib in it lol I just have no clue how to use it
     
  4. Did you know that ProtocolLib actually has a tutorial?
    [​IMG]
     
  5. Thats only for listening. Not for sending so..
     
  6. Sending is rather similar, with some extra steps at the beginning and end:
    Code (Java):
    // Create the packet
    packet = manager.createPacket(type);
    // Write the data
    packet.getSomeTypes().write(index, value);
    // Send the packet
    manager.sendServerPacket(player, packet);
     
  7. How can I find out what types to get for certain packets and what to write for them. Like what values do they need
     
  8. Have a look at PacketWrapper for easier use of ProtocolLib's packets. Simply include the classes for the packets you need (and AbstractPacket, of course) and it'll take care of the heavy lifting for you.

    If you'd rather manually write data to the packets you can, but PacketWrapper will still serve as a good example of what goes where, how to handle the fields in each type of packet.
     
  9. What it takes is a lot of reading :p
     
    • Agree Agree x 1
  10. Thanks! Though I have no Idea how to install if its just a dependency or do I have to decompile stuff. Sorry im a complete noob to packets/protocol
     
  11. Thx
     
  12. Yes and no. You could use it as a dependency, or you could copy the actual classes you need into your project so as to not force people wanting to use your plugin to install it as well.