Install the API like Modloader in the minecraft.jar before using MCP.
Add the following into load() of your mod_ file:
add simple blocks:
CreativeAPI.addBlock(yourBlock);
add blocks with subtypes (like wool):
CreativeAPI.addBlock(yourBlock, 1);
add items with subtypes (like dyes or charcoal):
CreativeAPI.addItem(yourItem, 1);
Regular items don't need to add!
Pro-Tipp:
Use try/catch to avoid minecraft crashing, for user they won't play in Creative Mode or install the API.
Example:
public class mod_YourMod extends BaseMod
{
public static final Block yourBlock= new Block(200);
public load()
{
ModLoader.registerBlock(yourBlock);
ModLoader.addName(yourBlock, "Block Name");
ModLoader.addRecipe(...);
try
{
CreativeAPI.addBlock(yourBlock);
CreativeAPI.addItem(Item.coal, 1);
} catch (NoClassDefFoundError e)
{
ModLoader.getLogger().fine((new StringBuilder("Creative API not found! ")).toString());
}
}
public String getVersion()
{
return "1.2.4";
}
}