Vampirism - Become a vampire!

Vampirism - Become a vampire!

16M Downloads

[1.9] Crash on world load. With AbyssalCraft

squirrelkiller opened this issue ยท 5 comments

commented

This bug has been a massive stress to solve, with multiple cases of mistaken identity. Turns out it is you. Please take all the information I can offer:

Each zip is the same pack, with only the exact alterations needed to show that I needed to narrow it down to this mod:

All of them include all the log files from the logs folder, and in the case of crashes, the crash report:

First, upon removing Vampirism, no crash, this is how I found it was you, and yes I have in fact shown this to AbyssalCraft and BoP, niether of them have anything to do with this:
No Vampirism.zip

With it however, yes a crash:
With Vampirism.zip

Now if you think it is BoP, this is false still crashing:
No Biomes O Plenty.zip

You can do this with this instance:
https://www.dropbox.com/s/iypf8qz9oly2phh/instance%20sample-1.0.zip?dl=0

This issue also exists if you repeat these tests with Evilcraft instead of AbyssalCraft and find the exact same crashes. If I had to guess the problem is something to do with this class of your mod, and has to do with when you interact with other people's biomes:

https://github.com/TeamLapen/Vampirism/blob/master/src/main/java/de/teamlapen/vampirism/world/gen/VampirismWorldGen.java

commented

Thanks for that extensive crash report. I investigated it a little bit, but could not find any solution yet, I will contact AbyssalCraft's authors now, maybe they have a idea.
The following is what I already found out in case anybody is interested:

This seems like quite a strange issue. It only occurs if both AbyssalCraft and Vampirism are installed (no other mod required), but it does not directly caused by any of them and only appears in a non-deobfuscated environment

After some investigation it looks like it has to do with Minecraft's EnumCreatureType. Vampirism adds two EnumCreatureType using Forge's methods (EnumHelper#addCreatureType()), which are definitively intended to be used.
Thereby it increases the size of EnumCreatureType to 6. Logging the values (EnumCreatureType#values()) at the end of Vampirism's pre init results in "EnumCreatureTypes 6 [MONSTER, CREATURE, AMBIENT, WATER_CREATURE, VAMPIRISM_HUNTER, VAMPIRISM_VAMPIRE]".

During Minecraft's spawning process the games iterates over all values and with this indirectly invokes BiomeGenBase#getSpawnableList(EnumCreatureType creatureType). Within this method there is a switch statement which seems to throw the ArrayIndexOutOfBoundsException when the iteration is at the 5th element (index 4) of EnumCreatureType#values().

I took a short look at AbyssalCraft's source code, but did not find anything that could be related to this, although it has to have some kind of impact, since the game does not crash without it and the above mentioned switch statement is also called without it.

Here is another Minecraft log with only Vampirism and AbyssalCraft installed: http://paste.ee/p/ELARk

commented

It probably has something to do with the fact that that switch case at BiomeGenBase#getSpawnableList is done over EnumCreatureType. Forge probably does some hacky ASM to allow enum values to be added at runtime, which seems to clash with the way Java handles enum-switching.
I think that BiomeGenBase#getSpawnableList will have to be patched so that it is able to handle EnumCreatureType value changes at runtime.

commented

Yep, I think patching the switch statement should fix this. But I'm still wondering why this issue only happens if a mod like AbyssalCraft or Evilcraft is installed, since I'm pretty sure this method is also called when they are not present.

I will wait if @Shinoow has an idea, otherwise I will open a forge issue

commented

Yeah, I have no idea what could be causing it, but @rubensworks seems to be on the right track. Getting in touch with Forge about this is probably the right way to go.

commented

Ok we found the problem and a solution that seems to work.

The switch statement in BiomeGenBase only knows the values of an enum that were present at the time of loading. With only Vampirism this is not a problem, because BiomeGenBase is not used before the new type isadded, but apparently AbyssalCraft, Evilcraft and probably other mods as well make BiomeGenBase load earlier.

The solution was to move the static block with the enum addition to Vampirism's main mod file, since that is loaded early enough.