Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,25 +1,23 @@
|
|||
package WayofTime.bloodmagic.entity.ai;
|
||||
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import WayofTime.bloodmagic.entity.mob.EntityDemonBase;
|
||||
|
||||
public class EntityAIAttackRangedBow extends EntityAIBase
|
||||
{
|
||||
public class EntityAIAttackRangedBow extends EntityAIBase {
|
||||
private final EntityDemonBase entity;
|
||||
private final double moveSpeedAmp;
|
||||
private int attackCooldown;
|
||||
private final float maxAttackDistance;
|
||||
private int attackCooldown;
|
||||
private int attackTime = -1;
|
||||
private int seeTime;
|
||||
private boolean strafingClockwise;
|
||||
private boolean strafingBackwards;
|
||||
private int strafingTime = -1;
|
||||
|
||||
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance)
|
||||
{
|
||||
public EntityAIAttackRangedBow(EntityDemonBase entityDemonBase, double speedAmplifier, int delay, float maxDistance) {
|
||||
this.entity = entityDemonBase;
|
||||
this.moveSpeedAmp = speedAmplifier;
|
||||
this.attackCooldown = delay;
|
||||
|
@ -27,45 +25,39 @@ public class EntityAIAttackRangedBow extends EntityAIBase
|
|||
this.setMutexBits(3);
|
||||
}
|
||||
|
||||
public void setAttackCooldown(int p_189428_1_)
|
||||
{
|
||||
public void setAttackCooldown(int p_189428_1_) {
|
||||
this.attackCooldown = p_189428_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
return this.entity.getAttackTarget() != null && this.isBowInMainhand();
|
||||
}
|
||||
|
||||
protected boolean isBowInMainhand()
|
||||
{
|
||||
protected boolean isBowInMainhand() {
|
||||
return this.entity.getHeldItemMainhand().getItem() instanceof ItemBow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return (this.shouldExecute() || !this.entity.getNavigator().noPath()) && this.isBowInMainhand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
public void startExecuting() {
|
||||
super.startExecuting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
super.startExecuting();
|
||||
this.seeTime = 0;
|
||||
this.attackTime = -1;
|
||||
|
@ -75,89 +67,70 @@ public class EntityAIAttackRangedBow extends EntityAIBase
|
|||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
public void updateTask() {
|
||||
EntityLivingBase entitylivingbase = this.entity.getAttackTarget();
|
||||
|
||||
if (entitylivingbase != null)
|
||||
{
|
||||
if (entitylivingbase != null) {
|
||||
double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
|
||||
boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase);
|
||||
boolean flag1 = this.seeTime > 0;
|
||||
|
||||
if (flag != flag1)
|
||||
{
|
||||
if (flag != flag1) {
|
||||
this.seeTime = 0;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
++this.seeTime;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
--this.seeTime;
|
||||
}
|
||||
|
||||
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20)
|
||||
{
|
||||
if (d0 <= (double) this.maxAttackDistance && this.seeTime >= 20) {
|
||||
this.entity.getNavigator().clearPathEntity();
|
||||
++this.strafingTime;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entity.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.moveSpeedAmp);
|
||||
this.strafingTime = -1;
|
||||
}
|
||||
|
||||
if (this.strafingTime >= 20)
|
||||
{
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
|
||||
{
|
||||
if (this.strafingTime >= 20) {
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
|
||||
this.strafingClockwise = !this.strafingClockwise;
|
||||
}
|
||||
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D)
|
||||
{
|
||||
if ((double) this.entity.getRNG().nextFloat() < 0.3D) {
|
||||
this.strafingBackwards = !this.strafingBackwards;
|
||||
}
|
||||
|
||||
this.strafingTime = 0;
|
||||
}
|
||||
|
||||
if (this.strafingTime > -1)
|
||||
{
|
||||
if (d0 > (double) (this.maxAttackDistance * 0.75F))
|
||||
{
|
||||
if (this.strafingTime > -1) {
|
||||
if (d0 > (double) (this.maxAttackDistance * 0.75F)) {
|
||||
this.strafingBackwards = false;
|
||||
} else if (d0 < (double) (this.maxAttackDistance * 0.25F))
|
||||
{
|
||||
} else if (d0 < (double) (this.maxAttackDistance * 0.25F)) {
|
||||
this.strafingBackwards = true;
|
||||
}
|
||||
|
||||
this.entity.getMoveHelper().strafe(this.strafingBackwards ? -0.5F : 0.5F, this.strafingClockwise ? 0.5F : -0.5F);
|
||||
this.entity.faceEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.entity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F);
|
||||
}
|
||||
|
||||
if (this.entity.isHandActive())
|
||||
{
|
||||
if (!flag && this.seeTime < -60)
|
||||
{
|
||||
if (this.entity.isHandActive()) {
|
||||
if (!flag && this.seeTime < -60) {
|
||||
this.entity.resetActiveHand();
|
||||
} else if (flag)
|
||||
{
|
||||
} else if (flag) {
|
||||
int i = this.entity.getItemInUseMaxCount();
|
||||
|
||||
if (i >= 20)
|
||||
{
|
||||
if (i >= 20) {
|
||||
this.entity.resetActiveHand();
|
||||
this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i));
|
||||
this.attackTime = this.attackCooldown;
|
||||
}
|
||||
}
|
||||
} else if (--this.attackTime <= 0 && this.seeTime >= -60)
|
||||
{
|
||||
} else if (--this.attackTime <= 0 && this.seeTime >= -60) {
|
||||
this.entity.setActiveHand(EnumHand.MAIN_HAND);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue