Solved How to block the AI or Guardians Jump

Discussion in 'Spigot Plugin Development' started by PSminKo, Jun 21, 2016.

  1. When the Guardian this out of the water he is jumping, the jumps is because your AI, how to block this?

    Code (Text):
    public class CustomGuardian extends EntityGuardian {

        @SuppressWarnings({ "rawtypes" })
        public CustomGuardian(World world ) {
             List goalB = (List)getPrivateField("b", PathfinderGoalSelector.class, goalSelector); goalB.clear();
             List goalC = (List)getPrivateField("c", PathfinderGoalSelector.class, goalSelector); goalC.clear();
             List targetB = (List)getPrivateField("b", PathfinderGoalSelector.class, targetSelector); targetB.clear();
             List targetC = (List)getPrivateField("c", PathfinderGoalSelector.class, targetSelector); targetC.clear();
             this.goalSelector.a(7, this.goalRandomStroll = new PathfinderGoalRandomStroll(this, 1.0D, 80));
             this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
             this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityGuardian.class, 12.0F, 0.01F));
             this.goalSelector.a(9, new PathfinderGoalRandomLookaround(this));

        public static Object getPrivateField(String fieldName, Class clazz, Object object) {
            Field field;
            Object o = null;

                field = clazz.getDeclaredField(fieldName);


                o = field.get(object);
            catch(NoSuchFieldException e)
            catch(IllegalAccessException e)

            return o;

    #1 PSminKo, Jun 21, 2016
    Last edited: Jun 22, 2016
  2. It's AI,

    Code (Text):
    this.goalSelector.a(7, this.goalRandomStroll = new PathfinderGoalRandomStroll(this, 1.0D, 80));
    The 80 is the time between movement.

    Not sure how to stop them jumping around like:
    Image Source: Google Images
    • Funny Funny x 1
    • Optimistic Optimistic x 1
  3. Yes, that leap that I want to block.

    When we change the 80 to 1 or 500 nothing changes.
  4. new LookForWaterSeizure(this, Stroll.valueOf("Crazy"));
    • Funny Funny x 2
    • Like Like x 1
  5. To solve, i put the guardian on the minecart, Thanks, all