Topic category: Help with Minecraft modding (Java Edition)
This might be the strangest problem I’ve encountered while developing mods, and I hope someone familiar with mod development can help me. In order to use my custom code in the mod to solve problems that MCreator itself cannot solve, I imported the backup of my project into IDEA. I deleted all folders and files except for /src and build, and used other files provided by the official Forge mdk. Next, I tried to modify the build and rebuild it. Everything looks good, IDEA did not report any errors, and I can even use gradle runClient to start the game and it runs well in IDEA. But when I used gradle jar to export the mod file, it crashed in an external game environment where I tested it: java.lang.reflect.InvocationTargetException: null.
What drives me crazy is: I have repeatedly confirmed that all necessary dependent mods have been downloaded! I checked the crash report, it seems to point out that there is a problem with the file used to register entities in /init: Exception message:
java.lang.NoSuchMethodError: ‘net.minecraft.world.entity.EntityType$Builder net.minecraft.world.entity.EntityType$Builder.of(net.minecraft.world.entity.EntityType$EntityFactory, net.minecraft.world.entity.MobCategory)’ Stacktrace: at net.ejr.init.EjrModEntities.<clinit>(EjrModEntities.java:25) ~[ejr-1.20.1-forge-0.0.4-beta.jar%23170!/:?] {re:classloading} at net.ejr.EjrMod.<init>(EjrMod.java:41) ~[ejr-1.20.1-forge-0.0.4-beta.jar%23170!/:?] {re:classloading}.
I don’t know why this method has no errors in the IDEA environment, but it cannot run after export. Is this the peculiarity of the code generated by MCreator? Or other problems in the IDEA environment. I have stopped updating for several weeks because of this problem, and I even have to give up my Mod that participated in Mod Jam because of it. Can anyone help me solve this problem? I will be very grateful. Here is the source code of my Mod In addition, this is my complete crash report.
You may not be using the same exact version of forge.
Your full install is using ancient version of 1.20.1-forge-0.0.4
First of all, thank you Klemen for your response, but it seems you misunderstood. “1.20.1-forge-0.0.4” is the version of my mod, not the version of Forge I’m using. But that’s okay, I’ve already solved it. From my observation, since there are no errors in my code, and all dependencies have been loaded with the correct versions, it’s very likely that the problem occurred when IDEA was using the gradle.jar command. So, I deleted /.gradle and /.idea and re-imported the Mod project. After trying the jar command again, I found that the exported mod was successfully loaded! Anyway, thank you for responding to us promptly when we encounter problems! LOL