Battlefield's mods

Creative API

This is the place where all the syntaxes and information about Creative API can be get.

Table of content

Syntax

Syntax for adding normal blocks

CAPI.addBlock(blocknamehere);

Working example

CAPI.addBlock(Block.monsterspawner);

Syntax for adding blocks with subtypes

CAPI.addSubtypeBlock(blocknamehere, damageValue);

Working example

CAPI.addSubtypeBlock(Block.cloth, 14);

Syntax for adding items with subtypes

CAPI.addSubtypeItem(item, damageValue);

Working example

CAPI.addSubtypeItem(Item.dyePowder, 14);



Full mod-test file that you can use as a template

package net.minecraft.src;
						
public class mod_test extends BaseMod {
	public String getVersion() {
		return "CAPI r6 test";
	}
	
	
	public void load() {
		CAPI.addBlock(Block.silverfish);
		CAPI.addBlock(Block.mobSpawner);
		CAPI.addBlock(lolblock1);

									
		CAPI.addSubtypeItem(lolitem, 1);
		CAPI.addSubtypeItem(lolitem, 2);

		ModLoader.RegisterBlock(lolblock1);

									
		ModLoader.AddName(lolblock1, "Lol Block");
		ModLoader.AddName(lolitem, "Lol Item");
	}
								
	public static final Block lolblock1 = (new BlockDirt(135, 1).setBlockName("lolblock").setHardness(0F).setLightValue(1F));
	public static final Item lolitem = (new SubItem(200).setItemName("lolitem"));

}



Your mod users don't want to use CAPI?
Put all the CAPI calls in like this.

public void load()
{
	ModLoader.RegisterBlock(lolblock1);
							
	ModLoader.AddName(lolblock1, "Lol Block");
	ModLoader.AddName(lolitem, "Lol Item");
	try
	{
								
		CAPI.addBlock(Block.silverfish);
		CAPI.addBlock(Block.mobSpawner);
		CAPI.addBlock(lolblock1);
		CAPI.addSubtypeItem(lolitem, 1);
		CAPI.addSubtypeItem(lolitem, 2);
							
	} catch (NoClassDefFoundError e)
	{
		ModLoader.getLogger().fine((new StringBuilder("CAPI not found! Not adding items to creative gui.")).toString());
	}
						
}

Getting errors?
If your error looks like this

java.lang.IllegalArgumentException: Remove item with damage value 0 from CAPI call
at net.minecraft.src.CAPI.addSubtypeItem(CAPI.java:29)
at net.minecraft.src.mod_test.load(mod_test.java:16)
at net.minecraft.src.ModLoader.init(ModLoader.java:739)
at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.java:162)
at net.minecraft.src.RenderManager.(RenderManager.java:104)
at net.minecraft.src.RenderManager.(RenderManager.java:42)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:314)
at net.minecraft.client.Minecraft.run(Minecraft.java:613)
at java.lang.Thread.run(Unknown Source)

just remove your CAPI call that includes damage value of 0

CAPI.addSubtypeItem(item, 0);

CAUTION: this is just for items not blocks

If error doesnt look like the one described above contact me on minecraft forums (my profile on minecraft forums) and I'll see what I can do about it.


Getting duplicated blocks?
Insert this syntax next to your CAPI calls.

CAPI.devider = true;
Downloads
Older versions