mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 19:59:56 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -8,8 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class EntityAIOrbitTarget extends EntityAIBase
|
||||
{
|
||||
public class EntityAIOrbitTarget extends EntityAIBase {
|
||||
private EntityNPCInterface theEntity;
|
||||
private EntityLivingBase targetEntity;
|
||||
private double movePosX;
|
||||
@@ -26,8 +25,7 @@ public class EntityAIOrbitTarget extends EntityAIBase
|
||||
private float decayRate = 1.0F;
|
||||
private int tick = 0;
|
||||
|
||||
public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5)
|
||||
{
|
||||
public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5) {
|
||||
this.theEntity = par1EntityCreature;
|
||||
this.speed = par2;
|
||||
this.distance = par4;
|
||||
@@ -38,90 +36,78 @@ public class EntityAIOrbitTarget extends EntityAIBase
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (--delay > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null)
|
||||
{
|
||||
public boolean shouldExecute() {
|
||||
if (--delay > 0) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
double d0 = this.theEntity.getDistanceToEntity(this.targetEntity);
|
||||
return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true);
|
||||
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null) {
|
||||
return false;
|
||||
} else {
|
||||
double d0 = this.theEntity.getDistanceToEntity(this.targetEntity);
|
||||
return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
double d0 = this.targetEntity.getDistanceToEntity(this.theEntity);
|
||||
return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate;
|
||||
public boolean continueExecuting() {
|
||||
double d0 = this.targetEntity.getDistanceToEntity(this.theEntity);
|
||||
return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.theEntity.getNavigator().clearPathEntity();
|
||||
this.delay = 60;
|
||||
if (this.theEntity.getRangedTask() != null){
|
||||
this.theEntity.getRangedTask().navOverride(false);
|
||||
public void resetTask() {
|
||||
this.theEntity.getNavigator().clearPathEntity();
|
||||
this.delay = 60;
|
||||
if (this.theEntity.getRangedTask() != null) {
|
||||
this.theEntity.getRangedTask().navOverride(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.canNavigate = true;
|
||||
Random random = this.theEntity.getRNG();
|
||||
this.direction = random.nextInt(10) > 5 ? 1 : -1;
|
||||
this.decayRate = random.nextFloat() + (this.distance / 16.0F);
|
||||
public void startExecuting() {
|
||||
this.canNavigate = true;
|
||||
Random random = this.theEntity.getRNG();
|
||||
this.direction = random.nextInt(10) > 5 ? 1 : -1;
|
||||
this.decayRate = random.nextFloat() + (this.distance / 16.0F);
|
||||
this.targetDistance = this.theEntity.getDistanceToEntity(this.targetEntity);
|
||||
double d0 = this.theEntity.posX - this.targetEntity.posX;
|
||||
double d1 = this.theEntity.posZ - this.targetEntity.posZ;
|
||||
this.angle = (float) (Math.atan2(d1, d0) * 180.0F / Math.PI);
|
||||
if (this.theEntity.getRangedTask() != null){
|
||||
this.theEntity.getRangedTask().navOverride(true);
|
||||
if (this.theEntity.getRangedTask() != null) {
|
||||
this.theEntity.getRangedTask().navOverride(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
if (this.theEntity.getNavigator().noPath() && this.tick >= 0)
|
||||
{
|
||||
if (this.theEntity.onGround && !this.theEntity.isInWater())
|
||||
{
|
||||
double d0 = this.targetDistance * (double)(MathHelper.cos(angle / 180.0F * (float)Math.PI));
|
||||
double d1 = this.targetDistance * (double)(MathHelper.sin(angle / 180.0F * (float)Math.PI));
|
||||
this.movePosX = this.targetEntity.posX + d0;
|
||||
this.movePosY = this.targetEntity.boundingBox.maxY;
|
||||
this.movePosZ = this.targetEntity.posZ + d1;
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
|
||||
this.angle += 15.0F * this.direction;
|
||||
this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F));
|
||||
if (this.decay)
|
||||
{
|
||||
this.targetDistance -=decayRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.tick >= 0) this.tick--;
|
||||
public void updateTask() {
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
if (this.theEntity.getNavigator().noPath() && this.tick >= 0) {
|
||||
if (this.theEntity.onGround && !this.theEntity.isInWater()) {
|
||||
double d0 = this.targetDistance * (double) (MathHelper.cos(angle / 180.0F * (float) Math.PI));
|
||||
double d1 = this.targetDistance * (double) (MathHelper.sin(angle / 180.0F * (float) Math.PI));
|
||||
this.movePosX = this.targetEntity.posX + d0;
|
||||
this.movePosY = this.targetEntity.boundingBox.maxY;
|
||||
this.movePosZ = this.targetEntity.posZ + d1;
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
|
||||
this.angle += 15.0F * this.direction;
|
||||
this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F));
|
||||
if (this.decay) {
|
||||
this.targetDistance -= decayRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.tick >= 0) this.tick--;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user