1.17.x How do you listen for an entity being loaded?

Discussion in 'Spigot Plugin Development' started by Xemor, Jul 8, 2021.

  1. Hi, is ChunkLoadEvent the only way of listening for entities being loaded into the world?
     
  2. Strahan

    Benefactor

    There is an EntitySpawnEvent as well.
     
  3. Does this work on mobs being reloaded after a restart?
     
  4. Strahan

    Benefactor

    Ah yea; no, I do not believe it would.
     
  5. Load + spawn being paired should be enough to notice every entity being loaded in.
     
  6. I'm getting an issue where the e.getChunk().getEntities() array is always empty?
     
  7. There was a bug fix for this a while ago, go update Spigot or w/e you use.
     
  8. This is a known bug in spigot 1.17. There is a PR open which fixes this and also adds new Entities(Un)LoadEvent and methods. You can either wait for it to be merged or create a schedular in the ChunkLoadEvent which runs a few ticks later and do then the entity logic.
     
  9. You use your ears boss man.