Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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!

  • Author

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

  • Author

Then I don't know. Make sure the items are initialized when you create the ItemStack / recipe.

 

It is correctly initialized, but i have other normal recipes .addRecipe(); that work well.  :(

  • Author

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)  {}
}

  • Author

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...

  • Author

I know what that means. I doubt you want to nest 6 or however many that is loops. What are you trying to do there?

 

If 6 blocks are the same then add one crafting recipe, else add another...

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.

  • Author

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?

Blocks.brown_mushroom and Blocks.brown_mushroom_block are two different things.

Make sure you are not confusing one for the other.

  • Author

Blocks.brown_mushroom and Blocks.brown_mushroom_block are two different things.

Make sure you are not confusing one for the other.

 

Oh, that's the problem  ;D

Thank you.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.