This will only work for userdata decented from the Entity base class. Using something else results in undefined behavior.