示例#1
0
 @Override
 public void tick() {
   this.petEntity.getControllerLook().a(targetEntity, 30.0F, 30.0F);
   if (--this.timeUntilNextNavigationUpdate <= 0) {
     this.timeUntilNextNavigationUpdate = (4 + this.petEntity.getRandom().nextInt(7));
     this.petEntity.getPetNavigation().navigateTo((LivingEntity) targetEntity.getBukkitEntity());
   }
   if (this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ)
               - (targetEntity.length * (2. / 3.))
           <= this.range
       && this.ticksUntilNextHitLeft-- <= 0) {
     if (this.petEntity.getEntitySenses().a(targetEntity)) {
       this.ticksUntilNextHitLeft = ticksUntilNextHit;
       if (this.petEntity instanceof MyPetEquipment) {
         if (((MyPetEquipment) this.petEntity).getEquipment(EquipmentSlot.MainHand) != null) {
           this.petEntity.bv(); // -> swingItem()
         }
       }
       this.petEntity.attack(targetEntity);
     }
   }
 }