001 package net.minecraft.src; 002 003 public class EntityAIPanic extends EntityAIBase 004 { 005 private EntityCreature theEntityCreature; 006 private float speed; 007 private double randPosX; 008 private double randPosY; 009 private double randPosZ; 010 011 public EntityAIPanic(EntityCreature par1EntityCreature, float par2) 012 { 013 this.theEntityCreature = par1EntityCreature; 014 this.speed = par2; 015 this.setMutexBits(1); 016 } 017 018 /** 019 * Returns whether the EntityAIBase should begin execution. 020 */ 021 public boolean shouldExecute() 022 { 023 if (this.theEntityCreature.getAITarget() == null) 024 { 025 return false; 026 } 027 else 028 { 029 Vec3 var1 = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4); 030 031 if (var1 == null) 032 { 033 return false; 034 } 035 else 036 { 037 this.randPosX = var1.xCoord; 038 this.randPosY = var1.yCoord; 039 this.randPosZ = var1.zCoord; 040 return true; 041 } 042 } 043 } 044 045 /** 046 * Execute a one shot task or start executing a continuous task 047 */ 048 public void startExecuting() 049 { 050 this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed); 051 } 052 053 /** 054 * Returns whether an in-progress EntityAIBase should continue executing 055 */ 056 public boolean continueExecuting() 057 { 058 return !this.theEntityCreature.getNavigator().noPath(); 059 } 060 }