PathFinding for 1.15

Discussion in 'BungeeCord Plugin Development' started by Chronoxx98, Apr 2, 2020.

Thread Status:
Not open for further replies.
  1. Hello,
    This might be a taught question, I am making some Custom Entities and I would like to use pathfinding to make them walk/run to a given position in the world. I have searched and tried a lot today but nothing seems to be working for 1.15.

    Also, I would like to remove the other goals from the entity. I have tried :
    Code (Text):
    List targetC = (List)Util.getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();
    With:
    Code (Text):

    public static Object getPrivateField(String fieldName, Class<PathfinderGoalSelector> clazz, Object object) {
        Field field;
        Object o = null;
        try
        {
            field = clazz.getDeclaredField(fieldName);
            field.setAccessible(true);
            o = field.get(object);
        }
        catch(NoSuchFieldException e)
        {
            e.printStackTrace();
        }
        catch(IllegalAccessException e)
        {
            e.printStackTrace();
        }
        return o;
    }

    @Override
    public void setOnFire(int i){

    }
     
    But it says I can't cast an Object to a List.
    So far, this is my Custom Entity (working):

    Code (Text):

    public class MyZombie extends EntityZombie {

        public MyZombie(org.bukkit.World world, Player player) {
            super(((CraftWorld) player.getWorld()).getHandle());

    //        List goalB = (List)Util.getPrivateField("b", PathfinderGoalSelector.class, goalSelector); goalB.clear();
    //        List goalC = (List)Util.getPrivateField("c", PathfinderGoalSelector.class, goalSelector); goalC.clear();
    //        List targetB = (List)Util.getPrivateField("b", PathfinderGoalSelector.class, targetSelector); targetB.clear();
    //        List targetC = (List)Util.getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();

            this.setCustomName(CraftChatMessage.fromStringOrNull(ChatColor.GOLD + "Hey :)"));
            this.setCustomNameVisible(true);
            this.setBaby(false);
    //        this.setNoAI(true);

            Zombie zombie = (Zombie)this.getBukkitEntity();
            // Do some stuff with the zombie

        }
     
    I have looked at API's also (like Citizens, PathFinder API https://www.spigotmc.org/resources/pathfinderapi.45879/) but I can't figure out how to make them work.

    Thank you very much,
    Chrono
     
  2. You are searching for help in the wrong subforum. Refer to spigot plugin development.
     
  3. Oh very sorry, I was sure that I clicked on Plugin development

    Envoyé de mon RMX1931 en utilisant Tapatalk
     
Thread Status:
Not open for further replies.