Jump to content

My crafting manager "addRecipe" returns a Null Pointer Exception


SteampunkRBot

Recommended Posts

I am working on a crafting manager for my mod, but when I try to use my addRecipe I get a null pointer exception.

 

My IBrewingManager

package RV97.Drinks.Utils.Crafting;

import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidStack;

public abstract interface IBrewingManager
{
public abstract void addRecipe(ItemStack inputItemStack1, LiquidStack outputLiquidStack, int brewingTime);
public abstract void addRecipe(ItemStack inputItemStack1, ItemStack inputItemStack2, LiquidStack outputLiquidStack, int brewingTime);
public abstract void addRecipe(ItemStack inputItemStack1, LiquidStack inputLiquidStack, LiquidStack outputLiquidStack, int brewingTime);
public abstract void addRecipe(ItemStack inputItemStack1, ItemStack inputItemStack2, LiquidStack inputLiquidStack, LiquidStack outputLiquidStack, int brewingTime);

public abstract IBrewingRecipe getRecipe(ItemStack inputStack, ItemStack inputStack2, LiquidStack inputLiquid);

public abstract List getRecipes();
}

 

My CraftingManager

package RV97.Drinks.Utils.Crafting;

public class CraftingManager {
public static IBrewingManager brewery;
}

 

My IBrewingRecipe

package RV97.Drinks.Utils.Crafting;

import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidStack;

public abstract interface IBrewingRecipe {

public abstract int getBrewTime();

public abstract ItemStack getInput1();
  
public abstract ItemStack getInput2();
  
public abstract LiquidStack getLiquidInput();

public abstract LiquidStack getLiquidOutput();

}

 

My attempt at addRecipe

CraftingManager.brewery.addRecipe(new ItemStack(Item.sugar), new ItemStack(Item.appleRed), new LiquidStack(Block.waterStill.blockID, 1000), new LiquidStack(applejackDaniels, 1000), 300);

 

And the error I get is as follows:

 

2013-08-18 18:56:08 [sEVERE] [ForgeModLoader] Caught exception from RV97Drinks

java.lang.NullPointerException

at RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33)

at RV97.Drinks.DrinksCore.preInit(DrinksCore.java:44)

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:494)

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:45)

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:192)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)

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:45)

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:103)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:515)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:163)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:411)

at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

at net.minecraft.client.Minecraft.run(Minecraft.java:733)

at java.lang.Thread.run(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] java.lang.NullPointerException

2013-08-18 18:56:08 [iNFO] [sTDERR] at RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33)

2013-08-18 18:56:08 [iNFO] [sTDERR] at RV97.Drinks.DrinksCore.preInit(DrinksCore.java:44)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:192)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-08-18 18:56:08 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:103)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.loadMods(Loader.java:515)

2013-08-18 18:56:08 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:163)

2013-08-18 18:56:08 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:411)

2013-08-18 18:56:08 [iNFO] [sTDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

2013-08-18 18:56:08 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:733)

2013-08-18 18:56:08 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

 

 

RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33) Refers to where I have the addRecipe I show above, and RV97.Drinks.DrinksCore.preInit(DrinksCore.java:44) refers to when I register that piece of code (I have addRecipe under a function I run during the mod initialisation)

 

Any and all help is appreciated. :)

Link to comment
Share on other sites

Man, the abstract code is useless to us. Your implementation is what is important.

public class CraftingManager {
public static IBrewingManager brewery;
}

This looks a bit...empty, don't you think ?

 

By the way...interfaces are always abstract.

Link to comment
Share on other sites

@Mazetar

Ok, im now getting this:

 

2013-08-18 20:05:52 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by net.minecraft.item.ItemSpade@7deb98f6 while adding net.minecraft.item.Item@76877f0f

2013-08-18 20:05:52 [iNFO] [fml.ItemTracker] The mod RV97Drinks is overwriting existing item at 256 (net.minecraft.item.ItemSpade from Minecraft) with net.minecraft.item.Item

