Boat: ClassCastException: net.minecraft.item.ItemStack cannot be cast to java.lang.Integer
Ricket opened this issue · 5 comments
I'm playing the Enigmatica 2 Expert pack v1.14 (pack version not MC version); MC 1.12.2. Quark-r1.4-122.
I craft a boat and try to place it, and get a client crash: https://paste.feed-the-beast.com/view/da942a12
java.lang.ClassCastException: net.minecraft.item.ItemStack cannot be cast to java.lang.Integer
at net.minecraft.entity.item.EntityBoat.func_70268_h(EntityBoat.java:874)
at net.minecraft.client.renderer.entity.RenderBoat.func_188311_a(SourceFile:51)
at net.minecraft.client.renderer.entity.RenderBoat.func_76986_a(SourceFile:32)
at net.minecraft.client.renderer.entity.RenderBoat.func_76986_a(SourceFile:11)
I then crash upon every login, and have to use WorldUtils to delete the entity from my world before I can successfully log back in. I can repeat it by crafting another boat, of any type, and trying to place it in water. As soon as I right click to place it, I crash.
However, I made a new single player world and couldn't repro it. Made one with the same world seed, went to same position, no repro. Spun up a new multiplayer server and no repro. I can't figure out what is different about my world to cause it. Also had another user over Discord try it and he couldn't repro either.
Luckily after MUCH wasted time I was able to figure out that it was the Quark "boat sails" feature causing this, and when I changed that config to false, I was able to log in and see my boat just fine.
Hm, that wasn't it, my configs matched.
My launcher renames all the mods on the client side to their mod ID name, which often reorders their loading. I suspect that's it, I've hit a problem with that in the past but didn't think of it this time. I think some other mod on my client side caused the classloader to load EntityBoat, which registered the keys, prior to your preInit method running.
Is it possible you could do the createKey
later, so that it'd be the last boat data key instead of the first? That seems like it'd be backwards compatible, unless another mod also added a boat key.
Maybe that ^ could be in one of the later init stages?
Or alternately, "poke" EntityBoat (cause the classloader to load it? I'm not sure off the top of my head how to do it) so that it initializes its static fields and therefore creates its keys before yours.
Thanks. Yeah I fixed my launcher to name jars closer to their original names, with the same capitalization so that the sorting would be the same as the server, and it fixed this issue (I was able to re-enable sails on both client and server and log in without issue). Still think it'd be a good idea to defend against the issue via postInit or similar though.
The initialization idea that I was thinking of would be like: https://stackoverflow.com/a/9391517/47493
But if postInit fixes the issue, and I think it will, then it'd probably be a cleaner solution.
I'm sorry to revive this thread, but I think I'm having a similar issue, but no one seems to be responding to mine. How would I go about fixing my launcher to name the .jar files closer to their original names?
This is what I'm getting: #929