Jump to content

Trouble with Vanilla Recipe (Repeaters)


Pentagear

Recommended Posts

So I recently picked up Modding and have successfully made a couple recipes based on the Forge tutorials. What I'm running into however, is when I attempt to use Redstone Repeaters in a recipe, it crashes the client. I'm sure there is something I'm missing, perhaps the ItemStack object cannot handle BlockRedstoneRepeater types.

 

Here's an example of a recipe I'd like to use them in (all other block types work for this recipe so code is omitted):

 

ItemStack furnaceStack = new ItemStack(Block.furnaceIdle);
ItemStack obsidianStack = new ItemStack(Block.obsidian);
ItemStack ironBlockStack = new ItemStack(Block.blockSteel);
ItemStack repeaterStack = new ItemStack(BlockRedstoneRepeater.redstoneRepeaterIdle);
ItemStack redstoneBlockStack = new ItemStack(Block.field_94341_cq);
ItemStack blockDiamondStack = new ItemStack(Block.blockDiamond);

GameRegistry.addRecipe(
blockDiamondStack,
"bab", "aea", "cdc",
"a",obsidianStack,
"b",ironBlockStack,
"c",repeaterStack,
"d",redstoneBlockStack,
"e",furnaceStack
);

 

I'm sorry if this is a really simple problem, but I couldn't find anything after searching on it for several hours. Do I need to modify or extend a class to enable this? What do I do?

 

I forgot to mention that the blockDiamondStack is there as a placeholder until I learn how to create entirely new blocks.

Link to comment
Share on other sites

The redstone repeater block is unobtainable in vanilla, it only gets placed by the repeater Item. When it gets destroyed, it also drops that Item (much like reeds do).

Ah, that makes sense. Thank you diesieben07. How would I go about allowing the use of repeaters in a recipe? I've seen other Mods with the ability to use them, what am I missing here?

Link to comment
Share on other sites

Awesome! Looks like that works. Where in the project explorer would I find a list of similar behaved items, so I don't have to ask again? :)

 

Edit: Nevermind! Found the Item list in net.minecraft.item > Item.java... Thanks again for the help diesieben07!

Link to comment
Share on other sites

Tested your problem

 

both :

        GameRegistry.addRecipe(new ItemStack(Block.dirt, 1), new Object[]{"P", 'P', new ItemStack(Item.redstoneRepeater,1)});

 

        GameRegistry.addRecipe(new ItemStack(Block.dirt, 1), new Object[]{"P", 'P', Item.redstoneRepeater});

 

20130323231102.png

 

I have no problem at all. dont know what you are doing, but it must be something else !

Link to comment
Share on other sites

Quite literally the result of ending the 2nd tutorial is what my code is. The only difference being is that I'm not using the recipes in the tutorial, rather just my own, the only code I've changed in that tutorial is in the Generic.java file:

 

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Generic", name="Generic", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Generic {

// The instance of the mod that Forge uses
@Instance("Generic")
public static Generic instance;

// Say where the client and server 'proxy' code are loaded
@SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")
public static CommonProxy proxy;

@PreInit
public void preInit(FMLPreInitializationEvent event) {
	// Stub Method
}

@Init
public void load(FMLInitializationEvent event) {

	proxy.registerRenderers();

	ItemStack furnaceStack = new ItemStack(Block.furnaceIdle);
	ItemStack obsidianStack = new ItemStack(Block.obsidian);
	ItemStack ironBlockStack = new ItemStack(Block.blockSteel);
	ItemStack repeaterStack = new ItemStack(Item.redstoneRepeater);
	ItemStack redstoneBlockStack = new ItemStack(Block.field_94341_cq);
	ItemStack blockDiamondStack = new ItemStack(Block.blockDiamond);

	GameRegistry.addRecipe(
		blockDiamondStack,
		"bab", "aea", "cdc",
		"a",obsidianStack,
		"b",ironBlockStack,
		"c",repeaterStack,
		"d",redstoneBlockStack,
		"e",furnaceStack
	);

}

@PostInit
public void postInit(FMLPostInitializationEvent event) {
	// Stub Method
}

}

 

That was my assumption too, that it was something else, but I've literally only tinkered with the Generic.java file.

Link to comment
Share on other sites

Tested your problem

 

both :

        GameRegistry.addRecipe(new ItemStack(Block.dirt, 1), new Object[]{"P", 'P', new ItemStack(Item.redstoneRepeater,1)});

 

        GameRegistry.addRecipe(new ItemStack(Block.dirt, 1), new Object[]{"P", 'P', Item.redstoneRepeater});

 

20130323231102.png

 

I have no problem at all. dont know what you are doing, but it must be something else !

 

I noticed that you are using a format that I haven't seen.

new Object[]{"P",'P', new ItemStack(Item.redstoneRepeater,1)}

and

new Object[]{"P",'P', Item.redstoneRepeater}

 

I understand what these mean, though is this how I have to identify those particular items, inside an Object?

Link to comment
Share on other sites

SOLVED!

 

Now using:

@Init
public void load(FMLInitializationEvent event) {
	proxy.registerRenderers();

	// BionikCraft: Redstone Furnace
	GameRegistry.addRecipe(
		new ItemStack(Block.bedrock, 1),
		new Object[] {
			"bab", "aea", "cdc",
			'a', Block.obsidian,
			'b', Block.blockSteel,
			'c', Item.redstoneRepeater,
			'd', Block.field_94341_cq,
			'e', Block.furnaceIdle
		}	
	);

}

 

Seems that for some reason ("a", obj, "b", obj, "c", obj) is in fact different than ('a', obj, 'b', obj, 'c', obj). My own stupid fault for assuming quotes were similar. I'm familiar with other C based languages, though this is the first time I've run into this kind of problem with strings.

 

Tested and working. Thanks again both of you.

Link to comment
Share on other sites

The reason why "a" obj does not work is that "a" is a string the object requires a character/char 'a'

 

so in short

"a" = string

'a' = character

 

Ahhh okay. Thanks for that! I will keep that in mind for the future.

 

At first it seemed an odd little quirk but when I started looking and really thinking about the construction of addRecipe, it makes sense that they are considered different.

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.

Announcements



×
×
  • Create New...

Important Information

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