I'm currently writing an add-on for another mod, but also wish to add integration with yet another add-on within mine — more specifically, an AE2 add-on for larger tiers of storage cells with Applied Mekanistics integration to also offer higher-capacity chemical cells for use with Mekanism. As part of that integration, I am trying to create and register some new items only if the other add-on is also installed and attempting to make use of Object holders in order to retrieve registered instances of those items.
So far, I've been successful in adding these items and making them work when the other add-on is installed. However, attempting to run a game with my add-on installed but not the other optional one results in an IllegalStateException crash because of the Item holders not having a registry entry to inject from. I am not sure how to handle this case, so I would like to know how to go about only having these items in the presence of another mod.
Huge disclaimer: I am very new to a lot of the mod-making process in Forge and this is also my first time using some of the features in it, so my code will most definitely look like shit in a few places. I have a GitHub repo for my add-on here with the beginning of this integration attempt committed to it just now.
Full crash report: