Yep, sometimes in gui this calls throw a NPE. Because field energyStored is null. I don't know exactly why, but it is.