Custom Item Pathfinder not working?

Discussion in 'Spigot Plugin Development' started by KuramaStone, Apr 20, 2017.

  1. Hello I am fairly new to creating custom mobs or so and have this odd occurrence. I am not receiving any errors and I know that the entities's navigation is being set to this particular item, but it is not reacting. It is even walking away from it. I could not find a Pathfinder for finding Items (Drops), so I changed the PathfinderGoalNearestAttackableTarget and PathfinderGoalTarget to suit my needs.

    The files are a bit long, so I will put them in hastebin:
    PathfinderGoalNearestItem used to be PathfinderGoalNearestAttackableTarget
    https://hastebin.com/payuqofeku.java

    PathfinderGoalTargetItem used to be PathfinderGoalTarget
    https://hastebin.com/omojanibap.java

    here is where I set the goals for the entity:
    Code (Text):
            this.goalSelector.a(0, new PathfinderGoalFloat(this));
            this.goalSelector.a(2, new PathfinderGoalLinger(this, 12.00D));
            this.goalSelector.a(2, new PathfinderGoalStroll(this, 1.0D));
            this.goalSelector.a(3, new PathfinderGoalRandomLookaround(this));
            this.targetSelector.a(0, new PathfinderGoalNearestItem(this, true));
            this.targetSelector.a(1, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8f));
            this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, true));
    The PathfinderGoalLinger is also custom and is working fine.

    In PathfunderGoalNearestItem it broadcasts the name of the nearest item if present. Here is a picture of it doing so:
    [​IMG]

    I am using Spigot 1.8.8
     
  2. I believe I have reached the point where most devs who know how to help me are either too busy to help or everyone happens to look past my posts.

    Ah, yes, my reason for this: Bump
     
  3. I don't see PathFinderGoalTargetItem being used anywhere.

    You're also using a target selector to do the navigation.

    Also, when you do have a goal selector which navigates towards the item, make sure the mutex bits are set properly. Check other pathfinders to see what the movement bit flag is.
     
  4. PathfinderGoalTargetItem is what PathfinderGoalNearestItem extends from as it is an abstract class.

    The item would be the target in this case and seems to me like it should be under target selector, but as you seem to be more informed than I therefore I will take your word on it.

    I do not know what mutex bits are. Could you explain?
     
  5. Regardless after playing around with the navigation I discovered that setting what I assume to be a speed to a double has caused it to work as expected. Thanks
    Code (Text):
    this.e.getNavigation().a(this.d, 1.1D);
     
  6. The target selector, should (as it says) select the target of the entity. However, what should actually move the entity are the Goals. the goal selector should be the one actually moving the entity (though they may do other things, hence mutex bits, explained below).

    The mutex bits are a bit flag used to make sure other goals do not run if they do similar things (look up bit flags if you're unsure what they are). For example, 2 pathfinders that deal with movement may share a bit flag to make sure they do not override the existing navigation goal, and 2 pathfinders that make the entity attack may share a bit flag to make sure that the entity doesn't attack more than once in a tick.

    Hope this helps.