Spawn Zombie and set target

Discussion in 'Plugin Development' started by kmccmk9, Jun 29, 2013.

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

    kmccmk9

    Hello, I am trying to set a spawned zombie's target. I can successfully get one to spawn but I can't figure out how to set its target. Thanks for any help

    Code:java
    1. World world = player.getWorld();
    2. world.spawnCreature(to, CreatureType.ZOMBIE);
     
  2. Offline

    r0306

    kmccmk9
    Since setTarget() is a function of the LivingEntity class, you would store the zombie object and use it to call up that function.
    Code:
    LivingEntity zombie = world.spawnCreature(to, CreatureType.ZOMBIE);
    zombie.setTarget(poorVictim);
     
  3. Offline

    kmccmk9


    Oh that makes sense. I'm gonna give that a try thanks.

    r0306
    I'm getting an error that LivingEntity does not have the function setTarget
     
  4. Offline

    r0306

    kmccmk9
    Sorry. I meant the Creature class.
     
  5. Offline

    kmccmk9

    Ok but if I change it to creature how do I spawn it?
     
  6. Offline

    SgtPunishment

    The whole setTarget doesn't actually work
     
  7. Offline

    kmccmk9

    So there is no way to tell the monster what to go towards?
     
  8. Offline

    Wingzzz

    kmccmk9
    Could perhaps use damaging to aggro the mob on a player
     
  9. Offline

    SgtPunishment

    If you were using NMS you would set the goal finder or something to that extent, or you could try damaging the zombie and set the damager as the player but set the damage to zero... so the mob will just aggro
     
  10. Offline

    Scyntrus

    I strongly suggest not working with Zombies. They have some interesting AI that makes them quite a pain to control. Instead, I suggest working with a PigZombie. They still share some of the "interesting AI" but are a bit easier to work with.
     
  11. Offline

    kmccmk9

    Okay thanks. However, I still can't seem to figure out how to set their target.
     
  12. Offline

    Scyntrus

    Well, setTarget does set Creature's target. However, if you want to use something more reliable to move a Creature, you'll have to go into NMS code and use Navigation.
     
Thread Status:
Not open for further replies.

Share This Page