fixed some nullptr exceptions when handling invalid node inventories

If a Lua invref is obtained from an unemergeable node, some of it's methods cause a nullptr crash, i.e.
minetest.get_meta({x=30000,y=30000,z=30000}):get_inventory():get_list('main')

I'm uncertain if it wouldn't be the better solution to return nil instead of an invref which is effectively unusable, which again may break some mods which do not expect a nil there...