ZidMC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

4 posters

Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by Ziddia Fri Apr 22, 2011 7:38 pm

For this tutorial, I will assume you have completed:
  • Creating a new Block
  • Creating a new Item
  • Creating a new Tool Set
  • Converted your EmeraldOre to an actual ore which drops the emerald item


Now, here goes the tutorial!

Adding a new recipe is the easiest function I know of in ModLoader- and the easiest to get an error over. Here's the base of the function:
Code:
  ModLoader.AddRecipe(new ItemStack(ItemYouWantToProduce, ItemAmountForProducing), new Object[] {
            "XXX", "XXX", "XXX" Character.valueOf('X'), The block/Item you want X to be
        });

You can just use that as a base for all your recipes, it goes directly under AddNames. Just in case you don't understand, here's a basic recipe:
Code:
  ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
            "XXX", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });

Note how it only says emeraldItem but says Item.stick? That's because the stick item is created within the Item.java file. So, you may need to use Block.anyblock or Item.anyitem in your recipes.

Heres all the recipes I made for my class (including the block which you make from emeralds which you won't have made in these tutorials):
Code:
 ModLoader.AddRecipe(new ItemStack(emeraldItem, 9), new Object[] {
            "X", Character.valueOf('X'), emeraldBlock
        });
  ModLoader.AddRecipe(new ItemStack(emeraldBlock, 1), new Object[] {
            "XXX", "XXX", "XXX", Character.valueOf('X'), emeraldItem
        });
  ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
            "XXX", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldShovel, 1), new Object[] {
            " X ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldAxe, 1), new Object[] {
            "XX ", "X| ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldHoe, 1), new Object[] {
            "XX ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldSword, 1), new Object[] {
            " X ", " X ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });

And here's the entire class(once again, including the block that you probably don't have, emeraldBlock):
Code:
package net.minecraft.src;

public class mod_Emeralds extends BaseMod
{
  public static final Block emeraldOre = new BlockEmeraldOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("emeraldOre");
  public static final Block emeraldBlock = new BlockEmerald(98, 0).setHardness(1.5F).setResistance(5.0F).setBlockName("emeraldBlock");
  public static final Item emeraldItem = new Item(2000).setItemName("emeraldItem");
  public static final Item emeraldPick = new ItemPickaxe(2001, EnumToolMaterial.2EMERALD).setItemName("emeraldPick");
  public static final Item emeraldShovel = new ItemSpade(2002, EnumToolMaterial.2EMERALD).setItemName("emeraldShovel");
  public static final Item emeraldAxe = new ItemAxe(2003, EnumToolMaterial.2EMERALD).setItemName("emeraldAxe");
  public static final Item emeraldHoe = new ItemHoe(2004, EnumToolMaterial.2EMERALD).setItemName("emeraldHoe");
  public static final Item emeraldSword = new ItemSword(2005, EnumToolMaterial.2EMERALD).setItemName("emeraldSword");
     
public mod_Emeralds()
{
  ModLoader.RegisterBlock(emeraldOre);
  ModLoader.RegisterBlock(emeraldBlock);
  emeraldOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldore.png");
  emeraldBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorial/emeraldblock.png");
  emeraldItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeralditem.png");
  emeraldPick.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldpick.png");
  emeraldShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldshovel.png");
  emeraldAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldaxe.png");
  emeraldHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldhoe.png");
  emeraldSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/tutorial/emeraldsword.png");
  ModLoader.AddName(emeraldOre, "Emerald Ore");
  ModLoader.AddName(emeraldBlock, "Emerald Block");
  ModLoader.AddName(emeraldItem, "Emerald");
  ModLoader.AddName(emeraldPick, "Emerald Pickaxe");
  ModLoader.AddName(emeraldShovel, "Emerald Shovel");
  ModLoader.AddName(emeraldAxe, "Emerald Axe");
  ModLoader.AddName(emeraldHoe, "Emerald Hoe");
  ModLoader.AddName(emeraldSword, "Emerald Sword");
  ModLoader.AddRecipe(new ItemStack(emeraldItem, 9), new Object[] {
            "X", Character.valueOf('X'), emeraldBlock
        });
  ModLoader.AddRecipe(new ItemStack(emeraldBlock, 1), new Object[] {
            "XXX", "XXX", "XXX", Character.valueOf('X'), emeraldItem
        });
  ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
            "XXX", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldShovel, 1), new Object[] {
            " X ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldAxe, 1), new Object[] {
            "XX ", "X| ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldHoe, 1), new Object[] {
            "XX ", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(emeraldSword, 1), new Object[] {
            " X ", " X ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), Item.stick
        });
}

 public String Version()
  {
  return "1.4_01";
  }

}

Hope this helps you in your mod creation!

Ziddia
Admin
Admin

Posts : 168
Join date : 2011-04-22

https://zidmc.forumotion.com

Back to top Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty Re: [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by Th3Guy Fri Apr 22, 2011 10:47 pm

The block/Item can also be a ItemStack.

It is used when accessing types of items that have one item id.

example:

Code:
ModLoader.AddRecipe(new ItemStack(emeraldPick, 1), new Object[] {
            "XXX", " | ", " | ", Character.valueOf('X'), emeraldItem, Character.valueOf('|'), new ItemStack(Item.dyePowder, 2, 11)
        });
Th3Guy
Th3Guy
Mod Developer
Mod Developer

Posts : 5
Join date : 2011-04-22

Back to top Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty Re: [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by Ziddia Sat Apr 23, 2011 5:07 am

Thanks

Ziddia
Admin
Admin

Posts : 168
Join date : 2011-04-22

https://zidmc.forumotion.com

Back to top Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty Re: [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by HiPPiE Wed Apr 27, 2011 9:52 am

Theres an error the thing in red you need to add:
Code:
Adding a new recipe is the easiest function I know of in ModLoader- and the easiest to get an error over. Here's the base of the function:

Code:
      ModLoader.AddRecipe(new ItemStack(ItemYouWantToProduce, ItemAmountForProducing), new Object[] {
                "XXX", "XXX", "XXX"[color=red],[/color] Character.valueOf('X'), The block/Item you want X to be
            });

HiPPiE
Crafter

Posts : 13
Join date : 2011-04-24
Age : 29

Back to top Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty Re: [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by Will.Ez Wed Apr 27, 2011 9:59 am

arg you know forum codes dont work in "code" tags, what HiPPiE means is
"XXX", Character.valueOf('X')
there you forgot the , between "XXX" and Character.va....
Will.Ez
Will.Ez
Iron Miner

Posts : 52
Join date : 2011-04-22
Age : 27

Back to top Go down

[Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11] Empty Re: [Beginner] Creating a new Recipe [22/4/11] [1.4_01] [2.11]

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum