Jump to content

[1.7.2] [Solved] GameRegistry.addShapelessRecipe() Don't work!


Recommended Posts

Posted

I don't know why but the GameRegistry.addShapelessRecipe(); method doesn't work.

 

Here is my code:

 

	public static void generic()
	{
		for(int a = 0; a < woodDamage.length; ++a)
		{
			GameRegistry.addShapelessRecipe(new ItemStack(Items.Soup, 1, a), new Object[] {new ItemStack(net.minecraft.init.Blocks.red_mushroom_block), new ItemStack(net.minecraft.init.Blocks.brown_mushroom_block), new ItemStack(Items.Bowl, 1, a)});
		}
	}

 

Thanks for helping!

Posted

You are just adding a vanilla recipe again. What do you expect to happen?

 

No, I'm not re-adding a vanilla recipe Items.Soup is equals to SackCastellon.betterwood.api.Items.Soup

In fact the "Soup" item in vanilla minecraft is called "mushroom_stew"

 

P.S.: Items.Bowl is equals to SackCastellon.betterwood.api.Items.Bowl

Posted

Show us where and how you initialized it.

 

RecipeLoader.class

package SackCastellon.betterwood.loader;

import java.util.Iterator;
import java.util.List;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import SackCastellon.betterwood.api.Blocks;
import SackCastellon.betterwood.api.Items;
import cpw.mods.fml.common.registry.GameRegistry;

public class RecipeLoader
{
private static final int[] woodDamage = {0, 1, 2, 3, 4, 5};

public static void init()
{
	vanilla.init();
}

private static class vanilla
{
	private static void init()
	{
		/* Blocks */

		/* Items */
		generic();
	}

	private static void generic()
	{
		for(int a = 0; a < woodDamage.length; ++a)
		{
			GameRegistry.addShapelessRecipe(new ItemStack(Items.Soup, 1, a), new Object[] {new ItemStack(net.minecraft.init.Blocks.red_mushroom_block), new ItemStack(net.minecraft.init.Blocks.brown_mushroom_block), new ItemStack(Items.Bowl, 1, a)});
			for(int b = 0; b < woodDamage.length; ++b)
			{					
				for(int c = 0; c < woodDamage.length; ++c)
				{
					for(int d = 0; d < woodDamage.length; ++d)
					{
						for(int e = 0; e < woodDamage.length; ++e)
						{
							for(int f = 0; f < woodDamage.length; ++f)
							{
								/* Sticks */
								if(a == b)
								{
									GameRegistry.addRecipe(new ItemStack(Items.Stick, 4, woodDamage[a]), new Object[] {"P", "P", 'P', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a])});
								}

								else
								{
									GameRegistry.addRecipe(new ItemStack(net.minecraft.init.Items.stick, 4), new Object[] {"P", "p", 'P', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a]), 'p', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[b])});
								}

								/* Doors */
								if(a == b && a == c && a == d && a == e && a == f &&
											 b == c && b == d && b == e && b == f &&
											 		   c == d && b == e && b == f && 
											 		   			 d == e && b == f && 
											 		   			 		   e == f)
								{
							        GameRegistry.addRecipe(new ItemStack(Items.Door, 1, woodDamage[a]), new Object[] {"XX", "XX", "XX", 'X', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a])});
								}

								else
								{
							        GameRegistry.addRecipe(new ItemStack(net.minecraft.init.Items.wooden_door, 1), new Object[] {"ab", "cd", "ef",
							        	'a', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a]),
							        	'b', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[b]),
							        	'c', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[c]),
							        	'd', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[d]),
							        	'e', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[e]),
							        	'f', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[f])});
								}

								/* Bowls */
								if(a == b && a == c
										  && b == c)
								{
							        GameRegistry.addRecipe(new ItemStack(Items.Bowl, 4, woodDamage[a]), new Object[] {"P P", " P ", 'P', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a])});
								}

								else
								{
									GameRegistry.addRecipe(new ItemStack(net.minecraft.init.Items.bowl, 4), new Object[] {"a b", " c ",
										'a', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a]),
							        	'b', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[b]),
							        	'c', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[c])});
								}
							}
						}
					}
				}
			}

			/* Mushroom Stew */
	    	GameRegistry.addShapelessRecipe(new ItemStack(Items.Soup, 1, woodDamage[a]), new Object[] {new ItemStack(net.minecraft.init.Blocks.brown_mushroom_block), new ItemStack(net.minecraft.init.Blocks.red_mushroom_block), new ItemStack(Items.Bowl, 1, woodDamage[a])});
