1.9 PathEntity.a() not working. Needing help

Discussion in 'Plugin Development' started by xxmobkiller, Mar 2, 2016.

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

    xxmobkiller

    I am making my own NPC plugin when I started to update my old work I came across a small problem. Here is the problem, I am calling PathFinder from NPCEntity all it is just PathFinder pathfinder;

    The method a(IBlockAccess, EntityInsentient, BlockPosition, float) in the type Pathfinder is not applicable for the arguments (ChunkCache, NPCEntity, BlockPosition, float)

    Then here is the code;

    The NPCEntity has this Extend and Impleneted;

    Code:
    public class NPCEntity extends EntityPlayer implements NPC {
    
    Code:
        public static NPCPath find(NPCEntity entity, Location to, double range, double speed) {
            if(speed > 1) {
                throw new IllegalArgumentException("Speed cannot be higher than 1!");
            }
    
            try {
                BlockPosition posFrom = new BlockPosition(entity);
                BlockPosition posTo = new BlockPosition(to.getX(), to.getY(), to.getZ());
                int k = (int) (range + 8.0);
    
                ChunkCache chunkCache = new ChunkCache(entity.world, posFrom.a(-k, -k, -k), posFrom.a(k, k, k), 0);
                PathEntity path = entity.getPathfinder().a(chunkCache, entity, posTo, (float) range);
                if(path != null) {
                    return new NPCPath(entity, path, speed);
                } else {
                    return null;
                }
            } catch(Exception e) {
                return null;
            }
        }
     
  2. Offline

    teej107

    @xxmobkiller You are supplying the wrong Object types for the method :p
     
  3. Offline

    xxmobkiller

    @teej107 What should I make them use. Cause It was working in 1.8 but now it not working I update all the other stuff but just this one problem has me on the edge of me mind.
     
  4. @xxmobkiller since you are using nms code you should be aware of the fact, that method names can change willy nilily with every new version. so you either stay with the version you had before or you search for the method you need by going through all the methods there are for pathfinder (which can be a pain in the ass if you dont know what you are searching for). but to me it seems like they changed from chunkcache to iblockaddress. so you should figure out what a iblockaddress is and how you can replace the chunkcache in your code with it. maybe there is some way to get the iblockaddress of a chunkcache idk.
     
  5. Offline

    teej107

     
  6. Offline

    xxmobkiller

    @Shmobi @teej107 I'm just going to look trough the ChunkCache and compair 1.9 with 1.8 and see whats different and then modify my coding to work with the new updated version. But yeah this should be lots of fun :p
     
  7. @xxmobkiller shouldn't be to hard. But just from the looks i believe that they removed the method you used in 1.8 or lets better say they altered it, so that the first parameter is iblockaccess is. So what you should search for is how to get a IBlockAccess instance, which provides the data you need to get the same result as you got from the old method using ChunCache
     
  8. Offline

    xxmobkiller

    Well This is how I fixed the problem but still Its not working so I think its just my coding sucks.

    Code:
        public static NPCPath find(NPCEntity entity, Location to, double range, double speed) {
            if(speed > 1) {
                throw new IllegalArgumentException("Speed cannot be higher than 1!");
            }
    
            try {
                BlockPosition posFrom = new BlockPosition(entity);
                BlockPosition posTo = new BlockPosition(to.getX(), to.getY(), to.getZ());
                int k = (int) (range + 8.0);
    
                ChunkCache chunkCache = new ChunkCache(entity.world, posFrom.a(-k, -k, -k), posFrom.a(k, k, k), 0);
                PathEntity path = entity.getPathfinder().a(chunkCache, ((EntityInsentient)((CraftLivingEntity)entity.getBukkitEntity()).getHandle()), posTo, (float) range);
                if(path != null) {
                    return new NPCPath(entity, path, speed);
                } else {
                    return null;
                }
            } catch(Exception e) {
                return null;
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page