Mobs Spawn and Lags

Discussion in 'Plugin Development' started by Someone_Like_You, Mar 8, 2014.

Thread Status:
Not open for further replies.
  1. Hello everyone, Im trying to create kind of MineZ zombies plugin Ive got my extended entity and I would like to spawn him in the world, but I would like to spawn that entity more inside towns (so like in big town = lots of zombies , small town = less) ... how would I do that?
    and for the lags, I have 3 delayed tasks that keep call themself as long as the player online (3 delayed tasks that run once in 190~210 ticks per player) and when Im on my testing server, after 1~3 mintues, Im getting PermGen error... Im calculating in this tasks the percentage of player health, taking XP levels from player, and taking XP from the bar of the player.. so my questions is :
    - Is it like that because my computer sucks? (My computer isnt the best, I geuss its because of it? )
    - Should I make 3 repeating delayed tasks for ALL players that online? instead of running 3 tasks per player? however then the server would have to do more calculations in same time...

    Another question : Im using CustomEntityType class to extend and register custom NMS entities, I would like to spawn normal vanilla entities aswell, not only the NMS ones, how can I do that? since its replacing all vanilla entities with the NMS ones
     
  2. Offline

    GameplayJDK

    Instead of using 3 delayed tasks you can use one SyncRepeatingTask
     
    Someone_Like_You likes this.
  3. GameplayJDK Thanks, I may use it, but is it better? since the server have to calculate more stuff in same time.
     
  4. Offline

    GameplayJDK

    It won't increase your servers performance, since it uses a new thread (Runnable).
     
    Someone_Like_You likes this.
  5. Offline

    GameplayJDK

    Do
    Code:java
    1.  
    2. player.getWorld().spawnEntity(new Location(player.getWorld(), x, y, z), EntityType.ZOMBIE);
    3.  

    to spawn a zombie at the location x, y, z
     
    Someone_Like_You likes this.
  6. GameplayJDK Thanks, however this isnt my problem :/, Ive extended EntityZombie and want to set the zombie spawn rate higher in some places... I have no idea how to do that... and what is better? creating a delayed task that keep call itself in a method , so like :
    public static void method(){
    for(player p : getOnlineplayers()...){
    p.setLevel(p.getLevel() * 100 / 20 + 7);
    }
    //200 ticks delay';
    method();
    }

    or doing repeating task?

    *Note that the code above isnt true, made it now for illustrate.
     
  7. Offline

    GameplayJDK

    Someone_Like_You likes this.
  8. GameplayJDK Il try that mob spawn soon, whats the diffrents between all the repeating tasks there is? is it the best (performance side) to use SyncRepeatingTask?
     
  9. Offline

    GameplayJDK

    Someone_Like_You
    I don't know what exactly the differences are, but as said, a syncRepeatingTask is Made for the case, that you wann to repeat something. Using the repeating one is just less coding, I think.
     
    Someone_Like_You likes this.
  10. GameplayJDK Il use it then :) but, this code do the same thing no?
    Code:java
    1. BukkitRunnable task = new BukkitRunnable(){
    2. @Override
    3. public void run() {
    4.  
    5. }
    6. };task.runTaskTimer(Main.getPlugin(), 5, 5);
     
  11. Offline

    GameplayJDK

    Someone_Like_You
    Looks like it would do the same. (I've not used a BukkitRunnable before, I used the scheduleSyncDelayedTask.)
     
    Someone_Like_You likes this.
  12. Offline

    GameplayJDK

Thread Status:
Not open for further replies.

Share This Page