2013-08-18 20:05:52 [iNFO] [sTDOUT] CONFLICT @ 0 item slot already occupied by net.minecraft.item.Item@76877f0f while adding net.minecraft.item.Item@4aea4e2e

2013-08-18 20:05:52 [iNFO] [fml.ItemTracker] The mod RV97Drinks is overwriting existing item at 256 (net.minecraft.item.Item from RV97Drinks) with net.minecraft.item.Item

 

 

I have no idea why its mentioning the Spade item... Unless I accidentally conflicted with it with one of my items.

 

@GotoLink

I plan to add more types of crafting, so that will be the central crafting class where I, and possibly other mods, may access these crafting managers.

Link to comment
Share on other sites

Here are my BrewingManager and BrewingRecipe classes (Not to be mistaken for IBrewingManager and IBrewingRecipe), which handle adding the recipes etc.

 

BrewingManager:

package RV97.Drinks.Utils.Crafting;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidStack;

public class BrewingManager implements IBrewingManager{

private final List recipes;

public BrewingManager()
{
	this.recipes = new ArrayList();
}

public static IBrewingManager getInstance(){
	return CraftingManager.brewery;
}

public void addRecipe(ItemStack inputItemStack1, LiquidStack outputLiquidStack, int brewingTime) {
	if(inputItemStack1 == null){
		return;
	}
	this.recipes.add(new BrewingRecipe(inputItemStack1, outputLiquidStack, brewingTime));
}


public void addRecipe(ItemStack inputItemStack1, ItemStack inputItemStack2, LiquidStack outputLiquidStack, int brewingTime) {
	if((inputItemStack1 == null) || (inputItemStack2 == null)){
		return;
	}
	this.recipes.add(new BrewingRecipe(inputItemStack1, inputItemStack2, outputLiquidStack, brewingTime));
}


public void addRecipe(ItemStack inputItemStack1, LiquidStack inputLiquidStack, LiquidStack outputLiquidStack, int brewingTime) {
	if((inputItemStack1 == null) || (inputLiquidStack == null)){
		return;
	}
	this.recipes.add(new BrewingRecipe(inputItemStack1, inputLiquidStack, outputLiquidStack, brewingTime));
}


public void addRecipe(ItemStack inputItemStack1, ItemStack inputItemStack2, LiquidStack inputLiquidStack, LiquidStack outputLiquidStack, int brewingTime) {
	if((inputItemStack1 == null) || (inputItemStack2 == null) || (inputLiquidStack == null)){
		return;
	}
	this.recipes.add(new BrewingRecipe(inputItemStack1, inputItemStack2, inputLiquidStack, outputLiquidStack, brewingTime));
}


public IBrewingRecipe getRecipe(ItemStack inputStack) {
	if (inputStack == null){
		return null;
	}
	for (BrewingRecipe r : this.recipes){
		if(inputStack.isItemEqual(r.getInput1())){
			return r;
		}
	}
	return null;
}

public IBrewingRecipe getRecipe(ItemStack inputStack, ItemStack inputStack2) {
	if ((inputStack == null)||(inputStack2 == null)){
		return null;
	}
	for (BrewingRecipe r : this.recipes){
		if((inputStack.isItemEqual(r.getInput1())) && (inputStack2.isItemEqual(r.getInput2()))){
			return r;
		}
	}
	return null;
}

public IBrewingRecipe getRecipe(ItemStack inputStack, LiquidStack inputLiquid) {
	if ((inputStack == null)||(inputLiquid == null)){
		return null;
	}
	for (BrewingRecipe r : this.recipes){
		if((inputStack.isItemEqual(r.getInput1())) && (inputLiquid.isLiquidEqual(r.getLiquidInput()))){
			return r;
		}
	}
	return null;
}

public IBrewingRecipe getRecipe(ItemStack inputStack, ItemStack inputStack2, LiquidStack inputLiquid) {
	if ((inputStack == null)|| (inputStack2 == null) ||(inputLiquid == null)){
		return null;
	}
	for (BrewingRecipe r : this.recipes){
		if((inputStack.isItemEqual(r.getInput1())) && (inputStack2.isItemEqual(r.getInput2())) && (inputLiquid.isLiquidEqual(r.getLiquidInput()))){
			return r;
		}
	}
	return null;
}

public List getRecipes() {
	return this.recipes;
}


}

 

