Afraid Entity Pathfinding?

Discussion in 'Plugin Development' started by BaddCamden, Nov 3, 2020.

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

    BaddCamden

    I am currently making an addition to my plugin which allows endermen to have a more sophisticated pathfinding and also they throw blocks. However, one of the situations the enderman (which is caused by low health) would be in requires that it is afraid of the player. How do I do this? I couldn't find any threads on this so, I think this is a really obscure problem.


    (Also, I know that some of my code is spaghetti code, and I plan on fixing that later during optimization. Currently, I am just working on how to get it to work)

    if(targetBlock != null) {
    if(DistanceBetween(targetBlock.getLocation(), entityLoc) < EtoTDis) {
    targetNew = entity.getLocation().getWorld().spawn(entity.getLocation(), ArmorStand.class);
    targetNew.setCustomNameVisible(false);
    ((ArmorStand) targetNew).setBasePlate(false);
    ((ArmorStand) targetNew).setArms(false);
    ((ArmorStand) targetNew).setVisible(false);
    targetNew.setInvulnerable(true);
    ((LivingEntity) targetNew).setCanPickupItems(false);
    targetNew.setGravity(false);
    ((ArmorStand) targetNew).setSmall(true);
    targetNew.teleport(targetBlock.getLocation());
    ((Enderman)entity).setTarget((LivingEntity) targetNew);
    } else {
    targetNew = targetOld;
    ((Enderman)entity).setTarget((LivingEntity) targetNew);
    }
    }
    } else {
    targetNew = targetOld;
    //I need it here...
    }

    For extra information, normally wolves scare skeletons and cats scare creepers, so I want to do that with the player and the enderman.
     
    Last edited: Nov 5, 2020
  2. Offline

    BaddCamden

    bump* (I think this is how you bump, I don't use forums often)
     
  3. Offline

    BaddCamden

    I am going to assume there isn't an answer to this, so I will not be adding anymore bumps besides this one.
    Bump + Update
     
Thread Status:
Not open for further replies.

Share This Page