Packets

Discussion in 'Plugin Development' started by 1928i, Apr 4, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    1928i

    Very recently I've been exploring everything about Bukkit to the best of my abilities. I've been trying to learn everything I will need to develop a great plugin. And so far, things have been going pretty well. Then, I knew I had to get into some of the hard stuff such as NMS. But, for now, I really want to learn about packets. I read through some of the classes about packets, but they are really complicated. I want to test to see what everything does, but I have no idea where to start. And when I try to research about it, almost everything I find is completely outdated. Can someone please explain to me a little bit about how packets work and how I could begin playing around with them, it would be really helpful. Thanks.
     
  2. Offline

    Skionz

    @1928i Outgoing packets tell the client what to display/do (EX: Spawn a mob). Incoming packets tell the server what the client is doing (EX: breaking a block).
     
  3. Offline

    nverdier

    @1928i Well if you want to know how to send a packet to a Player, you just do the following:
    Code:
    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(<Packet here>);
     
  4. Offline

    1928i

    @Skionz @nverdier
    Thanks for the help so far. How do I edit a packet to make it do what I want to do. Also, how do I send a packet to the server?
     
  5. Offline

    nverdier

    @1928i Well you can't send a packet to the server, because you are running the plugin on the server.
     
  6. Offline

    1928i

    @nverdier Then how do you work with outgoing packets?
     
  7. Offline

    nverdier

    @1928i
     
  8. Offline

    1928i

    @nverdier Sorry, I meant incoming packets.
     
  9. Offline

    nverdier

    @1928i Easiest thing to do is use ProtocolLib.
     
  10. Offline

    1928i

    @nverdier One, I kind of want to make my own plugins and understand it fully. Two, how do I format a packet so that I can manipulate it?
     
  11. Offline

    nverdier

    @1928i You just create an instance of a class extending Packet.
     
  12. Offline

    1928i

    @nverdier Ok, I will try this out, I will make another post if I need anymore help.

    @nverdier Can I see an example of packets in action. For instance, how would you make it so some players see your name as blue, while others see it as red?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  13. Offline

    RingOfStorms

    Something like this is actually quite complex without the use of protocol lib, so if you want to do it all yourself with no library I would start with something like sending a basic particle or an entity animation.
     
Thread Status:
Not open for further replies.

Share This Page