fix NPE

I have no idea how this ended up causing a problem, but our server had a world-corrupting bug based on an NPE in this line. Adding this additional check fixed it. It was some interaction with applied energistics.