/** Finds the entity where this task is running, casted to the given Entity subtype * @throws NullPointerException if there is none * @throws IllegalArgumentException if it is not of the indicated type */ public static <T extends Entity> T findEntity(Class<T> type) { Entity t = findEntity(); return Reflections.cast(t, type); }