Solved Custom NPCs despawning when player loads chunk

Discussion in 'Spigot Plugin Development' started by SeanTMG, Jul 13, 2020.

  1. So I'm making a custom NPC system (I was previously using the Citizens API, but that has huge issues, it was a much better solution to just make my own), however, when a player unloads the entities in the chunk that the entity was spawned in, the custom npc gets despawned and there's no "PlayerLoadChunkEvent" to tell me when to respawn the entity for the player. (This is all using NMS). There's also an issue where when a player spawns outside of the entity view range for an NPC, the NPC won't be spawned for the player.

    Strangely, the armor stand entities don't despawn, but the players do.

    Has anyone run into this issue before? And does anyone know how to solve it? Help appreciated.

    EDIT: Messed up title, "loads chunk" should be "unloads chunk"

    UPDATE: Fixed this by using PlayerMoveEvent and calculating the distance between the NPC and the player, removing/adding it as needed
     
    #1 SeanTMG, Jul 13, 2020
    Last edited: Jul 14, 2020