Jump to content

Recommended Posts

Posted

Hey! Newtime modder here and I am having some trouble with getting recipes to work. I have looked through countless tutorials to see if I am doing anything wrong but to no avail. Here's my code.

 

package nikolater.RiseOfAvnycyn;

import net.minecraft.block.Block;
import net.minecraft.block.Block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
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="ROA", name="RiseOfAvnycyn", version="0.0.0")

public class RiseOfAvnycyn {

@Instance(value="ROA")
public static RiseOfAvnycyn instance;

@SidedProxy(clientSide="nikolater.RiseOfAvnycyn.client.ClientProxy", serverSide="nikolater.RiseOfAvnycyn.CommonProxy")
public static CommonProxy proxy;

public static Item bronzeIngot;
public static Item bronzeMeld;

public static Block copperOre;
public static Block tinOre;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	Item bronzeIngot = new GenericItem(64, "BronzeIngot");
	Item bronzeMeld = new GenericItem(64, "BronzeMeld");

	Block copperOre = new GenericBlock(Material.rock, 2.0F, Block.soundTypeStone, "CopperOre", "pickaxe", 1);
	Block tinOre = new GenericBlock(Material.rock, 2.0F, Block.soundTypeStone, "TinOre", "pickaxe", 1);

	GameRegistry.registerItem(bronzeIngot, bronzeIngot.getUnlocalizedName());
	GameRegistry.registerItem(bronzeMeld, bronzeMeld.getUnlocalizedName());

	GameRegistry.registerBlock(copperOre, "CopperOre");
	GameRegistry.registerBlock(tinOre, "TinOre");
}

@EventHandler
public void init(FMLInitializationEvent event) {
	proxy.registerRenderers();


	ItemStack copperOreStack = new ItemStack(RiseOfAvnycyn.copperOre);
	ItemStack tinOreStack = new ItemStack(RiseOfAvnycyn.tinOre);

	GameRegistry.addShapelessRecipe(new ItemStack(RiseOfAvnycyn.bronzeMeld, 4), copperOreStack, copperOreStack, copperOreStack, tinOreStack);

	GameRegistry.addSmelting(RiseOfAvnycyn.bronzeMeld, new ItemStack(RiseOfAvnycyn.bronzeIngot), 1F);

}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {

}

}

Posted

Hey! Newtime modder here and I am having some trouble with getting recipes to work. I have looked through countless tutorials to see if I am doing anything wrong but to no avail. Here's my code.

 

package nikolater.RiseOfAvnycyn;

import net.minecraft.block.Block;
import net.minecraft.block.Block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
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="ROA", name="RiseOfAvnycyn", version="0.0.0")

public class RiseOfAvnycyn {

@Instance(value="ROA")
public static RiseOfAvnycyn instance;

@SidedProxy(clientSide="nikolater.RiseOfAvnycyn.client.ClientProxy", serverSide="nikolater.RiseOfAvnycyn.CommonProxy")
public static CommonProxy proxy;

public static Item bronzeIngot;
public static Item bronzeMeld;

public static Block copperOre;
public static Block tinOre;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	Item bronzeIngot = new GenericItem(64, "BronzeIngot");
	Item bronzeMeld = new GenericItem(64, "BronzeMeld");

	Block copperOre = new GenericBlock(Material.rock, 2.0F, Block.soundTypeStone, "CopperOre", "pickaxe", 1);
	Block tinOre = new GenericBlock(Material.rock, 2.0F, Block.soundTypeStone, "TinOre", "pickaxe", 1);

	GameRegistry.registerItem(bronzeIngot, bronzeIngot.getUnlocalizedName());
	GameRegistry.registerItem(bronzeMeld, bronzeMeld.getUnlocalizedName());

	GameRegistry.registerBlock(copperOre, "CopperOre");
	GameRegistry.registerBlock(tinOre, "TinOre");
}

@EventHandler
public void init(FMLInitializationEvent event) {
	proxy.registerRenderers();


	ItemStack copperOreStack = new ItemStack(RiseOfAvnycyn.copperOre);
	ItemStack tinOreStack = new ItemStack(RiseOfAvnycyn.tinOre);

	GameRegistry.addShapelessRecipe(new ItemStack(RiseOfAvnycyn.bronzeMeld, 4), copperOreStack, copperOreStack, copperOreStack, tinOreStack);

	GameRegistry.addSmelting(RiseOfAvnycyn.bronzeMeld, new ItemStack(RiseOfAvnycyn.bronzeIngot), 1F);

}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {

}

}

What happens when you run your code?

Does it crash?

If so, give the crash report.

If it doesnt crash, say what happens.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Its just as I said nothing crashes its just that when I try to use any of the recipes nothing comes up in the result box.

First of all, you have to register stuff in the pre-init. Though that shouldn't totally affect it...

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Yeah I had tried registering it in the preInit before but it still didn't wok :(

Does your smelting work?

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Posted

Hi.

 

Are you sure this line is executed?

 

GameRegistry.addShapelessRecipe(new ItemStack(RiseOfAvnycyn.bronzeMeld, 4), copperOreStack, copperOreStack, copperOreStack, tinOreStack);

 

If so, and if you can use the debugger, try putting a breakpoint in here

ShapelessRecipes.matches()

 

It creates a copy of the shapeless recipe list (look in here, see if you can find yours), then iterates through each slot in the crafting container, and for each recipe which doesn't have the right item in the recipe, it deletes it.

 

By comparing your recipe with the crafting entries, you can see why this line isn't matching your recipe:

                        if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))

 

-TGG

 

Posted

I just decided to look at the log and apparently the registry is not adding any of the recipes that I have made. Any tips for how I would fix that?

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.