001 package net.minecraft.src; 002 003 public class EntityAITradePlayer extends EntityAIBase 004 { 005 private EntityVillager villager; 006 007 public EntityAITradePlayer(EntityVillager par1EntityVillager) 008 { 009 this.villager = par1EntityVillager; 010 this.setMutexBits(5); 011 } 012 013 /** 014 * Returns whether the EntityAIBase should begin execution. 015 */ 016 public boolean shouldExecute() 017 { 018 if (!this.villager.isEntityAlive()) 019 { 020 return false; 021 } 022 else if (this.villager.isInWater()) 023 { 024 return false; 025 } 026 else if (!this.villager.onGround) 027 { 028 return false; 029 } 030 else if (this.villager.velocityChanged) 031 { 032 return false; 033 } 034 else 035 { 036 EntityPlayer var1 = this.villager.getCustomer(); 037 return var1 == null ? false : (this.villager.getDistanceSqToEntity(var1) > 16.0D ? false : var1.openContainer instanceof Container); 038 } 039 } 040 041 /** 042 * Execute a one shot task or start executing a continuous task 043 */ 044 public void startExecuting() 045 { 046 this.villager.getNavigator().clearPathEntity(); 047 } 048 049 /** 050 * Resets the task 051 */ 052 public void resetTask() 053 { 054 this.villager.setCustomer((EntityPlayer)null); 055 } 056 }