code: public static <T> T getTagValue(Tag<?> t, Class<? extends T> clazz) {
          Object o = toTagValue(t);
          if (o == null) {
              return null;
          }
          try {
              return clazz.cast(o);
          } catch (ClassCastException e) {
              return null;
          }
      }
docs: Takes in an NBT tag, sanely checks null status, and then returns it value. This method will return null if the value cannot be cast to the given class.
  
  @param t Tag to get the value from
  @param clazz the return type to use
  @return the value as an onbject of the same type as the given class