Jump to content

NoSuchMethodError and NoSuchFieldError when run in game folder <SOLVED>


RafaelVN

Recommended Posts

Well, I'm having trouble running an example of already compiled code in real minecraft package (no package eclipse), when I run in eclipse, runs without any problem, but when I move the compiled code into the mods folder in the directory the real minecraft (.minecraft) I get the message NoSuchMethodError. I'll post the example code and the error message.

 

Class Generic (init class)

package tutorial.generic;

import tutorial.generic.items.GenericItem;
import tutorial.generic.items.GenericMetaItem;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "generic", name = "Generic", version = "0.0.0")
public class Generic {

@Instance(value = "generic")
public static Generic instance;

@SidedProxy(clientSide = "tutorial.generic.client.ClientProxy", serverSide = "tutorial.generic.CommonProxy")
public static CommonProxy proxy;

public static Item genericItem,genericMetaItem;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	genericItem = new GenericItem().setMaxStackSize(64).setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("genericItem").setTextureName("generic:nickelCrystal");

	GameRegistry.registerItem(genericItem, "GenericItem");
}

@EventHandler
public void init(FMLInitializationEvent event) {
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}

}

 

Class GenericItem

package tutorial.generic.items;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class GenericItem extends Item {

public GenericItem() {
                super();
}
}

 

Class CommonProxy

package tutorial.generic;

public class CommonProxy {

// Client stuff
public void registerRenderers() {
	// Nothing here as the server doesn't render graphics or entities!
}
}

 

Class ClientProxy

package tutorial.generic.client;

import tutorial.generic.CommonProxy;
import net.minecraftforge.client.MinecraftForgeClient;

public class ClientProxy extends CommonProxy {

@Override
public void registerRenderers() {
	// This is for rendering entities and so forth later on
}
}

 

Error message

--- Minecraft Crash Report ----
// Ouch. That hurt 

Time: 08/11/14 23:44
Description: There was a severe problem during mod loading that has caused the game to fail

cpw.mods.fml.common.LoaderException: java.lang.NoSuchMethodError: tutorial.generic.items.GenericItem.setMaxStackSize(I)Lnet/minecraft/item/Item;
at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:515)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:867)
at net.minecraft.client.main.Main.main(SourceFile:148)
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: tutorial.generic.items.GenericItem.setMaxStackSize(I)Lnet/minecraft/item/Item;
at tutorial.generic.Generic.preInit(Generic.java:31)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
at sun.reflect.GeneratedMethodAccessor3.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 cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
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 cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513)
... 10 more

 

my mod dir is :

 

generic

      assets

      tutorial

            generic

                  CommonProxy.class

                  Generic.class

                  client

                          ClientProxy.class

                  items

                          GenericItem.class

forge version:

Minecraft forge-1.7.10-10.13.2.1230

 

Note. When I change the code setMaxStackSize(64) by maxStackSize = 64 in constructor,  the exception changes to NoSuchFieldError.

 

Well this is my problem, can someone help me?

Link to comment
Share on other sites

compiled by gradlew and it worked, but now I have another problem, when I run the game the item customized it not renders (instead renders a box of pink and black), the directory where the texture is located assets / generic / textures / items / NickelCrystal.png.

I call on item setTextureName ("generic: nickelCrystal");

This works fine when I do the eclipse, when I put the game simply does not render correctly. is there anything else I should do?

 

Note: i check for the textures files in jar and its ok

 

grateful again for the answers.

Link to comment
Share on other sites

The pink and black box is the "texture missing" texture. Check the logs, they should be spammed with something like:

 

[Client thread/ERROR]: Using missing texture, unable to load <blah>.png
java.io.FileNotFoundException: <blah>

 

This will tell you where your mod is looking for the textures, versus where they are actually placed.

Link to comment
Share on other sites

compiled by gradlew and it worked, but now I have another problem, when I run the game the item customized it not renders (instead renders a box of pink and black), the directory where the texture is located assets / generic / textures / items / NickelCrystal.png.

I call on item setTextureName ("generic: nickelCrystal");

This works fine when I do the eclipse, when I put the game simply does not render correctly. is there anything else I should do?

 

Note: i check for the textures files in jar and its ok

 

grateful again for the answers.

your upper and lower case must match in jars.

 

eg NickelCrystal.png is not the same as nickelCrystal.png

 

-TGG

Link to comment
Share on other sites

here :

[02:53:57] [Client thread/ERROR]: Using missing texture, unable to load generic:textures/items/nickelCrystal.png

 

hehe, my bad i did write "nickelCrystal" in setTextureName(), when its use uppercase ("NickelCrystal.png"), now its every ok ty for all =b

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.