Guide-API

Guide-API

76M Downloads

registerBook() causes a crash

Da-Technomancer opened this issue ยท 6 comments

commented

If I'm following the example book correctly, when I create a book then try to run registerBook() it crashes. (I am giving it the book and pre-initialization event as args). The interesting thing is when, in order to test the bug to see if I was just coding a book incorrectly, I copy pasted in the code in the testBook built into the mod into my code and ran it from their, it crashed for the same reason (of course I renamed the packages and initialized it and so on). It seems only books coded from within the API, as opposed to a mod using it, work. Here is the crash log: Log (for my book, its a similer log for copying the testbook code)

commented

I guess I forgot to mention in the original post, but I had been checking to see if Loader.isModLoaded("guideapi") before trying to run the book related code the whole time, so I don't think that was it.

commented

Mods are considered loaded before the preinit phase. You need to add "after:guideapi" to your dependencies.

commented

Thanks, worked like a charm. I'm guessing it's obvious I've never used an API before.

commented

Its only because I reference the book item there. If it gets called before our item is created, it attempts to register a model for a null item. I'll add a secondary constructor that doesn't bother with the model.

commented

Make sure you are loading after us. BloodMagic is using it just fine.

https://github.com/WayofTime/BloodMagic/tree/1.8/src/main/java/WayofTime/bloodmagic/compat/guideapi

commented

I'm currently away. I can actually help in a few hours.