Posted October 15, 20159 yr Hi! I'm making 2 mods, but I've been getting this runtime error in both mods. They compile ok, IntelliJ doesn't highlights any error, but when I test them, Minecraft throws a java.lang.NoSuchMethodError. I'm using Forge 1.8-11.14.3.1521 to run, and IntelliJ IDEA 14.1.4 as IDE. I checked the methods, the imports (the line itself), and the files being imported, and everything is ok. I also searched this online, even here, but I didn't find an answer to my problem. I can't modify the import, as it's from an external library. Here I will put the error of one of the mods, along with the relevant code of the file imported and the MC Crash report. I hope you guys can help me with this. File 'errored': package com.joa.techmod.items; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; public class BasicItem extends Item { public BasicItem(String unlocalizedName) { super(); this.setUnlocalizedName(unlocalizedName); // <- This is "wrong" this.setCreativeTab(CreativeTabs.tabMaterials); } } Import (Item, resume): package net.minecraft.item; import ... public class Item { ... private String unlocalizedName; ... /** * Sets the unlocalized name of this item to the string passed as the parameter, prefixed by "item." */ public Item setUnlocalizedName(String unlocalizedName) { this.unlocalizedName = unlocalizedName; return this; } ... } Crash Report: ---- Minecraft Crash Report ---- // I just don't know what went wrong Time: 13/10/15 13:23 Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderException: java.lang.NoSuchMethodError: com.joa.techmod.items.BasicItem.setUnlocalizedName(Ljava/lang/String;)Lnet/minecraft/item/Item; at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:163) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:553) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249) at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:413) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:325) at net.minecraft.client.main.Main.main(SourceFile:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.NoSuchMethodError: com.joa.techmod.items.BasicItem.setUnlocalizedName(Ljava/lang/String;)Lnet/minecraft/item/Item; at com.joa.techmod.items.BasicItem.<init>(BasicItem.java:10) at com.joa.techmod.items.ModItems.createItems(ModItems.java:50) at com.joa.techmod.CommonProxy.preInit(CommonProxy.java:12) at com.joa.techmod.ClientProxy.preInit(ClientProxy.java:12) at com.joa.techmod.Main.preInit(Main.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) ... 10 more
October 15, 20159 yr Are you compiling it with gradlew build (or running the build task through IDEA's Gradle window)? This reobfuscates the mod after compiling it, so setUnlocalizedName is renamed to the appropriate SRG name (the names used outside of the development environment). Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 15, 20159 yr Author Yes, I'm using the "Build On Make" task. And, sorry, but I'm just a newbie (not even 5 months I started), but, how I "fix" it? Thank you on advance.
October 15, 20159 yr Yes, I'm using the "Build On Make" task. And, sorry, but I'm just a newbie (not even 5 months I started), but, how I "fix" it? Thank you on advance. I haven't used IDEA's artifacts before, but I don't think they're compiled with the Gradle build task; so they're not reobfuscated by ForgeGradle. You need to run the build task from the command line or IDEA's Gradle window, which will compile and reobfuscate the mod and output it to build/libs. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 15, 20159 yr Author Ok. So I used Gradle build task, but it didn't compile the resources. Then I changed the build.gradle file (I searched the problem here and found a fix) but now it doesn't compiles any source code at all. It just build 'empty' .jars, containing only a META-INF folder (with the Manifest saying "Manifest version 1.0.0"), while "Build On Make" option compiles everything, but it has the problem mentioned in the OP. What should I do? Thanks ^^
October 16, 20159 yr Author Is your source code in src/main/java and your resources in src/main/resources? If so, post your build.gradle. My source code is in src/com, and my assets in src/resources. Didn't added the main/java due to a friend's recommendation (He said something about IntelliJ and Java, I don't remember well). EDIT: I tested the .jar I got to compile. Using 'runClient' Gradle task, the mod works and no errors are found. However, if I use the normal Minecraft (the launcher, not the development environment) it finds the same error, despite using the same .jar.
October 16, 20159 yr Author Gradle will only pick up your sources and resources if you use src/main/java and src/main/resources unless you tell it otherwise. IntelliJ will do the same if you import the gradle project properly (see here). I started programming in Eclipse, then switched to IntelliJ. However, I added that line of code at the end of the build.gradle file before.
October 16, 20159 yr Author I am not talking about the resources fix, it does not affect building outside of IntelliJ. I am talking about the "open build.gradle" step. Also, in eclipse you should be using src/main/java and src/main/resources as well. It is pretty much the standard (set by maven) for Java projects. When I used Eclipse I also used main/java, then I switched to IntelliJ (what I'm using now) and I changed it to src/com (Same with resources). Should I upload build.gradle?
October 16, 20159 yr Author You do not listen. Code goes in src/main/java. Resources go in src/main/resources. No matter what IDE you use. Oh, ok. I thought you were specificating for eclipse. Changing folders now.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.