Development Assistance NMS goal problems

Discussion in 'Plugin Help/Development/Requests' started by KiF, Feb 7, 2015.

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

    KiF

    I'm trying to edit the pathfinding goals for villagers. Specifically:
    Code:
    this.goalSelector.a(1, new PathfinderGoalAvoidTarget(EntityHuman.class, thing, 8.0F, 0.6D, 0.6D));
    However, I'm not sure what predicate I need to put where it says "thing" (it's a placeholder).
     
  2. Offline

    ReadySetPawn

    The first arg should be your custom entity class and the second arg should be the entity you want them to avoid. In your case, it's EntityHuman.class.
     
  3. Offline

    KiF

    @ReadySetPawn That didn't work, although I may have done it wrong. Here's the code now:
    Code:
    this.goalSelector.a(1, new PathfinderGoalAvoidTarget(SSCustomEntityType.class, EntityHuman.class, 8.0F, 0.6D, 0.6D));
     
  4. Offline

    ReadySetPawn

    I suggest you put your pathfinders in the constructor for your custom entity class and use "this" for the first arg.
     
  5. Offline

    KiF

    @ReadySetPawn It's already in the constructor. I also tried putting this for the first argument, but still didn't fit. (Line 17)
    Constructor:
    Code:
    public SSCustomEntityVillager(World world) {
            super(world);
            try {
                    Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
                    bField.setAccessible(true);
                    Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
                    cField.setAccessible(true);
                    bField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
                    bField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
                    cField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
                    cField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
                } catch (Exception exc) {
                    exc.printStackTrace();
                    // This means that the name of one of the fields changed names or declaration and will have to be re-examined.
                }
            this.goalSelector.a(0, new PathfinderGoalFloat(this));
            this.goalSelector.a(1, new PathfinderGoalAvoidTarget(this, EntityHuman.class, 8.0F, 0.6D, 0.6D));
            this.goalSelector.a(1, new PathfinderGoalLookAtTradingPlayer(this));
            this.goalSelector.a(2, new PathfinderGoalMoveIndoors(this));
            this.goalSelector.a(3, new PathfinderGoalRestrictOpenDoor(this));
            this.goalSelector.a(4, new PathfinderGoalOpenDoor(this, true));
            this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 0.6D));
            this.goalSelector.a(6, new PathfinderGoalMakeLove(this));
            this.goalSelector.a(7, new PathfinderGoalTakeFlower(this));
            this.goalSelector.a(8, new PathfinderGoalPlay(this, 0.32D));
            this.goalSelector.a(9, new PathfinderGoalInteract(this, EntityVillager.class, 5.0F, 0.02F));
            this.goalSelector.a(9, new PathfinderGoalRandomStroll(this, 0.6D));
            this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
        }
     
  6. Offline

    ReadySetPawn

    What version of spigot are you using and what errors are you getting?
     
  7. Offline

    nverdier

  8. Offline

    KiF

    I'm using a custom CB 1.8.1. The error for that line says:
    I know that it wants EntityCreature, Predicate, float, double, double for its args.
     
  9. Offline

    ReadySetPawn

    Sorry. Thought this was the spigot forums for a second.

    Maybe try having the second arg as an entity?
     
  10. Offline

    KiF

    @ReadySetPawn I've now tried putting an entity, although I wasn't sure what entity. However, it did count as an entity, but still gave me the same error.
    Updated Code:
    Code:
    this.goalSelector.a(1, new PathfinderGoalAvoidTarget(EntityHuman.class, Entity.this, 8.0F, 0.6D, 0.6D));
     
Thread Status:
Not open for further replies.

Share This Page