Get PathEntity of a certain Entity

Discussion in 'Plugin Development' started by CommonSenze, Apr 1, 2018.

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

    CommonSenze

    Hello all,

    Simple question with a hard answer (In my opinion), I need a method in the BukkitAPI or NMS to give me the PathEntity of a entity.

    I know nothing about this type of stuff (Bukkit API, NMS, and what their methods/fields do), so if theres a link to help further educate me on these things that would be helpful as well
     
  2. Offline

    PriorityHacker

    Hi , can you please post some code ? Maybe it will help .
    And to clarify you want to verify what is the entity ?
    Like : (Replace the (EntityType.MULE by an entity in the list of Bukkit Api Link --> ENTITYAPI))
    Code:
    //example you have an event
    
    public void exampleEvent(EntityExampleEvent event)
    {
    
    if(event.getEntity().getType().equals(EntityType.MULE){
    //DO SOME CODE HERE
    
    }
    
    }
     
  3. Offline

    CommonSenze

    @PriorityHacker
    The NPCEntity extends Entity player.
    Code:java
    1. public static NPCPath find(NPCEntity entity, Location to, double range, double speed) {
    2. if (speed > 1) {
    3. throw new IllegalArgumentException("Speed cannot be higher than 1!");
    4. }
    5.  
    6. try {
    7. PathEntity path = entity.world.a(entity, to.getBlockX(), to.getBlockY(), to.getBlockZ(), (float) range, true, false, false, true);//Error here.
    8. if (path != null) {
    9. return new NPCPath(entity, path, speed);
    10. } else {
    11. return null;
    12. }
    13. } catch (Exception e) {
    14. return null;
    15. }
    16. }
     
  4. Offline

    PriorityHacker

    Sorry @CommonSenze

    If the entity is a player then forget that it is impossible to force a player to move.

    That's why your code does not work .
     
  5. Offline

    CommonSenze

    @PriorityHacker
    Not for a player. For a entity. I did some researched and 1.7.10 Spigot had the method NMS#World#findpath that returned PathEntity. Where did it go? Is there someone I can ask like the makers of bukkit or some?
     
Thread Status:
Not open for further replies.

Share This Page