Crash when clicking on ChromatiCraft Chromic Lexicon in library
Haggle1996 opened this issue ยท 10 comments
Steps to reproduce:
Open Enchiridion 2. Click 'Library' in top right. Click on 'Chromic Lexicon' icon at top. Crash to desktop with NullPointerException.
Have you tried a newer version of ChromatiCraft? - https://sites.google.com/site/reikasminecraft/latest-downloads
Same crash occurs with the latest version of Enchiridion and ChromatiCraft (v7f), minimal modset.
i think this occurs because the chromatic lexicon contains info fragments (internal inventory), when it checks for those it returns a null pointer (there's probably not even an itemstack associated to the book GUI from enchiridion). difficult to fix as without fragments the lexicon is pretty much worthless, and tracking fragment progress could be difficult (at least in a general way - and i guess you dont want to do a lot of coding for supporting one single mod). i see 2 (general) solutions:
-in the enchiridion menu, you have access to a player based (saved in .dat) inventory which stores all the books, so you can update (add new fragments) things like the chromatic lexicon, with the downside of having to add all the books manually (as items) (the book would be passed as the "use"d item stack -> )
+: you could even add player written books to the library (or custom books which are not recognised - although there would need some sort of book detection method, to prevent infinite item storage exploits)
--: no more free books
-creating a temporary item stack of the book when you open it
+: less storage requirement, less chance for updates to break things
-: either you add a full or an empty lexicon, there is no option inbetween
I can add an API hook for you to get fragments by name on a book or player, but I get the feeling that will not be enough.
Also, I know nothing of Enchiridon, not even what it does.
EDIT:
After an explanation of what Enchiridon is and looking at the stacktrace, I think I know the cause.
The Lexicon GUI depends on the book and the player, and for the former was written with the (normally unbreakable) assumption that the player had the book in hand when opening the GUI. If either are null or invalid, errors will occur.
There is no way for me to fix this on my end. I strongly recommend caching the ItemStack somehow, but that will need to be able to be updated for the player to add fragments.
EDIT:
That will not work either, because the GUI class fetches it (and cannot have it passed in via the GuiHandler). I do not think this is fixable at all.
maybe, as a workaround, temporarily switching a cached version of the lexicon with the currently active hotbar item?
Because any cached version is A) likely in accessible, B) may not exist and C) likely to be out of sync.
it might work if it would copy the lexicon the player gets at the start of the game, store it into a hidden 1 slot enderchest-like (playerbound) inventory and switch it with the active item every time you try to access it via enchiridion, though it would require the mod to be existent on the server to work in MP. another option would be to simply cache the UI (maybe as an interactive book?) and show it directly without accessing the standard methods, though it would be quite difficult to model the interactive part dynamically (i.e. without doing it manually for every update/new book).