use of net.minecraft.server.v1_8_R3.EntityLiving in project MyPet by xXKeyleXx.
the class BehaviorAggressiveTarget method shouldFinish.
@Override
public boolean shouldFinish() {
if (!petEntity.canMove()) {
return true;
} else if (petEntity.getMyPetTarget() == null) {
return true;
}
EntityLiving target = ((CraftLivingEntity) petEntity.getMyPetTarget()).getHandle();
if (!target.isAlive()) {
return true;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.getBehavior() != BehaviorMode.Aggressive) {
return true;
} else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return true;
} else if (target.world != petEntity.world) {
return true;
} else if (petEntity.h(target) > 400) {
return true;
} else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
return true;
}
return false;
}
use of net.minecraft.server.v1_8_R3.EntityLiving in project MyPet by xXKeyleXx.
the class ControlTarget method shouldStart.
@Override
public boolean shouldStart() {
if (controlPathfinderGoal == null) {
if (petEntity.getPathfinder().hasGoal("Control")) {
controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
}
}
if (controlPathfinderGoal == null) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
if (entityLiving instanceof EntityPlayer) {
Player targetPlayer = (Player) entityLiving.getBukkitEntity();
if (myPet.getOwner().equals(targetPlayer)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
continue;
}
} else if (entityLiving instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
continue;
}
}
} else if (entityLiving instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
continue;
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
continue;
}
if (behaviorSkill != null) {
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (entityLiving instanceof EntityTameableAnimal) {
continue;
} else if (entityLiving instanceof EntityMyPet) {
continue;
} else if (entityLiving instanceof EntityPlayer) {
continue;
}
}
}
controlPathfinderGoal.stopControl();
this.target = entityLiving;
return true;
}
}
}
return false;
}
use of net.minecraft.server.v1_8_R3.EntityLiving in project Village_Defense by Plajer.
the class RidableVillager method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bt();
if (entityliving == null) {
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
P = 0.5f;
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
final float yaw = entityliving.yaw;
this.yaw = yaw;
lastYaw = yaw;
pitch = entityliving.pitch * 0.5f;
setYawPitch(this.yaw, pitch);
final float yaw2 = this.yaw;
aM = yaw2;
aO = yaw2;
f = entityliving.bd * 0.75F;
f1 = entityliving.be;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = 1.0F;
}
use of net.minecraft.server.v1_8_R3.EntityLiving in project Village_Defense by Plajer.
the class RidableVillager method a.
public void a(float f, float f1, float f2) {
EntityLiving entityliving = null;
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.P = 0.5F;
this.aR = 0.02F;
this.k((float) 0.12);
super.a(f, f1, f2);
return;
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aO = this.aM = this.yaw;
f = entityliving.be * 0.5F * 0.75F;
f2 = entityliving.bg;
if (f2 <= 0.0f) {
f2 *= 0.25F;
}
k(0.12f);
super.a(f, f1, f2);
P = (float) 1.0;
}
use of net.minecraft.server.v1_8_R3.EntityLiving in project Village_Defense by Plajer.
the class RidableVillager method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bw();
if (entityliving == null) {
// search first human passenger
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aQ = this.aO = this.yaw;
f = entityliving.be * 0.75F;
f1 = entityliving.bf;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = (float) 1.0;
}
Aggregations