Check if all zombies dead?

Discussion in 'Plugin Development' started by kmccmk9, Jul 17, 2013.

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


    Hello, I am trying to see if all my spawned zombies are dead. What is the best way to do that? Basically the goal is to kill them all so I'm trying to check if they're all dead. I do already have a listener set up. This is how I'm spawning them:
    1. while (i <= 10) {
    2. Entity zombie = world.spawnEntity(to, EntityType.PIG_ZOMBIE);
    3. ((Creature) zombie).setTarget((LivingEntity) chicken);
    4. areaRadius = 15; //Or any radius you want
    5. minRadius = 10; // This would give me a radius between 500 and 1000
    6. t = Math.random() * Math.PI;
    7. radius = Math.random()*(areaRadius - minRadius) + minRadius;
    8. x = Math.cos(t) * radius;
    9. y = Math.sin(t) * radius;
    10. z = Math.cos(t) * radius;
    11. i++;
    12. }
  2. Offline


    Add the zombies' IDs to a list. Listen to EntityDeathEvent, and if the entity's ID is in your list, remove it from the list and then check if the list is empty.
  3. Offline


    Thanks for the reply. What type should the list be though? Entity?

    EDIT: I'm trying it with a string list. However, how would I find the index of the entity id in the list?
  4. Offline


    It would be a string list because you're using their ID. You wouldn't need to get the index for this solution, just use the contains() and remove() methods.
  5. Offline


  6. Offline


    Oh yeah, it would probably be int. I was thinking of player names.
  7. Offline


    adam753 how would you add the zombie to a list
  8. Offline


    Wantsome909 ArrayList<Integer> zombies = new ArrayList<Integer>();
  9. Offline



    I think it should be getEntityId() but I'm nor sure what the difference is...
Thread Status:
Not open for further replies.

Share This Page