I don't really know where i should post this, so i try it here.
I have a mod and use the api to add a macerator,centrifuge and ore washing plant recipe. The problem is get an npe when i add the recipes and play it outside of eclipse without ic2, because it cant find the def of the class.
I check in my code if Ic2 is loaded, but it seems like it has no use.
Main:
//Ic²
IC2SupportHandler.isIC2Installed(); (= at cobaltmod.main.mod_cobalt.preLoad(mod_cobalt.java:169))
Ic2SupportHandler:
package cobaltmod.handler;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.Recipes;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cobaltmod.api.CMStuff;
import cobaltmod.items.ItemCrushedCobalt;
import cobaltmod.items.ItemPurifiedCrushedCobalt;
import cobaltmod.main.mod_cobalt;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
public class IC2SupportHandler
{
public static void isIC2Installed()
{
System.out.println("STARTING");
if(Loader.isModLoaded("IC2"))
{
System.out.println("IC2 LOADED");
try
{
//Definition
CMStuff.crushed_cobaltore = new ItemCrushedCobalt().setUnlocalizedName(mod_cobalt.MODID +":crushed_cobaltore").setTextureName(mod_cobalt.MODID + ":crushed_cobaltore").setCreativeTab(mod_cobalt.cobalttabitems);
CMStuff.purified_crushed_cobaltore = new ItemPurifiedCrushedCobalt().setUnlocalizedName(mod_cobalt.MODID +":purified_crushed_cobaltore").setTextureName(mod_cobalt.MODID + ":purified_crushed_cobaltore").setCreativeTab(mod_cobalt.cobalttabitems);
//Registry
GameRegistry.registerItem(CMStuff.crushed_cobaltore, "crushed_cobalt");
GameRegistry.registerItem(CMStuff.purified_crushed_cobaltore, "purified_crushed_cobalt");
//Recipe
Recipes.macerator.addRecipe(new RecipeInputItemStack(new ItemStack(CMStuff.cobaltore)), null, new ItemStack(CMStuff.crushed_cobaltore, 2));
NBTTagCompound metadata = new NBTTagCompound();
metadata.setInteger("minHeat", 1500);
Recipes.centrifuge.addRecipe(new RecipeInputItemStack(new ItemStack(CMStuff.crushed_cobaltore)), metadata, new ItemStack(CMStuff.purified_crushed_cobaltore));
NBTTagCompound metadata1 = new NBTTagCompound();
metadata1.setInteger("amount", 1000);
Recipes.oreWashing.addRecipe(new RecipeInputItemStack(new ItemStack(CMStuff.crushed_cobaltore)), metadata, new ItemStack(CMStuff.purified_crushed_cobaltore));
//Smelting
GameRegistry.addSmelting(CMStuff.crushed_cobaltore, new ItemStack(CMStuff.cobaltingot, 1), 1.0F);
GameRegistry.addSmelting(CMStuff.purified_crushed_cobaltore, new ItemStack(CMStuff.cobaltingot, 2), 1.0F);
}
catch(Exception e)
{}
}
else
{}
}
}
Crash:
cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: ic2/api/recipe/IRecipeInput
at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:514)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
at net.minecraft.client.Minecraft.func_71384_a(MinecraftOverlay.java:467)
at net.minecraft.client.Minecraft.func_99999_d(MinecraftOverlay.java:815)
at net.minecraft.client.main.Main.main(SourceFile:103)
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:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.NoClassDefFoundError: ic2/api/recipe/IRecipeInput
at cobaltmod.main.mod_cobalt.preLoad(mod_cobalt.java:169)
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.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.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
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.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:512)
... 10 more
Caused by: java.lang.ClassNotFoundException: ic2.api.recipe.IRecipeInput
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 38 more
Caused by: java.lang.NullPointerException
As soon as i add Ic2 it works ._.
I also tried it in preinit and init.
EDIT:
I fixed it. It was a stupid mistake i made, because through the method the other classes got imported even, if they werent used ._.