Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-3081

Custom name is not set on an entity at the time of CreatureSpawnEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • N/A

      [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.

            Unassigned Unassigned
            Zhro Matt D.
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: