mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 09:37:29 +00:00
Attempt to fix AI Sprint
This commit is contained in:
1 parent
e536345556
commit
d9d2481b7f
1 file changed
+21
-36
@@ -7,42 +7,27 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAISprintToTarget extends EntityAIBase
|
||||
{
|
||||
/** The entity that is leaping. */
|
||||
private EntityNPCInterface runner;
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
/** The entity that the leaper is leaping towards. */
|
||||
private EntityLivingBase runTarget;
|
||||
|
||||
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving)
|
||||
{
|
||||
this.runner = par1EntityLiving;
|
||||
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving){
|
||||
this.npc = par1EntityLiving;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.runTarget = this.runner.getAttackTarget();
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
EntityLivingBase runTarget = this.npc.getAttackTarget();
|
||||
|
||||
if (this.runTarget == null)
|
||||
{
|
||||
if (runTarget == null || this.npc.getNavigator().noPath()){
|
||||
return false;
|
||||
}
|
||||
else if (this.runner.getNavigator().noPath())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(this.runner.ai.onAttack)
|
||||
{
|
||||
case 0 : return !this.runner.isInRange(runTarget, 8)? (!this.runner.onGround ? false : true) : false;
|
||||
case 2 : return this.runner.isInRange(runTarget, 7)? (!this.runner.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
}
|
||||
|
||||
switch(this.npc.ai.onAttack){
|
||||
case 0 : return !this.npc.isInRange(runTarget, 8)? (!this.npc.onGround ? false : true) : false;
|
||||
case 2 : return this.npc.isInRange(runTarget, 7)? (!this.npc.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,22 +35,22 @@ public class EntityAISprintToTarget extends EntityAIBase
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return this.runner.isEntityAlive() && this.runner.onGround && this.runner.hurtTime <= 0 && (this.runner.motionX != 0.0D && this.runner.motionZ != 0.0D);
|
||||
return this.npc.isEntityAlive() && this.npc.onGround && this.npc.hurtTime <= 0 && (this.npc.motionX != 0.0D && this.npc.motionZ != 0.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.runner.setSprinting(true);
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.npc.setSprinting(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.runner.setSprinting(false);
|
||||
@Override
|
||||
public void resetTask(){
|
||||
this.npc.setSprinting(false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user