This tutorial is an updated version of the old Muserae's Minecraft Tutorial, found Here.
Since displaying codes on the forums text wraps, the codes might be hard to read. I recommend copy pasting the code into Eclipse or NotePad++ if you're having trouble reading it.
First, you want to create a new .java and name it mod_*, replacing * with whatever you want.
This tutorial will be based off the java named mod_Tutorial
package net.minecraft.src;
import java.util.Map;
import net.minecraft.client.Minecraft;
public class mod_Tutorial extends BaseMod{
public mod_Tutorial()
{
//Block and item "Description" goes here.
}
//If you don't know, a // means it's a comment and is ignored in game
//Declaring blocks and items go here
public String getVersion(){return "Mod name and version here";}
public void load() {}
}
You'll want to make a new java named Block* replacing the * with a name. You'll also need to make sure you have a mod_ class. You can use your Block* class for related blocks. If you use BlockOre as an example, multiple Blocks are created there (Gold Ore, Iron Ore, Diamond Ore, ect)
This example will be BlockTutorial.
package net.minecraft.src;
import java.util.Random;
public class BlockTutorial extends Block
{
public BlockTutorial(int i, int j, Material material)
{
super(i, Material.rock);
//You can replace rock with other materials, refer to the Block Materials tutorial for a list of materials
//And a definition of what each material does
}
public int idDropped(int par1, Random par2Random, int par3)
{
return <<BlockIDHere>>;
//For a custom item or block, you want mod_Tutorial.yourBlock.blockID/mod_Tutorial.yourItem.shiftedIndex;
//For a Block, you want Block.dirt.blockID;
//For an Item, you want Item.stick.shiftedIndex;
}
}
mod_Tutorial
You can delete the crafting recipe if you don't want it.
Refer to the mod_ Template Explained tutorial for help on textures, crafting recipes, etc.
package net.minecraft.src;
import java.util.Map;
public class mod_Tutorial extends BaseMod{
public mod_Tutorial()
{
tutorialBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/folder/tutorialBlock.png");
ModLoader.addName(tutorialBlock, "Block Tutorial");
ModLoader.registerBlock(tutorialBlock);
ModLoader.addRecipe(new ItemStack(tutorialBlock, 1), new Object[] {
"MMM", "MSM", "MNM", Character.valueOf('M'), Item.ingotIron, Character.valueOf('S'), Block.dirt, Character.valueOf('N'), Item.stick});
}
public static Block tutorialBlock = new BlockTutorial(200, 0, Material.rock).setHardness(0.6F).setResistance(5F).setBlockName("tutorialBlock");
public String getVersion(){return "Mod name and version here";}
public void load() {}
}
You'll want to make a new java file and name it Item* replacing * with a name. Make sure you have a mod_ file.
This tutorial will use an example of ItemTutorial. You can use an item file with multiple items. For example, ItemSword is used for all types of swords.
ItemTutorial
package net.minecraft.src;
public class ItemTutorial extends Item
{
public ItemTutorial (int i)
{
super (i);
maxStackSize = 64; //You can change 64 to anything from 1-64
}
}
mod_Tutorial
You can delete the crafting recipe if you don't want it.
Refer to the mod_ Template Explained for help on textures, crafting recipes, etc.
package net.minecraft.src;
import java.util.Map;
public class mod_Tutorial extends BaseMod{
public mod_Tutorial()
{
//<Item Name>
tutorialItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/folder/tutorialItem.png");
ModLoader.addName(tutorialItem, "Tutorial Item");
ModLoader.addRecipe(new ItemStack(tutorial, 1), new Object[] {
"MMM", "MSM", "MMM", Character.valueOf('M'), Block.stone, Character.valueOf('S'), Item.stick});
}
public static Item tutorial = (new ItemTutorial(500)).setItemName("tutorialItem");
public String getVersion(){return "Mod name and version here";}
public void load(){}
}
This tutorial requires a new java class named Block* replacing the * with a name. Make sure you have a mod_ file.
This tutorial will use BlockTutorial and mod_Tutorial.
I recommend reading the notes and comments added in the Basic Block tutorial first.
BlockTutorial
package net.minecraft.src;
import java.util.Random;
public class BlockTutorial extends Block
{
protected BlockTutorial(int par1, int par2, Material par3Material)
{
super(par1, par3Material);
setTickRandomly(true);
float f = 0.2F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3F, 0.5F + f);
}
protected BlockTutorial(int par1, int par2)
{
this(par1, par2, Material.plants);
}
//Will take the blocks in the canThisPlantGrowOnThisBlockID method and will allow or not allow you to place it on the block
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
return super.canPlaceBlockAt(par1World, par2, par3, par4) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
}
//You can add or remove blocks you don't want it to generate on
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
return par1 == Block.grass.blockID || par1 == Block.dirt.blockID || par1 == Block.tilledField.blockID;
}
//Tells what to do when a block next to the flower breaks
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
checkFlowerChange(par1World, par2, par3, par4);
}
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
checkFlowerChange(par1World, par2, par3, par4);
}
//Tells to drop the block as an item (the block will return itself)
protected final void checkFlowerChange(World par1World, int par2, int par3, int par4)
{
if (!canBlockStay(par1World, par2, par3, par4))
{
dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
public boolean canBlockStay(World par1World, int par2, int par3, int par4)
{
return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i)
{
return null;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 1;
}
}
For the mod_Tutorial part, refer to the Basic Block tutorial.
Only difference is this
public static Block tutorial = new BlockTutorial(200, 0, Material.rock).setHardness(0.6F).setResistance(5F).setBlockName("tutorial");
will change to this
public static Block tutorial = new BlockTutorial(200, 0).setHardness(0.6F).setResistance(5F).setBlockName("tutorial");
Since displaying codes on the forums text wraps, the codes might be hard to read. I recommend copy pasting the code into Eclipse or NotePad++ if you're having trouble reading it.
You'll want to make a new java named Block* replacing the * with a name. You'll also need to make sure you have a mod_ class. You can use your Block* class for related blocks. If you use BlockOre as an example, multiple Blocks are created there (Gold Ore, Iron Ore, Diamond Ore, ect)
This example will be BlockTutorial.
mod_Tutorial
You can delete the crafting recipe if you don't want it.
Refer to the mod_ Template Explained tutorial for help on textures, crafting recipes, etc.
mod_Tutorial
You can delete the crafting recipe if you don't want it.
Refer to the mod_ Template Explained for help on textures, crafting recipes, etc.
For the mod_Tutorial part, refer to the Basic Block tutorial.