Stop mobs from despawning

Discussion in 'Plugin Development' started by maxecito, Sep 2, 2015.

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

    maxecito

    Heyyww!

    Im spawning some entities at set locations!

    Code:
        for (int i = 0; i < 2; i++) {
           Silverfish silverfish = Bukkit.getWorld("DepartedWorld").spawn(murtlapSpawnup1, Silverfish.class);
           silverfish.setCustomName(ChatColor.YELLOW + "Murtlap");
           silverfish.setCustomNameVisible(true);
    
         }
    
         for (int i = 0; i < 11; i++) {
    
           Silverfish silverfish2 = Bukkit.getWorld("DepartedWorld").spawn(murtlapSpawnup2, Silverfish.class);
           silverfish2.setCustomName(ChatColor.YELLOW + "Murtlap");
           silverfish2.setCustomNameVisible(true);
    
         }
    
    So, they spawn (all fine) but the current problem is, they despawn upon leaving the area, when the chunck despawns they also do. Any1 has a solution? :3
    (Or a better idea how I can load the mobs on every onEnable() so you can encounter them always?) :3
     
  2. Offline

    Anrza

    Get chunk on ChunkUnloadEvent, get entities in chunk, check if they're a Murtlap silverfish, save them in config with the chunk as key, respawn them on ChunkLoadEvent.
     
Thread Status:
Not open for further replies.

Share This Page