aadnk / ProtocolLib

Provides read and write access to the Minecraft protocol with Bukkit.
GNU General Public License v2.0
287 stars 92 forks source link

How to get Entity ID from Packet #122

Closed Jimmeh94 closed 7 years ago

Jimmeh94 commented 7 years ago

My apologies for leaving this here, but I wasn't sure where else to put it xD

I'm completely new to ProtocolLib, but it seems extremely useful. I'm trying to stop the spawning of an entity to specific players (this way I can make instanced areas easily). Currently I've extended PacketAdapter and I'm overriding onPacketSending(), ensuring that the packet is of SPAWN_ENTITY_LIVING type. I was just wondering how I get the entity's id or UUID from this event once I get the PacketContainer.

I see I can: .getEntityModifier() .getIntegers() .getUUIDS() but I'm not entirely sure what I'm looking at there. I see that all this is done through reflection, so are the ".getIntegers()" all the integer fields within a given class?

Again, my apologies if I asked this question in the wrong place. There's a good amount of YouTube tutorials about ProtocolLib, but they all seem to be very specific (which of course will be handy in the future).

Thanks for your time and I'm excited to work with this awesome resource! :D

dadus33 commented 7 years ago

Hey, be sure to check http://wiki.vg. It contains a lot of handy information about current protocol specs. As for your issue, take a look at this: http://wiki.vg/Protocol#Spawn_Mob As you can see, the Entity ID is stored as an integer. So you should use the getIntegers() method and access the index 0.

Jimmeh94 commented 7 years ago

Ah okay. I see now. Thank you! :D