All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minecraft.server.PathfinderGoalSit Maven / Gradle / Ivy

package net.minecraft.server;

import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityTameableAnimal;
import net.minecraft.server.PathfinderGoal;

public class PathfinderGoalSit extends PathfinderGoal {

  private final EntityTameableAnimal entity;
  private boolean willSit;

  public PathfinderGoalSit(EntityTameableAnimal entitytameableanimal) {
    this.entity = entitytameableanimal;
    this.a(5);
  }

  public boolean a() {
    if (!this.entity.isTamed()) {
      return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
    } else if (this.entity.V()) {
      return false;
    } else if (!this.entity.onGround) {
      return false;
    } else {
      EntityLiving entityliving = this.entity.getOwner();

      return entityliving == null || ((!(this.entity.h(entityliving) < 144.0D) || entityliving.getLastDamager() == null) && this.willSit);
    }
  }

  public void c() {
    this.entity.getNavigation().n();
    this.entity.setSitting(true);
  }

  public void d() {
    this.entity.setSitting(false);
  }

  public void setSitting(boolean flag) {
    this.willSit = flag;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy