Problem with doVillagers

Discussion in 'Performance Tweaking' started by Robert, Jul 14, 2013.

  1. Hi! I'm having some problem with the event doVillagers (as it's shown in timings). Sometimes the TPs of my server drop to 15-10, i've tracked down the problem to the doVillagers event since when i execute timings on laggy moments i get this on first place:

    94.76% Genubi - doVillages

    Genubi it's the towny world. So, i started to seek in the server for Villagers farms (http://www.minecraftwiki.net/wiki/Tutorials/Village_mechanics), i destroyed some and i implemented a cancellation for villagers spawning event in my server with this code:

    Code (Text):
    // No natural ocelot or villager spawn in Genubi.
        @EventHandler(priority = EventPriority.MONITOR)
        public void onCreatureSpawn(final CreatureSpawnEvent event) {
            if ((event.getEntityType().equals(EntityType.OCELOT) || event.getEntityType().equals(EntityType.VILLAGER))
                    && event.getLocation().getWorld().getName().equalsIgnoreCase("Genubi")
                    && !event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER_EGG)) {
                event.setCancelled(true);
            }
        }
    Wich helped a lot, but i'm still getting some lag for the same reason. So, my question is, how i can stop the server to spent ticks on the "doVillagers" thing? I searched into de spigot code and i found this:

    timings.doVillages.startTiming(); // Spigot
    this.villages.tick();
    this.siegeManager.a();
    timings.doVillages.stopTiming(); // Spigot

    In WorldServer.java, what exactly villages.tick() and siegeManager.a() do? The server could be triggering the event of siegeManager and this could be causing the TPs issues? (i've seen in the siegeManager code that the doors and villagers could be triggering it) Any further ideas to fix this? If it's possible, i don't want to remove all the Villagers from the world, just stop the event that lags the server. Thanks!
     
  2. md_5

    Administrator Developer

    Lets just say cancelling spawns is a bad idea, and Minecraft hates it.
    Instead remove the spawned entity next tick.
     
    • Informative Informative x 1
  3. K, will do. But, by your guess, that's the whole problem or there's something more with the siegeManager involved? Or maybye the villagers updating their items stocks? (I dunno really, just taking a shot).

    There's a way to disable the village siege? (Maybye removing the register of the manager?)