BrewingRecipe:

package RV97.Drinks.Utils.Crafting;

import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidStack;

public class BrewingRecipe implements IBrewingRecipe{
private final ItemStack inputStack;
private final ItemStack inputStack2;
private final LiquidStack inputLiquid;
private final LiquidStack resultLiquid;
private final int brewTime;

public BrewingRecipe(ItemStack inputStack, LiquidStack resultLiquid, int brewTime){
	this.inputStack = inputStack;
	this.resultLiquid = resultLiquid;
	this.brewTime = brewTime;
}

public BrewingRecipe(ItemStack inputStack, ItemStack inputStack2, LiquidStack resultLiquid, int brewTime){
	this.inputStack = inputStack;
	this.inputStack2 = inputStack2;
	this.resultLiquid = resultLiquid;
	this.brewTime = brewTime;
}

public BrewingRecipe(ItemStack inputStack, LiquidStack inputLiquid, LiquidStack resultLiquid, int brewTime){
	this.inputStack = inputStack;
	this.inputLiquid = inputLiquid;
	this.resultLiquid = resultLiquid;
	this.brewTime = brewTime;
}

public BrewingRecipe(ItemStack inputStack, ItemStack inputStack2, LiquidStack inputLiquid, LiquidStack resultLiquid, int brewTime){
	this.inputStack = inputStack;
	this.inputStack2 = inputStack2;
	this.inputLiquid = inputLiquid;
	this.resultLiquid = resultLiquid;
	this.brewTime = brewTime;
}

public int getBrewTime() {

	return this.brewTime;
}

public ItemStack getInput1() {

	return this.inputStack.copy();
}

public ItemStack getInput2() {

	if(this.inputStack2 == null){
	return null;
	}
	return this.inputStack2.copy();
}

public LiquidStack getLiquidInput() {

	if(this.inputLiquid == null){
	return null;
	}
	return this.inputLiquid.copy();
}

public LiquidStack getLiquidOutput() {

	return this.resultLiquid.copy();
}
}

Link to comment
Share on other sites

I moved the BrewingRecipe code into my brewing manager, so that should be fine. Still need to solve this crash though... I shall try re-adding all my items, just to check none of them are conflicting with 0. Shall Report back shortly.

 

EDIT: Ok, now the breakline no longer refers to id conflicts of 0 (turns out I forgot to change my config class to use my ID's for 2 items... Silly mistake ¬¬)

 

However, we are back to the original crash of:

 

2013-08-19 16:16:17 [iNFO] [sTDERR] java.lang.NullPointerException

2013-08-19 16:16:17 [iNFO] [sTDERR] at RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33)

2013-08-19 16:16:17 [iNFO] [sTDERR] at RV97.Drinks.DrinksCore.preInit(DrinksCore.java:44)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:192)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:172)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-08-19 16:16:17 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:103)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.loadMods(Loader.java:515)

2013-08-19 16:16:17 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:163)

2013-08-19 16:16:17 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:411)

2013-08-19 16:16:17 [iNFO] [sTDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

2013-08-19 16:16:17 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:733)

2013-08-19 16:16:17 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

 

Link to comment
Share on other sites

2013-08-19 16:16:17  [sTDERR] java.lang.NullPointerException

2013-08-19 16:16:17  [sTDERR]    at RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33)

 

can we see those lines ?, actually the whole class and everythign related to it, its a NPE it shouldnt be that hard

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

@hydroFlame

My Liquids class as requested:

package RV97.Drinks;

import cpw.mods.fml.common.registry.LanguageRegistry;
import RV97.Drinks.Config.ItemInfo;
import RV97.Drinks.Items.Items;
import RV97.Drinks.Utils.Crafting.CraftingManager;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;

