[SPIGOT-3081] Custom name is not set on an entity at the time of CreatureSpawnEvent Created: 20/Feb/17  Updated: 27/Dec/18  Resolved: 27/Dec/18

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

Type: Bug Priority: Minor
Reporter: Matt D. Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: NameTag, entity, name
Environment:

N/A



 Description   

[CODE]@EventHandler
public void onEntitySpawn(
   CreatureSpawnEvent event)
{
   System.out.println("Name: " + event.getEntity().getName());
   System.out.println("Custom: " + event.getEntity().getCustomName());[/CODE]
 
When I name an egg "A MOB NAMED BOB" and spawn the egg I get the following output:
 
[code]2017-02-20 09:16:06 [INFO] Name: Zombie
2017-02-20 09:16:06 [INFO] Custom: null[/code]
 
I want to perform a particular action when a mob with a certain name is spawned. To test this I named an egg in an anvil and watched the output with the above code. According to this error, it seems that there is no way to determine the name of a mob at the time it's spawned.
 
I verified that both of these function work correctly by then monitoring EntityDamageByEntityEvent and outputting the mob's name and custom name; both of which are correct according to what I named the egg. The problem is that I can't query this information during the CreatureSpawnEvent.
 
How am I to perform my desired action? Is this a bug or a feature.



 Comments   
Comment by md_5 [ 27/Dec/18 ]

This was fixed by Mojang in some update

Comment by Matt D. [ 01/Mar/17 ]

I just wanted to mention that custom names are set for getName() and getCustomName() when an entity is summoned rather than spawned with an egg:

/summon Skeleton ~ ~ ~ {CustomName:"Skalington",Size:0.5

Would it be possible to provide a means of discovering this information for SpawnReason.SPAWNER_EGG? For example, this information would be contained as the name of the item stack of the egg being used to spawn the mob.

Comment by md_5 [ 20/Feb/17 ]

This is unlikely to be able to be fixed because of how the event is called

Generated at Sat Dec 13 13:39:15 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.