Slime Navigation

Discussion in 'Plugin Development' started by ShadowLAX, Apr 17, 2015.

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

    ShadowLAX

    Hello bukkit;

    I have been looking into NMS and learning about pathfinders recently. I have experimented and created mobs who uses custom pathfinders to follow a player/entity using Navigation.a(). However, the slime and magma cube do not seem to respond to that method. I tried looking into why, but it went really deep into obfuscated code that I've spent a couple days looking into it with almost no result. I figure it has something to do with the custom ControllerMove they both use, but I thought I would ask here to see if anyone knows how to correctly do this before I spend more time looking through the NMS and trying to figure it out. Any help would be much appreciated, and thanks in advance!
     
  2. Offline

    nverdier

    Please post code.
     
  3. Offline

    ShadowLAX

    @nverdier
    Code:
        public static class PathfinderGoalGotoTile extends PathfinderGoal {
    
            private EntityInsentient entity;
            private UUID id;
    
            public PathfinderGoalGotoTile(EntityInsentient entity, UUID id) {
                this.entity = entity;
                this.id = id;
            }
    
            @Override
            public boolean a() {
    
                if (Bukkit.getPlayer(id) == null) {
                    return false;
                }
    
                Location tarloc = Bukkit.getPlayer(id).getLocation();
                Location eloc = entity.getBukkitEntity().getLocation();
                if (eloc.getWorld() == tarloc.getWorld() && eloc.distanceSquared(tarloc) > 15 * 15) {
                    entity.getBukkitEntity().teleport(Bukkit.getPlayer(id));
                }
              
                this.c();
              
                return true;
            }
    
            @Override
            public void c() {
                Location l = Bukkit.getPlayer(id).getLocation();
                this.entity.getNavigation().a(l.getX() + 1, l.getY(), l.getZ() + 1, 1.3D);
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page