//		    	GameRegistry.addRecipe(new ItemStack(Items.Arrow, 4, woodDamage[a]), new Object[] {"a", "b", "c", 'a', net.minecraft.init.Items.flint, 'b', new ItemStack(net.minecraft.init.Blocks.planks, 1, woodDamage[a]), 'c', net.minecraft.init.Items.feather});
		}
	}
}
}

 

The Main Class

package SackCastellon.betterwood;

import java.io.File;

import SackCastellon.betterwood.handler.*;
import SackCastellon.betterwood.loader.BlockLoader;
import SackCastellon.betterwood.loader.BlockRegister;
import SackCastellon.betterwood.loader.ItemLoader;
import SackCastellon.betterwood.loader.ItemRegister;
import SackCastellon.betterwood.loader.RecipeLoader;
import SackCastellon.betterwood.loader.TabLoader;
import SackCastellon.betterwood.proxy.CommonProxy;
import SackCastellon.betterwood.reference.Reference;
import SackCastellon.core.helper.LogHelper;
import SackCastellon.core.helper.Version;
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=Reference.ID, name=Reference.NAME, version=Reference.VERSION, dependencies=Reference.DEPENDENCIES)
public class BetterWood {

	@Instance(Reference.ID)
	public static BetterWood instance;

	@SidedProxy(clientSide=Reference.CLPROXY, serverSide=Reference.CMPROXY)
	public static CommonProxy proxy;

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		ConfigHandler.loadConfig(new File(event.getModConfigurationDirectory(), Reference.ConfigPath));

		if (ConfigHandler.CheckVersion == true) {
			Version.check(Reference.ID, Reference.NAME, Reference.VERSION, Reference.URL);
		}

		TabLoader.init();

		// Items

		try
		{
	    	LogHelper.info(Reference.ID, "Loading items.");
	    	
	    	ItemLoader.init();
	    	ItemRegister.init();
		}

		catch(Exception e)
		{
			LogHelper.error(Reference.ID, "Could not load items");
		}

		finally
		{
			LogHelper.info(Reference.ID, "Items succesfully loaded");
		}

		// Blocks

		try
		{
	    	LogHelper.info(Reference.ID, "Loading blocks.");
	    	
	    	BlockLoader.init();
	    	BlockRegister.init();
		}

		catch(Exception e)
		{
			LogHelper.error(Reference.ID, "Could not load blocks");
		}

		finally
		{
			LogHelper.info(Reference.ID, "Blocks succesfully loaded");
		}
	}

	@EventHandler
	public void init(FMLInitializationEvent event)
	{
		// Recipes
		try
		{
	    	LogHelper.info(Reference.ID, "Loading recipes.");
	    	
	    	RecipeLoader.init();
	    	GameRegistry.registerFuelHandler(new FuelHandler()); // TODO
		}

		catch(Exception e)
		{
			LogHelper.error(Reference.ID, "Could not load recipes");
		}
	}

	@EventHandler
	public void postInit(FMLPostInitializationEvent event)  {}
}

Posted

if(a == b && a == c && a == d && a == e && a == f && b == c && b == d && b == e && b == f && c == d && b == e && b == f && d == e && b == f &&  e == f)
What on earth. I doubt you know what you are doing.

 

It means if a, b, c, d, e and f are equal...

Posted

if(a == b && a == c && a == d && a == e && a == f && b == c && b == d && b == e && b == f && c == d && b == e && b == f && d == e && b == f &&  e == f)
What on earth. I doubt you know what you are doing.

 

It means if a, b, c, d, e and f are equal...

 

You can also do this and get the same result.

 

if(a == b && a == c && a == d && a == e && a == f)

 

if a == b and a == c, you don't need to then check b == c. 

 

It's called the transitive property of mathematics.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

if(a == b && a == c && a == d && a == e && a == f && b == c && b == d && b == e && b == f && c == d && b == e && b == f && d == e && b == f &&  e == f)
What on earth. I doubt you know what you are doing.

 

It means if a, b, c, d, e and f are equal...

 

You can also do this and get the same result.

 

if(a == b && a == c && a == d && a == e && a == f)

 

if a == b and a == c, you don't need to then check b == c. 

 

It's called the transitive property of mathematics.

 

Ok, thank you very much.

 

But coming back to the main topic, how can i fix the .addShapelessRecipe() problem?

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.

Announcements



×
×
  • Create New...

Important Information

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