I can only spawn mobs manually near spawn

Discussion in 'Plugin Development' started by Scullyking, Jul 5, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Scullyking

    So I have an NPCManager class which handles to spawning and de-spawning of my NPCs from the game. NPCs are villagers with custom behaviours. So far I've been spawning these NPCs in the spawn of my world, and they've been appearing fine. And because they're villagers they don't de-spawn, even better!

    The problem comes when I try to spawn mobs quite far from spawn. I've tested out different distances and it's when I get pretty far (a couple of hundred blocks maybe?) when they stop spawning.

    At first I thought that these chunks we're unloaded when the server booted and so mobs couldn't be spawned in (bear in mind there's no error message). So I implemented a repeating task that would check all the NPCs that SHOULD be spawned and if they weren't spawned, attempt to spawn it. This had me thinking that if I walked my player to the desired location, they chunk would load, and the mob would spawn. However this does not work.

    Does anyone know about this? Is it a feature of bukkit or minecraft or something else? I would post code but there's a fair amount of it and I hope this issue isn't related to my code (the above description of the problem makes that fairly clear).

    Thanks
     
  2. Offline

    Tecno_Wizard

    @Scullyking, the repeating task is probably going to take a hit on server performance. Have you tried manually loading the corresponding chunks?
     
  3. Offline

    Scullyking

    @Tecno_Wizard
    I've fixed the issue. The repeating task is every 20 seconds so shouldn't have much effect on the server.
     
  4. Offline

    WesJD

    @Scullyking Repeating task isn't the best way to go. A better idea is if you try to spawn the entity and the chunk is unloaded, store them, and then spawn them when the chunk loads. When the chunk unloads, store them, and then spawn them again when it is loaded again.
     
Thread Status:
Not open for further replies.

Share This Page