public NearbyComponentsSensor(
     PlannerAgent agent, Class<? extends VanillaEntityComponent>... classes) {
   this.agent = agent;
   this.state = WorldState.createEmptyState();
   this.classes = new ArrayList<Class<? extends VanillaEntityComponent>>();
   for (Class<? extends VanillaEntityComponent> clazz : classes) {
     this.classes.add(clazz);
   }
 }
 @Override
 public WorldState generateState() {
   ArrayList<Entity> entities = new ArrayList<Entity>();
   for (Entity entity :
       agent.getEntity().getWorld().getNearbyEntities(agent.getEntity(), radius)) {
     boolean hasClass = false;
     for (Class clazz : classes) {
       if (entity.get(clazz) != null) {
         hasClass = true;
         break;
       }
     }
     if (!hasClass) {
       continue;
     }
     entities.add(entity);
   }
   boolean found = entities.size() > 0;
   state.put("hasNearbyEntities", found);
   state.put("entities", found ? entities : Collections.emptyList());
   return state;
 }
 /**
  * Returns if the sensor sensed a player nearby.
  *
  * @return True if player detected, false if not.
  */
 public boolean hasFoundEntity() {
   return (Boolean) state.get("hasNearbyEntities");
 }
 /**
  * Returns all the entities this sensor found.
  *
  * @return Entities found
  */
 public List<Entity> getEntities() {
   final List<Entity> targets = state.get("entities");
   return targets == null ? new ArrayList<Entity>() : targets;
 }