001 package net.minecraft.src; 002 003 public class EntityAISit extends EntityAIBase 004 { 005 private EntityTameable theEntity; 006 007 /** If the EntityTameable is sitting. */ 008 private boolean isSitting = false; 009 010 public EntityAISit(EntityTameable par1EntityTameable) 011 { 012 this.theEntity = par1EntityTameable; 013 this.setMutexBits(5); 014 } 015 016 /** 017 * Returns whether the EntityAIBase should begin execution. 018 */ 019 public boolean shouldExecute() 020 { 021 if (!this.theEntity.isTamed()) 022 { 023 return false; 024 } 025 else if (this.theEntity.isInWater()) 026 { 027 return false; 028 } 029 else if (!this.theEntity.onGround) 030 { 031 return false; 032 } 033 else 034 { 035 EntityLiving var1 = this.theEntity.getOwner(); 036 return var1 == null ? true : (this.theEntity.getDistanceSqToEntity(var1) < 144.0D && var1.getAITarget() != null ? false : this.isSitting); 037 } 038 } 039 040 /** 041 * Execute a one shot task or start executing a continuous task 042 */ 043 public void startExecuting() 044 { 045 this.theEntity.getNavigator().clearPathEntity(); 046 this.theEntity.setSitting(true); 047 } 048 049 /** 050 * Resets the task 051 */ 052 public void resetTask() 053 { 054 this.theEntity.setSitting(false); 055 } 056 057 /** 058 * Sets the sitting flag. 059 */ 060 public void setSitting(boolean par1) 061 { 062 this.isSitting = par1; 063 } 064 }