Removing Entity after Player death

Discussion in 'Plugin Development' started by Pr0_fAssEr, Mar 7, 2015.

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


    I want to remove entity(Wolf) when the owner of the wolf dies.

    I Tryed like 10 codes and noone works please can you help me ?
  2. Offline


    What have you tried? We don't want to give you code that you've already attempted before being.
  3. Offline


    Last edited by a moderator: Mar 7, 2015
  4. Try adding some debug messages.
  5. Offline


  6. Offline


    p.getWorld().getEntitiesByClass(Wolf.class) will get every Wolf entity in the world.

    Therefore, you want to do something like this inside your event method.

    for (Wolf wolf : p.getWorld().getEntitiesByClass(Wolf.class)) {
        // If the wolf isn't tamed, or the wolf does not belong to the player that died, then continue
        if (!wolf.isTamed() || !wolf.getOwner().equals(p)) continue;
        // So the code here will only execute if the above statement returns true
Thread Status:
Not open for further replies.

Share This Page