public class Liquids {
public static Item applejackDaniels;
public static Item goldApplejackDaniels;
public static Item witherWine;
public static Item zambambooze;
public static Item spiderSpirit;

public static void init(){
	applejackDaniels = new Item(ItemInfo.LIQUID_ID).setUnlocalizedName("applejackDaniels");
	LanguageRegistry.addName(applejackDaniels, "Apple JackDaniels");
}

public static void registerLiquids(){
	LiquidDictionary.getOrCreateLiquid("Apple JackDaniels", new LiquidStack(applejackDaniels, 1));
	LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Apple JackDaniels", 1000), new ItemStack(Items.drink,1,1), new ItemStack(Items.mug)));
}

public static void registerLiquidRecipes(){
	CraftingManager.brewery.addRecipe(new ItemStack(Item.sugar), new ItemStack(Item.appleRed), new LiquidStack(Block.waterStill.blockID, 1000), new LiquidStack(Block.lavaStill, 1000), 300);
}
}

 

Line 33 is: CraftingManager.brewery.addRecipe(new ItemStack(Item.sugar), new ItemStack(Item.appleRed), new LiquidStack(Block.waterStill.blockID, 1000), new LiquidStack(Block.lavaStill, 1000), 300);

 

@GotoLink

I moved that code into the BrewingManager code, which is the only class that tries to access those lines, so that should fix it (atleast, for now).

Link to comment
Share on other sites

@hydroflame

I am not sure... Where should it be? (I might have forgotten to create a class or two, as this is my first crafting system.)

 

@GotoLink

I did indeed remove the "final" keyword :)

Nice ;)

 

In your CraftingManager constructor maybe ?  ::)

public class CraftingManager {
public static IBrewingManager brewery;
public CraftingManager(IBrewingManager brewingMnger)
{
this.brewery = brewingMnger;
}
}

Link to comment
Share on other sites

I am not sure... Where should it be? (I might have forgotten to create a class or two, as this is my first crafting system.)

"somewhere" xD

literally, the NullPointerException is due to that

you are trying to call a method on a object that doesnt exists

 

public static IBrewingManager brewery;

this mean "yeah i have a IBreingManager" (but only that i have one, it doesnt say what or who it is)

 

then you go

CraftingManager.brewery.addRecipe(args)

and the JVM goes ragemode yelling

WHO THE F*** ARE YOU TALKING ABOUT, THERE'S NOTHING THERE !!!

 

so probably in your main mod class during preinit or wtv you should make:

CraftingManager.brewery = new BrewingManager();

 

actually it doesnt matter WHERE you place that, as long as its before

 

2013-08-18 18:56:08 [sEVERE] [ForgeModLoader] Caught exception from RV97Drinks

java.lang.NullPointerException

  at RV97.Drinks.Liquids.registerLiquidRecipes(Liquids.java:33)

  at RV97.Drinks.DrinksCore.preInit(DrinksCore.java:44)

line 44 of the method preInit in class DrinksCore. because thats when the code needs it ;)

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Ok, that solved it! Thanks for the explaination, I have never heard someone explain something like that xD

 

Just to use this thread a little more, I seem to be having trouble with searching through recipes. In my BrewingManager, I try to make a getRecipe function, but on my "for (BrewingRecipe r : this.recipe)" line, eclipse is telling me "Type mismatch: cannot convert from element type Object to BrewingManager.BrewingRecipe" and as I am still kinda nooby (as you may have gathered :P) I cant't figure out a solution... (Basically, just tell me how to solve this :3)

 

Thanks for all the help so far, I really appreciate it! :)

Link to comment
Share on other sites

that actually simple, your for loop should work but your List does not specify a generic type

 

google "java generic types" and you should find a butload of info on that

but basicly you want to make a

 

private List<BrewingRecipe> theList;

instead of a

private List theList;

the first one specify its a list of Brewing recipe while the 2nd will accept anything :\

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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