mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 02:29:41 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -9,9 +9,10 @@ import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIRangedAttack extends EntityAIBase
|
||||
{
|
||||
/** The entity the AI instance has been applied to */
|
||||
public class EntityAIRangedAttack extends EntityAIBase {
|
||||
/**
|
||||
* The entity the AI instance has been applied to
|
||||
*/
|
||||
private final EntityNPCInterface entityHost;
|
||||
|
||||
/**
|
||||
@@ -31,16 +32,12 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
private boolean hasFired = false;
|
||||
private boolean navOverride = false;
|
||||
|
||||
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob)
|
||||
{
|
||||
if (!(par1IRangedAttackMob instanceof EntityLivingBase))
|
||||
{
|
||||
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) {
|
||||
if (!(par1IRangedAttackMob instanceof EntityLivingBase)) {
|
||||
throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.rangedAttackEntityHost = par1IRangedAttackMob;
|
||||
this.entityHost = (EntityNPCInterface)par1IRangedAttackMob;
|
||||
this.entityHost = (EntityNPCInterface) par1IRangedAttackMob;
|
||||
this.rangedAttackTime = this.entityHost.stats.minDelay / 2;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
@@ -49,23 +46,21 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase var1 = this.entityHost.getAttackTarget();
|
||||
public boolean shouldExecute() {
|
||||
EntityLivingBase var1 = this.entityHost.getAttackTarget();
|
||||
|
||||
if (var1 == null || !var1.isEntityAlive()) return false;
|
||||
|
||||
if(entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
|
||||
if (entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
|
||||
|
||||
if (this.entityHost.inventory.getProjectile() == null) return false;
|
||||
if (this.entityHost.inventory.getProjectile() == null) return false;
|
||||
|
||||
double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ);
|
||||
double var3 = this.entityHost.ais.distanceToMelee * this.entityHost.ais.distanceToMelee;
|
||||
|
||||
if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3) return false;
|
||||
|
||||
else
|
||||
{
|
||||
else {
|
||||
this.attackTarget = var1;
|
||||
return true;
|
||||
}
|
||||
@@ -74,16 +69,14 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
public boolean continueExecuting() {
|
||||
return this.shouldExecute() || !this.entityHost.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
public void resetTask() {
|
||||
this.attackTarget = null;
|
||||
this.entityHost.setAttackTarget(null);
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
@@ -95,77 +88,63 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
|
||||
public void updateTask() {
|
||||
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
|
||||
double var1 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
|
||||
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
|
||||
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
|
||||
|
||||
if (!navOverride && this.entityHost.ais.directLOS)
|
||||
{
|
||||
if (this.entityHost.getEntitySenses().canSee(this.attackTarget))
|
||||
{
|
||||
++this.field_75318_f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_75318_f = 0;
|
||||
}
|
||||
int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5;
|
||||
if (var1 <= (double)field_82642_h && this.field_75318_f >= v)
|
||||
{
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D);
|
||||
}
|
||||
if (!navOverride && this.entityHost.ais.directLOS) {
|
||||
if (this.entityHost.getEntitySenses().canSee(this.attackTarget)) {
|
||||
++this.field_75318_f;
|
||||
} else {
|
||||
this.field_75318_f = 0;
|
||||
}
|
||||
int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5;
|
||||
if (var1 <= (double) field_82642_h && this.field_75318_f >= v) {
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
} else {
|
||||
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
this.rangedAttackTime = Math.max(this.rangedAttackTime - 1, 0);
|
||||
|
||||
if (this.rangedAttackTime <= 0)
|
||||
{
|
||||
if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2))
|
||||
{
|
||||
if (this.field_70846_g++ <= this.entityHost.stats.burstCount)
|
||||
{
|
||||
this.rangedAttackTime = this.entityHost.stats.fireRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_70846_g = 0;
|
||||
this.hasFired = true;
|
||||
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
|
||||
}
|
||||
if (this.rangedAttackTime <= 0) {
|
||||
if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) {
|
||||
if (this.field_70846_g++ <= this.entityHost.stats.burstCount) {
|
||||
this.rangedAttackTime = this.entityHost.stats.fireRate;
|
||||
} else {
|
||||
this.field_70846_g = 0;
|
||||
this.hasFired = true;
|
||||
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
|
||||
}
|
||||
|
||||
if (this.field_70846_g > 1)
|
||||
{
|
||||
boolean indirect = false;
|
||||
if (this.field_70846_g > 1) {
|
||||
boolean indirect = false;
|
||||
|
||||
switch(this.entityHost.ais.canFireIndirect)
|
||||
{
|
||||
case 1 : indirect = var1 > (double)field_82642_h / 2; break;
|
||||
case 2 : indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
|
||||
}
|
||||
switch (this.entityHost.ais.canFireIndirect) {
|
||||
case 1:
|
||||
indirect = var1 > (double) field_82642_h / 2;
|
||||
break;
|
||||
case 2:
|
||||
indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
|
||||
}
|
||||
|
||||
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
|
||||
if (this.entityHost.currentAnimation != EnumAnimation.AIMING)
|
||||
{
|
||||
this.entityHost.swingItem();
|
||||
}
|
||||
}
|
||||
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
|
||||
if (this.entityHost.currentAnimation != EnumAnimation.AIMING) {
|
||||
this.entityHost.swingItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFired()
|
||||
{
|
||||
return this.hasFired;
|
||||
public boolean hasFired() {
|
||||
return this.hasFired;
|
||||
}
|
||||
|
||||
public void navOverride(boolean nav){
|
||||
this.navOverride = nav;
|
||||
public void navOverride(boolean nav) {
|
||||
this.navOverride = nav;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user