This tutorial assumes that you have set up forge and eclipse with MCP and have already decompiled.
Tutorial List(Red: Not Done, Green: Done, Maroon: Will Do Soonl)
Your First Mod Class
Your First Item
Your First Block
Texturing Items and Blocks
Smelting
Crafting
*To do, add more*
Your First Mod Class
As said at the top of the page these tutorials assume that you have setup forge and eclipse and have already decompiled.
To start of a mod you need a class.
package firemods;
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.stats.Achievement;
import net.minecraft.stats.AchievementList;
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="TMJ", name="Testing My Java", version="0.5.2 Alpha")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Testingmajava
{
public static CreativeTabs tabtmj = new CreativeTabs("tabTMJ") {
public ItemStack getIconItemStack() {
return new ItemStack(CoalBlock);
}
};
@Instance("Generic")
public static Testingmajava instance;
private final static Item genericItem = new TestItem(5000);
public final static Block CoalBlock = new CoalBlock(500, Material.ground)
.setHardness(0.5F).setStepSound(Block.soundClothFootstep).setUnlocalizedName("cblock").setCreativeTab(tabtmj);
// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="firemods.client.ClientProxy", serverSide="firemods.CommonProxy")
public static CommonProxy proxy;
@PreInit
public void preInit(FMLPreInitializationEvent event) {
}
@Init
public void load(FMLInitializationEvent event) {
proxy.registerRenderers();
//Names
LanguageRegistry.addName(genericItem, "Dat Item");
LanguageRegistry.addName(CoalBlock, "Coal Block");
LanguageRegistry.instance().addStringLocalization("itemGroup.tabTMJ", "en_US", "Testing Blocks/Items For Mod");
//Registering Blocks
GameRegistry.registerBlock(CoalBlock, "cblock");
//Recipes
GameRegistry.addRecipe(new ItemStack(CoalBlock), "xxx", "x x", "xxx",
'x', Item.coal);
//Smelting
GameRegistry.addSmelting(CoalBlock.blockID, new ItemStack(Block.blockNetherQuartz), 1.0f);
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
// Stub Method
}
}
This is my main mod class but first you have to set up a package to put your classes in.
Click the Box like thing next to the create class button, when you hover over it, it should say "New Java Package".
When you create the package you should name it something to do with your mod ie. "Firemods.modnamehere".
then create a new package again but this time just add ".client" to the end ie. "Firemods.modnamehere.client"
Now we need to create Proxy classes and our mod class. That is why you created the ".client".
Common Proxy
Put this new class inside your "Firemods.modnamehere"
package firemods;
public class CommonProxy {
public void registerRenderers()
{
}
}
Client Proxy
Put this class inside the "Firemods.modnamehere.client"
package firemods.client;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraftforge.client.MinecraftForgeClient;
import firemods.CommonProxy;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderers()
{
}
}
Main Class
This goes inside the "Firemods.modnamehere" along with all you block and item classes.
package firemods;
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.stats.Achievement;
import net.minecraft.stats.AchievementList;
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="TESTINMAJAVA", name="YOURMODNAMEHERE", version="0.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Testingmajava
{
@Instance("Generic")
public static Testingmajava instance;
@SidedProxy(clientSide="firemods.client.ClientProxy", serverSide="firemods.CommonProxy")
public static CommonProxy proxy;
@PreInit
public void preInit(FMLPreInitializationEvent event) {
}
@Init
public void load(FMLInitializationEvent event) {
proxy.registerRenderers();
//Names(Names here)
//Registering Blocks(Block Registering go here)
//Recipes(Recipes go here)
//Smelting(Smelting Recipes go here)
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
// Stub Method
}
}
Congratulations You just made you first mod class. Press the little green arrow named "Run Client" to watch your mod do absolutely nothing.
Your First Item
Items are rather easy to create,
TestItem
package firemods;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class TestItem extends Item
{
public TestItem(int par1) {
super(par1);
setMaxStackSize(64);
setCreativeTab(Creativetabs.tabMisc);
setUnlocalizedName("genericItem");
}
}
You can change Max stack size to a number between 1 and 64.
The creative tab doesnt have to be there and can be changed between the various tabs.
The Unlocalized name can be changed as well but try to make sure it does not conflict with other names.
Add this under @Instance and public static TMJ(or whaterver yours is called)
private final static Item genericItem = new TestItem(ITEMID);
replace ITEMID with a number.
Your First Block
Blocks are easy as well.
I'm creating a coal block because I want to so here is the code I was using.
package firemods;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
public class CoalBlock extends Block
{
public CoalBlock(int par1, Material par2Material) {
super(par1, par2Material);
}
}
Rather simple.
Add this to the main mod class
Under @Instance
public final static Block CoalBlock = new CoalBlock(500, Material.ground)
.setHardness(0.5F).setStepSound(Block.soundClothFootstep).setUnlocalizedName("cblock").setCreativeTab(creativetabs.tabMisc);
You can change the footstep sound but I just like cloth.
Nice tutorials! I was looking for some good ones that explain everything well and yours does just that. I recently switched to forge for the benefits. I was wondering if you could make a tutorial on how to make a mob hold an item and wear armor. That would be great.
Tutorial List(Red: Not Done, Green: Done, Maroon: Will Do Soonl)
Your First Mod Class
Your First Item
Your First Block
Texturing Items and Blocks
Smelting
Crafting
*To do, add more*
As said at the top of the page these tutorials assume that you have setup forge and eclipse and have already decompiled.
To start of a mod you need a class.
This is my main mod class but first you have to set up a package to put your classes in.
Click the Box like thing next to the create class button, when you hover over it, it should say "New Java Package".
When you create the package you should name it something to do with your mod ie. "Firemods.modnamehere".
then create a new package again but this time just add ".client" to the end ie. "Firemods.modnamehere.client"
Now we need to create Proxy classes and our mod class. That is why you created the ".client".
Common Proxy
Put this new class inside your "Firemods.modnamehere"
Client Proxy
Put this class inside the "Firemods.modnamehere.client"
Main Class
This goes inside the "Firemods.modnamehere" along with all you block and item classes.
Congratulations You just made you first mod class. Press the little green arrow named "Run Client" to watch your mod do absolutely nothing.
Items are rather easy to create,
TestItem
You can change Max stack size to a number between 1 and 64.
The creative tab doesnt have to be there and can be changed between the various tabs.
The Unlocalized name can be changed as well but try to make sure it does not conflict with other names.
Main Mod Class
Add this under Names
Add this under @Instance and public static TMJ(or whaterver yours is called)
replace ITEMID with a number.
Blocks are easy as well.
I'm creating a coal block because I want to so here is the code I was using.
Rather simple.
Add this to the main mod class
Under @Instance
You can change the footstep sound but I just like cloth.
Add this under names
You can change the "Coal Block" to whatever name you want it to be.
Add under Registering Blocks
Now you are done.
2 new dimensions!!!