Checking Zombie Is Dead!

Discussion in 'Plugin Development' started by Wantsome909, Aug 14, 2013.

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

    Wantsome909

    Code:java
    1. this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
    2. public void run() {
    3. Player[] players = main.this.getServer().getOnlinePlayers();
    4. for (Player p : players) {
    5. Location zom1 = new Location(p.getWorld(), 18, 65, 8);
    6. if(z.isDead()){
    7. Zombie z = (Zombie) zom1.getWorld().spawn(zom1, Zombie.class);
    8. z.setCustomName(ChatColor.RED + "Zombie");
    9. z.setCustomNameVisible(true);
    10. }
    11. }
    12. }
    13. }, 500, 500);


    I test it but it does not work any ideas why?
     
  2. Offline

    Axe2760

    Don't use Async for that. Use Sync.
     
    tommycake50 likes this.
  3. Offline

    xTrollxDudex

    Wantsome909
    Is it even possible to add colored mob names?
     
  4. Offline

    Axe2760

    xTrollxDudex I've done it many times in NBT edit, I don't see why it would be a limitation here.
     
  5. Offline

    tommycake50

    Yeah your using methods that aren't thread safe afaik.
    like axe said use Synchronous scheduling.
     
  6. Offline

    Conarnar

    You checked to see if the zombie was dead before you initialized it. Besides if it was just spawned why would you need to check if it was dead. Plus you don't need a cast if you are using that spawn method.
     
  7. Offline

    Wantsome909

    Conarnar i want it... like if a zombie spawn and then if repeats and if that zombie is not dead then don't spawn another one
     
  8. Offline

    ZeusAllMighty11

    Yes, they also support 32 characters where players support 20 I believe


    You can check if (!entity.isAlive()) or maybe it has an isDead() method
     
  9. Offline

    xTrollxDudex

  10. Offline

    ZeusAllMighty11

    xTrollxDudex

    Oh, I was thinking of the packet number. Packet20NamedEntitySpawn
     
    xTrollxDudex likes this.
Thread Status:
Not open for further replies.

Share This Page