Paper/src/main/java/net/minecraft/server/PathfinderGoalSit.java

40 Zeilen
1.1 KiB
Java

package net.minecraft.server;
public class PathfinderGoalSit extends PathfinderGoal {
2013-07-01 13:03:00 +02:00
private EntityTameableAnimal entity;
private boolean willSit;
public PathfinderGoalSit(EntityTameableAnimal entitytameableanimal) {
2013-07-01 13:03:00 +02:00
this.entity = entitytameableanimal;
this.a(5);
}
public boolean a() {
2013-07-01 13:03:00 +02:00
if (!this.entity.isTamed()) {
return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
} else if (this.entity.G()) {
return false;
2013-07-01 13:03:00 +02:00
} else if (!this.entity.onGround) {
return false;
} else {
2013-07-01 13:03:00 +02:00
EntityLiving entityliving = this.entity.getOwner();
2013-07-01 13:03:00 +02:00
return entityliving == null ? true : (this.entity.e(entityliving) < 144.0D && entityliving.getLastDamager() != null ? false : this.willSit);
}
}
public void c() {
2013-07-01 13:03:00 +02:00
this.entity.getNavigation().h();
this.entity.setSitting(true);
}
public void d() {
2013-07-01 13:03:00 +02:00
this.entity.setSitting(false);
}
2013-01-17 10:28:44 +01:00
public void setSitting(boolean flag) {
2013-07-01 13:03:00 +02:00
this.willSit = flag;
}
}