[SPIGOT-582] Player spawn egg event Created: 17/Feb/15  Updated: 14/Apr/19

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor
Reporter: MattBDev Assignee: md_5
Resolution: Unresolved Votes: 0
Labels: bukkit, craftbukkit, entity, mobspawning


 Description   

It would be extremely helpful if there was an event that checked specifically if a mob was spawned from a spawn egg and to get the player who spawned it in.
It is possible at the moment to check if when a mob is spawned, to see if it was from a spawn egg but you can't see who spawned it.



 Comments   
Comment by blablubbabc [ 17/Feb/15 ]

Possible workaround you could use:
Listen to the PlayerInteractEvent and check if the player is right clicking a block with the spawn egg in hand. The assumption is that this will always trigger a related CreatureSpawnEvent right afterwards.

So to get the connection from CreatureSpawnEvent to the related PlayerInteractEvent, you could temporary store the information you need from the PlayerInteractEvent in a data structure (like a hashmap), and then get and remove it from there again inside the CreatureSpawnEvent.

The same steps should work for detecting when a creature is spawned because the player right clicked another entity while having a spawn egg in hand.

Generated at Mon Apr 07 22:29:15 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.