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 ; } }
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 .