I think casts are fine. I use it to grab my game instance, from almost anywhere. Slick has this “GameState”, but ofcourse I’ve extended it to fit my needs, like grabbing the current map being drawn. The API doesn’t care for that though, so this is what I do to get access:
game = (IngameState) sbg.getState(GAME_STATE.GAME.getID());
Different states, different needs. Since this is part of Slick, I see no slick (;)) way of doing that, without casting. Another example is datagram packets. I use KryoNet, so serialized objects are the packets. To keep it OOP, I have to do a cast though, to know what fields I should be looking for. Else, it’ll just be a byte-array which takes away the entire point of serializing objects to send over the network.
That would indeed be very neat.