[1.8] Make mob attack another mob

Discussion in 'Spigot Plugin Development' started by LucaBoh, May 21, 2016.

  1. Hello everyone!

    I searched a lot on the net, but I've found only old threads talking about this.

    Is possibile to make a mob attack another mob (e.g. Zombie attacking another Zombie, Spider -> Skeleton etc.), as if the attacked was a player?

    I tried with Entity.setTarget(), but it seems working only with Player targets, in my case.The target is correctly set, but the zombie doesn't move/attack.

    Maybe I need to use NMS classes?

    Edit: I noticed that skeletons attack other entities, while zombies and spiders no.
     
    #1 LucaBoh, May 21, 2016
    Last edited: May 21, 2016
  2. You can try to use the setTarget(LivingEntity entity) method. This allows you to set the mob's target to any living entity. If it's a hostile creature, it will attacked the set target. If it's a non-hostile entity, it will follow the set entity. Find more about it at https://hub.spigotmc.org/javadocs/spigot/ and find the Creature interface
     
  3. I tried it (I specified that), but, for example, a zombie doesn't attack another zombie...