예제 #1
0
 @Override
 public boolean continueExecuting() {
   if (entity.worldObj != null) {
     if (targetEntity != null
         && targetEntity.getHeldItem(EnumHand.MAIN_HAND) != null) { // TODO Allow Left hand
       if (entity.isValidForPickup(targetEntity.getHeldItem(EnumHand.MAIN_HAND).getItem())
           && entity.isAnySpaceForItemPickup(targetEntity.getHeldItem(EnumHand.MAIN_HAND))
           && !targetEntity.isInWater()
           && !(entity.getDistanceToEntity(targetEntity) > 8)) return true;
     }
   }
   if (entity.worldObj != null && targetEntity != null) {
     switch (randInt) {
       case 0:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX + (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ + (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 1:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX - (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ + (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 2:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX + (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ - (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 3:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX - (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ - (rand.nextInt(12) + 8),
             this.speed);
         break;
     }
   }
   targetEntity = null;
   return false;
 }
예제 #2
0
 @Override
 public void updateTask() {
   if (rand.nextInt(200) == 0) {
     int newInt = -1;
     while (newInt == -1 || newInt == randInt) newInt = rand.nextInt(4);
     randInt = newInt;
     startExecuting();
   }
   if (targetEntity != null && entity.getDistanceToEntity(targetEntity) > 2 && continueExecuting())
     startExecuting();
 }
예제 #3
0
 @Override
 public boolean shouldExecute() {
   if (!pathFinder.noPath()) {
     return false;
   }
   if (entity.worldObj != null) {
     EntityPlayer player = entity.worldObj.getClosestPlayerToEntity(entity, 8);
     if (player != null
         && player.getHeldItem(EnumHand.MAIN_HAND) != null) { // TODO Allow Left hand
       if (entity.getEntitySenses().canSee(player)
           && entity.isValidForPickup(player.getHeldItem(EnumHand.MAIN_HAND).getItem())
           && entity.isAnySpaceForItemPickup(player.getHeldItem(EnumHand.MAIN_HAND))
           && !player.isInWater()) {
         targetEntity = player;
         randInt = rand.nextInt(4);
         return true;
       }
     }
   }
   return false;
 }
예제 #4
0
 public EntityAIBegPlayer(EntityFendinainMob entity, double speed, Random rand) {
   this.entity = entity;
   this.pathFinder = entity.getNavigator();
   this.speed = speed;
   this.rand = rand;
 }