001 package net.minecraft.src; 002 003 public class EntityAIBeg extends EntityAIBase 004 { 005 private EntityWolf theWolf; 006 private EntityPlayer field_75385_b; 007 private World worldObject; 008 private float minPlayerDistance; 009 private int field_75384_e; 010 011 public EntityAIBeg(EntityWolf par1EntityWolf, float par2) 012 { 013 this.theWolf = par1EntityWolf; 014 this.worldObject = par1EntityWolf.worldObj; 015 this.minPlayerDistance = par2; 016 this.setMutexBits(2); 017 } 018 019 /** 020 * Returns whether the EntityAIBase should begin execution. 021 */ 022 public boolean shouldExecute() 023 { 024 this.field_75385_b = this.worldObject.getClosestPlayerToEntity(this.theWolf, (double)this.minPlayerDistance); 025 return this.field_75385_b == null ? false : this.func_75382_a(this.field_75385_b); 026 } 027 028 /** 029 * Returns whether an in-progress EntityAIBase should continue executing 030 */ 031 public boolean continueExecuting() 032 { 033 return !this.field_75385_b.isEntityAlive() ? false : (this.theWolf.getDistanceSqToEntity(this.field_75385_b) > (double)(this.minPlayerDistance * this.minPlayerDistance) ? false : this.field_75384_e > 0 && this.func_75382_a(this.field_75385_b)); 034 } 035 036 /** 037 * Execute a one shot task or start executing a continuous task 038 */ 039 public void startExecuting() 040 { 041 this.theWolf.func_70918_i(true); 042 this.field_75384_e = 40 + this.theWolf.getRNG().nextInt(40); 043 } 044 045 /** 046 * Resets the task 047 */ 048 public void resetTask() 049 { 050 this.theWolf.func_70918_i(false); 051 this.field_75385_b = null; 052 } 053 054 /** 055 * Updates the task 056 */ 057 public void updateTask() 058 { 059 this.theWolf.getLookHelper().setLookPosition(this.field_75385_b.posX, this.field_75385_b.posY + (double)this.field_75385_b.getEyeHeight(), this.field_75385_b.posZ, 10.0F, (float)this.theWolf.getVerticalFaceSpeed()); 060 --this.field_75384_e; 061 } 062 063 private boolean func_75382_a(EntityPlayer par1EntityPlayer) 064 { 065 ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); 066 return var2 == null ? false : (!this.theWolf.isTamed() && var2.itemID == Item.bone.shiftedIndex ? true : this.theWolf.isWheat(var2)); 067 } 068 }