MCPHackers / RetroMCP-Java

A rewrite of MCP to provide support for many versions of Minecraft which were never supported by original MCP
MIT License
228 stars 32 forks source link

Mod works perfectly fine unobfuscated, but after building jar and running from, it crashes #44

Closed glowiak closed 1 year ago

glowiak commented 1 year ago

Exception in thread "Minecraft main thread" java.lang.NoSuchFieldError: X at net.minecraft.client.a.e.e(Unknown Source) at net.minecraft.client.a.e.a(Unknown Source) at net.minecraft.client.d.run(d.java:359) at java.lang.Thread.run(Thread.java:750)

Version: inf-20100415 Build jar: https://anonfiles.com/j0g1I9c0z4/minecraft_jar Patches: https://anonfiles.com/P3geI0cbz5/PATCHES_ZIP

Thanks in advance.

glowiak commented 1 year ago

I hope this won't be like last time, when the only respond is a month after.

PhoenixVX commented 1 year ago

Looking at the mappings. the error appears to be happening in EntityRenderer#getMouseOver. The field X appears to be a field of EntityLiving. After decompiling the mod myself, I noticed that it wouldn't recompile due to this X field not existing. The field appears to be referenced twice in EntityRenderer, once in getMouseOver and hurtCameraEffect methods. After noticing EntityPlayerSP and EntityPlayer did not have this reference (in the patches), I looked to their superclass, that being EntityLiving.

I immediately notice you formatted the code, which made it a bit of a pain to identify the issue, but then I narrowed my choice down to only fields as that's the issue. After thoroughly looking into the code, I noticed that a field was missing, namely the health field disappeared. After re-adding the field, things started working again in both a deobfuscated and obfuscated environment.

Now... why didn't this error at compile time? After all, a field is missing, and the answer to that is simply the fact that a deobfuscated copy of MC is put on the classpath with fixed exceptions (for sound) and that allows the code to work as-is in your IDE. So the fix is simply re-adding the health field.

PhoenixVX commented 1 year ago

Also tip: If you want quicker support, you should join the Modification Station discord which is where we conduct development and receive bug reports primarily.

glowiak commented 1 year ago

@PhoenixVX I re-added health in EntityLiving and now it works, thank you.