It does not work "setTarget ()"

Discussion in 'Plugin Development' started by kotake545, Sep 26, 2014.

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

    kotake545

    Code:
    Creature entity = (Creature) spawnLocatin.getWorld().spawnEntity(
                        spawnLocatin, EntityType.ZOMBIE);
    ((Zombie)entity).setTarget((LivingEntity)player);
    It does not seem to be functioning.
    by craftbukkit1.6.4R0.1]
    What's wrong...?
     
  2. Offline

    Nateb1121

    kotake545

    Define, 'not working'. Like, not spawning? or has errors?
     
  3. Offline

    kotake545


    I'm sorry insufficient explanation...
    target has not been updated.
     
  4. Offline

    Nateb1121

    The setTarget() method is interesting. Be sure it's night, and that you're not in creative mode whilst testing.
     
  5. Offline

    AronTheGamer

    Why would you convert it to its superclass?
     
  6. Offline

    kotake545

    was not in creative mode.
     
  7. Offline

    Nateb1121


    So your issue is, that when using setTarget() the zombies won't attack you after being spawned? Are they just not going after you, or something else?
     
  8. Offline

    kotake545

    "((Zombie)entity).getTarget()" and "(LivingEntity)player"
    It became the same result
     
  9. Offline

    Konato_K

    No, it doesn't work, I don't know how much time has been broken but it doesn't work, the solution I made was making the mob walk in the direction of the player, but setTarget never worked for me.
     
  10. Offline

    xize

    setTarget only works for wolves as a switch between being angry and setting a target to some one I thought, not exactly sure though.

    from what I know for other entitys it doesn't work unless they 'may' have smilliarities with a wolf for example a Iron Golem can be angry on a player to however I don't think that was implemented in setTarget, there where some changes about setTarget() around 1.7 though.
     
  11. Offline

    fireblast709

    kotake545 how far away were you from the entity?
     
  12. Offline

    kotake545

    About 10m

    zombie is the aim players in the vicinity only

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  13. Offline

    fireblast709

    kotake545 have you tried debugging the EntityTargetEvent - perhaps it found a new target or lost the target due to an unknown reason
     
  14. Offline

    kotake545

    Code:
    // HashMap<Entity,Entity> CheckTarget;
    @EventHandler
        public static void EntityTargetEntity(final EntityTargetEvent event){
            if(CheckTarget.containsKey(event.getEntity())){
                if(event.getTarget()!=CheckTarget.get(event.getEntity())){
                    event.setCancelled(true);
                }
            }
        }
    Code:
    CheckTarget.put(entity,target);
    entity.damage(0.0D,target);
    entity.setVelocity(new Vector());
    If you specify a target in this way, everything is working.
    Please tell me if there are other ways.
     
Thread Status:
Not open for further replies.

Share This Page