Checking is my spawned entity is dead?

Discussion in 'Plugin Development' started by kevinspl2000, Nov 2, 2013.

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

    kevinspl2000

    Okay so I have spawned an entity using
    world.spawnEntity(loc, EntityType.PIG_ZOMBIE);
    Now, I want to check if the entity is dead then do something if it is..
    I have been told I need to store the entity ID somewhere. But how would java know if its the spawned entity it is referring to? How would I check if the entity is dead? Also where would I store the id of the entity?
    Example code please?
     
  2. Offline

    adam753

    Code:
    Entity e = world.spawnEntity(loc, EntityType.PIG_ZOMBIE);
     
    //Later
    if(e.isValid()) {
    
     
  3. Offline

    kevinspl2000

    adam753
    Thanks man!
    But would that spawn an entity too?
     
  4. Offline

    GusGold

    Yes, the code
    Code:java
    1. Entity e = world.spawnEntity(loc, EntityType.PIG_ZOMBIE);
    both spawns the entity and saves the Entity object returned to the variable, 'e'
     
    adam753 likes this.
Thread Status:
Not open for further replies.

Share This Page