1.15.2 Pathfinding for 1.15

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

  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();
    Code (Text):

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

    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.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,

    Envoyé de mon RMX1931 en utilisant Tapatalk
  2. Hey !
    It's due to a NMS Remapping, i'm exploring source code and will send you the corrects fields names when I would have it.
  3. @PulsePvP_ Can you send them in this topic when you've found them? Would be interesting so I'd like to have them too!
  4. Yes! Here's the whole code in the EntityZombie class of Spigot 1.15.2 :
    Code (Text):

     protected void initPathfinder() {
        this.goalSelector.a(4, new a(this, 1.0D, 3));
        this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, (Class)EntityHuman.class, 8.0F));
        this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
      protected void l() {
        this.goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false));
        this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, true, 4, this::ey));
        this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D));
        this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[] { EntityPigZombie.class }));
        this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
        if (this.world.spigotConfig.zombieAggressiveTowardsVillager)
          this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false));
        this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
        this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, 10, true, false, EntityTurtle.bw));
      protected void initAttributes() {
        getAttributeMap().b(d).setValue(this.random.nextDouble() * 0.10000000149011612D);

    And the fields for PathfinderGoalSelector.class ( 1.15.2 ):
    Code (Text):
      private final Map<PathfinderGoal.Type, PathfinderGoalWrapped> c = new EnumMap<>(PathfinderGoal.Type.class);
      private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();
      private final GameProfilerFiller e;
      private final EnumSet<PathfinderGoal.Type> f = EnumSet.noneOf(PathfinderGoal.Type.class);
      private int g = 3;

    If you tell me the spigot version needed for the code you posted, I can try to get the new fields names and make it works.
    • Like Like x 1
  5. Last version ? please