NMS Pathfinder help

Discussion in 'Plugin Development' started by Scullyking, Apr 16, 2015.

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

    Scullyking

    I have a custom zombie as defined:

    Code:
    public class CustomZombie extends EntityZombie {
    
        public CustomZombie(org.bukkit.World world) {
            super(((CraftWorld) world).getHandle());
    
            List goalB = (List) Reflect.getPrivateField("b", PathfinderGoalSelector.class, goalSelector); goalB.clear();
            List goalC = (List) Reflect.getPrivateField("c", PathfinderGoalSelector.class, goalSelector); goalC.clear();
            List targetB = (List) Reflect.getPrivateField("b", PathfinderGoalSelector.class, targetSelector); targetB.clear();
            List targetC = (List) Reflect.getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();
    
            this.goalSelector.a(0, new PathfinderGoalFloat(this));
            this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, EntityChicken.class, 1.0D, true));
            this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
            this.goalSelector.a(6, new PathfinderGoalMoveThroughVillage(this, 1.0D, false));
            this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
            this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityChicken.class, 8.0F));
            this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
    
            this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true));
            this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true));
        }
       
    }
    However it isn't attacking me in-game. It is spawning, and it is spawning the custom zombie because it only looks at chickens (as a set in the PathfinderGoalLookAtPlayer overwrite).

    Another question I have, what are the numbers in the first parameter in a(). The ones that read 0, 4, 5, 6, 7, 8, 8, etc. I want to add new pathfinders to my zombie, but I have no idea what this int should be.
     
  2. Offline

    ark9026

  3. Offline

    Europia79

    Good question. I'm not exactly sure, but I would guess that they are some kind of priority number, with zero being the highest priority ?

    I'm not sure if clearing all the pathfinders first will solve your problem, but it's worth a try.

    Here it is the method from Teeepeee's tutorial:
    https://github.com/Europia79/Extrac...raction/nms/v1_7_R4/CraftHostage.java#L39-L52
     
  4. Offline

    Scullyking

    @ark9026 @Europia79

    I have already overwritten default pathfinders. This is proven because my custom zombie looks at chickens, not humans. Because I have overwritten it to look at chickens not players.
     
Thread Status:
Not open for further replies.

Share This Page