Discussion in 'Plugin Development' started by ZodiacTheories, Jul 21, 2014.

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


    Hi, I am listening to the CreatureSpawnEvent and then checking if the SpawnReason is breeding. Is there any way that I can get the Player that bred the animals?

  2. Offline


    Idk if there is a creature feed event, but if there isn't you'll have to store the player in a list using a PlayerInteractEvent when they click on an animal with food.
  3. Offline


    You can track the PlayerInteractEntityEvents and then match the interacted entities type with the newly spawned one. Or you can just try to find the Player closest to the spawned creature.

    Or combine both. You dont have a guarantee that you got the right player, but it is most likely.
  4. Offline


    and if two different players fed the two different animals?
  5. Offline


  6. Offline


    If there were a method to get who bred the animals, how would it handle having two different players feeding the two animals?
  7. Offline


    ZodiacTheories hintss is pointing out the fact that two people can use wheat on the two different animals and still have it result in a breeding event. With the method mentioned above you will get the closest player to the spawned entity and not both players.
    You will have to store players in a List after listening for when they interact with a breedable animal. I would say that this method is inefficient but it's the only way I can think of.

    There might be something you can do with metadata in order to add the last feeder's uuid to the animal, and listen to the CreatureSpawnEvent to get the closest entity to the spawned entity. If I'm not mistaken, the baby animal spawns in the same vector as the parent, which would allow you to read that metadata.
  8. Offline


    Last I read, the baby spawns in between the two parents
  9. Offline


Thread Status:
Not open for further replies.

Share This Page