Hello everyone and this is my tutorial for modding. I will be going slow and telling you guys how to create or make mods in minecraft with modloader. This tutorial will also tell you how to set up it so you can start modding.
I hope you enjoy.
Installing / Setting up:
1. Before we can starting modding we have to set up minecraft coder pack and install modloader. To edit or create mods im going to be using eclipse but you can use any text editor you have (I Recommend using eclipse).
2. To download MCP (minecraft coder pack) goto http://mcp.ocean-lab...hp/MCP_Releases,
make sure you download the latest MCP. Goto http://adf.ly/DDYvr to download modloader or search it up if you have a newer version of minecraft. Now goto http://adf.ly/DDZaK to download eclipse. Make sure that the eclipse you are downloading is Eclipse IDE for Java Developers and choose the 32 bit or 64 bit download
3. Once you have downloaded all of them goto to start and type in "%appdata%", then goto .minecraft\bin and open up the "minecraft.jar" file with "winrar", now you can copy all the "modloaders" files into the "minecraft.jar".
4. Now once you have installed modloader you can set up minecraft coder pack, but before doing that make sure that you run minecraft to see if you have installed modloader right. Once you have tested miencraft open up the "MCP" folder, also open up the ".minecraft" folder and copy the "bin" and "resources" folders and put them in the "MCP\jars" folder. Now you are ready to decompile minecraft, so now go back to the "MCP" folder and open up the "decompile.bat" file. This should take few seconds, once it is done close the "decompile.bat".
5. Once you have closed the "decompile.bat" open up eclipse (from the winrar folder or just extract the files in the winrar folder to a folder to your desktop or somewhere you can easily open eclipse from). Now a window should pop up asking you to pick a default folder. You want to click browse and goto your "MCP" folder and select "eclipse" folder.
6. Now just click ok and you are done.
Creating a class:
To create a Item what we need to do is to create a new class. To do that click on the "client" on the left window, then click on "src" and then "net.minecraft.src;". Now this will open up all the minecraft classes. To make our own class right click on "net.minecraft.src;" and go "new/class". Make sure that when ever you are making a mod with modloader make the class name "mod_" and then your mod name like this "mod_YourModName".
Now that we have made our mod class it should look like this:
package net.minecraft.src;
public class mod_YourModName
{}
Now before we starting making our mod we have to add some more code to make it so thats with modloader:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public void load()
{
}
public String getVersion()
{
return "1.3.2";
}
}
"extends BaseMod" means it is going to allow us to use the methods in inside the BaseMod.java "public void load()" is where we are going to be calling all the modloaders methods "public String getVersion()" we have to return the latest version of minecraft for me it is 1.3.2. This also fixes a error that will get if we dont put this here, you can test it if you want just delete the "public String getVersion()" method and you will see a red line under your class name.
This is the end of the first tutorial. I hope you have learn't how to create a class with eclipse
Creating items:
Lets get started creating our own class. To make a item we want to start off by typing "public static final Item" other the Item we put the name of the item we ant to create. Im going to name mine "redDiamond". So now it should look something like this:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond
public void load()
{
}
public String getVersion()
{
return "1.3.2";
}
}
Other we have given our item a name lets give it some properties. To do that we want to add the code below:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond");
public void load()
{
}
public String getVersion()
{
return "1.3.2";
}
}
"(new Item(1000))" is the item id. The id can not be the same as any other items id. ".setItemName("redDiamond")" this is just setting the item name (THIS IS NOT THE IN GAME NAME).
You can also add on ".setTabToDisplayOn(CreativeTabs.tabMaterials)" this will make it so that the
item will show up in the creative menu under the "tabMaterials". I will put a list of all the tabs you can use at the bottom of this tutorial. this is the code with the creative tab part added on:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public void load()
{
}
public String getVersion()
{
return "1.3.2";
}
}
Now that we have made our item with properties lets start adding in the image and the in game name to it. To add the in game name we have to put in "ModLoader.addName(redDiamond, "Red Diamond");" the "ModLoader" is how we call a modloader method, so if we add ".addName()" onto it we will call the addName method. Now once you have added "ModLoader.addName()" in the "()" you want to first put the name of the item you want the in game name to be for me it is "redDiamond", after you have done that you put a "," when to double quotes and in side the double quotes you what to put the in game name. Once you have done that your code should look something like this
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public void load()
{
ModLoader.addName(redDiamond, "Red Diamond");
}
public String getVersion()
{
return "1.3.2";
}
}
So after you have done that lets add a image. To add a image to the item you have to do things a little different then we did to add the in game name. You want to add this code "redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");". Now the "redDiamond" is where you put your item name and then you can add on ".iconIndex". This is calling the method "iconIndex". After you have added that we put in "= ModLoader" this is so that the game knows that we want to call something from the "ModLoader.java" file. After that we put or add in the ".addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png")" this means that we are going to add a image of our own to the image "items.png". Now the your code should look like this:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public void load()
{
ModLoader.addName(redDiamond, "Red Diamond");
redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");
}
public String getVersion()
{
return "1.3.2";
}
}
Here is the creative tab list:
> Materials
> Brewing
> Combat
> Tools
> Foodstuffs
> Miscellaneous
> Transportation
> Redstone
> Decoration Blocks
> Building Blocks
Ok guys i hope you enjoyed this tutorial that is all we are going to do for now
Creating Weapons:
Hello guys on this tutorial i will be teaching you how to create a weapon (sword). So lets get started.
First you need to know how to create a enum tool material so if you dont know how to create enum tool material please go and do that tutorial first and then come back here. Now if you know how to create a enum tool material lets get started.
first off you want to go to our "mod_YourModName" class with the item in it. Once you are there to make it easy for your self copy the Item we made and paste below the item we made. Now you should have this:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public void load()
{
ModLoader.addName(redDiamond, "Red Diamond");
redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");
}
public String getVersion()
{
return "1.3.2";
}
}
You should get some errors that is fine it just meas that you cant have to items the some name. Now we are going to change the item name and where it has "(new Item(1000))" change Item to waht ever you named your ItemSword class i named mine ItemYourModNameSword so i will change Item to that. After doing that your code should look something like this:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item redDiamondSword = (new ItemYourModNameSword(1000)).setItemName("redDiamondSword").setTabToDisplayOn(CreativeTabs.tabCombat);
public void load()
{
ModLoader.addName(redDiamond, "Red Diamond");
redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");
}
public String getVersion()
{
return "1.3.2";
}
}
I have also gone a head and changed the creative tab to combat. Once you have done that it gets a little harder. After the Item id number put a ",", then type in what you named your enum tool material class. I named mine "YourModNameEnumToolMaterials" and then you waht to "." then what ever you named your material mine was named "REDDIAMOND" so im going to put that in. Your code should look like this:
public static final Item redDiamondSword = (new ItemYourModNameSword(1000, YourModNameEnumToolMaterials.REDDIAMOND)).setItemName("redDiamondSword").setTabToDisplayOn(CreativeTabs.tabCombat);
and there should be no errors on the weapon item. Now to add the in game name and texture just do the same as i showed you in the Creating Items mod. Now you should have a working weapon.
I hoped you have enjoyed this tutorial if you need any help at all just post a comment below.
Creating Tools:
Hello guys in this tutorial i will be showing you how to create a tool. Im going to be creating a pickaxe. First thing you need to know is how to create a enum tool material so go and do the enum tool material first and then come back here. Now lets get started, first thing you wanna do is to copy the weapon we created above or just copy my code below:
public static final Item redDiamondSword = (new ItemYourModNameSword(1000, YourModNameEnumToolMaterials.REDDIAMOND)).setItemName("redDiamondSword").setTabToDisplayOn(CreativeTabs.tabCombat);
Now before we go any where you guys will have to rename the item. Im going to name mine "redDiamondPickaxe", after that you going to want to change the "ItemYourModNameSword" to your own Item pickaxe (or what ever tool you are making) class, mine is "ItemYourModNamePickaxe". Now i im going to be changing the creative tab to Tools like this:
.setTabToDisplayOn(CreativeTabs.tabTools);
Now your code should look like this:
package net.minecraft.src;
public class mod_YourModName extends BaseMod
{
public static final Item redDiamond = (new Item(1000)).setItemName("redDiamond").setTabToDisplayOn(CreativeTabs.tabMaterials);
public static final Item redDiamondSword = (new ItemYourModNameSword(1000, YourModNameEnumToolMaterials.REDDIAMOND)).setItemName("redDiamondSword").setTabToDisplayOn(CreativeTabs.tabCombat);
public static final Item redDiamondPickaxe = (new ItemYourModNamePickaxe(1000, YourModNameEnumToolMaterials.REDDIAMOND)).setItemName("redDiamondPickaxe").setTabToDisplayOn(CreativeTabs.tabTools);
public void load()
{
ModLoader.addName(redDiamond, "Red Diamond");
redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");
}
public String getVersion()
{
return "1.3.2";
}
}
Now to add the in game name and texture just do the same thing as the creating items tutorial.
I hoped you have enjoyed this tutorial, fell free to post comments below if you need help.
Creating Enum Tool Materials:
Ok guys in this tutorial im going to be showing you how to create a enum tool material. This is used to create your own tools and weapons. The First thing you want to do is to create a new class i called mine "YourModNameEnumToolMaterials". Your code should look like this:
package net.minecraft.src;
public class YourModNameEnumToolMaterials
{
}
Before we start adding in some code we first need to make the this class a enum, so to do that we need to change class with enum. Your code should look like this:
package net.minecraft.src;
public enum YourModNameEnumToolMaterials
{
}
Now we can start adding in our own code. Now below is the code you have to add in.
REDDIAMOND(3, 21561, 20.0f, 3, 100);
private final int harvestLevel;[/indent]
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
private final int enchantability;
private EnumToolMaterial(int par3, int par4, float par5, int par6, int par7)
{
this.harvestLevel = par3;
this.maxUses = par4;
this.efficiencyOnProperMaterial = par5;
this.damageVsEntity = par6;
this.enchantability = par7;
}
public int getMaxUses()
{
return this.maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return this.efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return this.damageVsEntity;
}
public int getHarvestLevel()
{
return this.harvestLevel;
}
public int getEnchantability()
{
return this.enchantability;
}
Where it saids "REDDIAMOND" you are going to replace it with the name of the material you are going to make. After you the "{}" you can see some numbers the first number is the "harvest level" this means if it is a 3 it can mine obsidian and so on (if you realling want to know all the other harvest levels and what they do just post a comment below). The second number is "how many uses" you can get out of it. Diamond is 1561 and so on. The thrid number is the "how fast it can mine through the right block", 20.0F can mine dirt instantly (diamond = 8.0F). The fourth number is just the same as the first and the frith number is "how much damage a sword can do" (100 can kill any mob with one hit, diamond = 10). Now Where it saids "private EnumToolMaterial(int par3, int par4, float par5, int par6, int par7)" change "EnumToolMaterial" to what ever you named your enum (class). Your code should look like this:
package net.minecraft.src;
public enum YourModNameEnumToolMaterials
{
REDDIAMOND(3, 21561, 20.0f, 3, 100);
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
private final int enchantability;
private YourModNameEnumToolMaterials(int par3, int par4, float par5, int par6, int par7)
{
this.harvestLevel = par3;
this.maxUses = par4;
this.efficiencyOnProperMaterial = par5;
this.damageVsEntity = par6;
this.enchantability = par7;
}
public int getMaxUses()
{
return this.maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return this.efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return this.damageVsEntity;
}
public int getHarvestLevel()
{
return this.harvestLevel;
}
public int getEnchantability()
{
return this.enchantability;
}
}
Now what you want to do is to create some new classes but before do that this is what your going to name the classes "ItemYourModNameTool, ItemYourModNameSword, ItemYourModNameSpade, ItemYourModNameHoe, ItemYourModNamePickaxe, ItemYourModNameAxe" you can change the "YourModName" to your what ever your mod is called. now this is where it gets little bit harder. The first class you want to create is the "ItemYourModNameTool" class. Now im going to be giving you the code to put in here, so just copy this code beloa and put it in to your new class:
package net.minecraft.src;[/indent]
public class ItemTool extends Item
{
/** Array of blocks the tool has extra effect against. */
private Block[] blocksEffectiveAgainst;
protected float efficiencyOnProperMaterial = 4.0F;
/** Damage versus entities. */
private int damageVsEntity;
/** The material this tool is made from. */
protected EnumToolMaterial toolMaterial;
protected ItemTool(int par1, int par2, EnumToolMaterial par3EnumToolMaterial, Block[] par4ArrayOfBlock)
{
super(par1);
this.toolMaterial = par3EnumToolMaterial;
this.blocksEffectiveAgainst = par4ArrayOfBlock;
this.maxStackSize = 1;
this.setMaxDamage(par3EnumToolMaterial.getMaxUses());
this.efficiencyOnProperMaterial = par3EnumToolMaterial.getEfficiencyOnProperMaterial();
this.damageVsEntity = par2 + par3EnumToolMaterial.getDamageVsEntity();
this.setTabToDisplayOn(CreativeTabs.tabTools);
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
Block[] var3 = this.blocksEffectiveAgainst;
int var4 = var3.length;
for (int var5 = 0; var5 < var4; ++var5)
{
Block var6 = var3[var5];
if (var6 == par2Block)
{
return this.efficiencyOnProperMaterial;
}
}
return 1.0F;
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(2, par3EntityLiving);
return true;
}
public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(1, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.damageVsEntity;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String func_77861_e()
{
return this.toolMaterial.toString();
}
}
Now once you have copy the code you can now change the class name to your class name. Where it saids "protected EnumToolMaterial toolMaterial" change the "EnumToolMaterial" to your enum class anme, so i named mine "YourModNameEnumToolMaterials" so once you have done that you wanna rename anything that has the names "ItemTool","EnumToolMaterial" and "par3EnumToolMaterial" to your class names. Your code should look like this:
package net.minecraft.src;
public class ItemYourModNameTool extends Item
{
/** Array of blocks the tool has extra effect against. */
private Block[] blocksEffectiveAgainst;
protected float efficiencyOnProperMaterial = 4.0F;
/** Damage versus entities. */
private int damageVsEntity;
/** The material this tool is made from. */
protected YourModNameEnumToolMaterials toolMaterial;
protected ItemYourModNameTool(int par1, int par2, YourModNameEnumToolMaterials par3YourModNameEnumToolMaterials, Block[] par4ArrayOfBlock)
{
super(par1);
this.toolMaterial = par3YourModNameEnumToolMaterials;
this.blocksEffectiveAgainst = par4ArrayOfBlock;
this.maxStackSize = 1;
this.setMaxDamage(par3YourModNameEnumToolMaterials.getMaxUses());
this.efficiencyOnProperMaterial = par3YourModNameEnumToolMaterials.getEfficiencyOnProperMaterial();
this.damageVsEntity = par2 + par3YourModNameEnumToolMaterials.getDamageVsEntity();
this.setTabToDisplayOn(CreativeTabs.tabTools);
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
Block[] var3 = this.blocksEffectiveAgainst;
int var4 = var3.length;
for (int var5 = 0; var5 < var4; ++var5)
{
Block var6 = var3[var5];
if (var6 == par2Block)
{
return this.efficiencyOnProperMaterial;
}
}
return 1.0F;
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(2, par3EntityLiving);
return true;
}
public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(1, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.damageVsEntity;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String func_77861_e()
{
return this.toolMaterial.toString();
}
}
Make sure that your code has no errors in it (if it does then post a comment below and i will try to help you as best i can). Now lets move on to the other class we have to create. The other classes are not as big as this one is there are much smaller .. Now lets get started, first thing you want to do is to create the second class i told you to create and then copy in this code:
package net.minecraft.src;
public class ItemSword extends Item
{
private int weaponDamage;
private final EnumToolMaterial toolMaterial;
public ItemSword(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1);
this.toolMaterial = par2EnumToolMaterial;
this.maxStackSize = 1;
this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
this.setTabToDisplayOn(CreativeTabs.tabCombat);
this.weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block.blockID == Block.web.blockID ? 15.0F : 1.5F;
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String func_77825_f()
{
return this.toolMaterial.toString();
}
}
Once you have done that then he is the parts you have to rename to your own class:
Once you have renamed all the stuff you can move on to the next class but first i will show you what your code should look like:
package net.minecraft.src;
public class ItemYourModNameSword extends Item
{
private int weaponDamage;
private final YourModNameEnumToolMaterials toolMaterial;
public ItemYourModNameSword(int par1, YourModNameEnumToolMaterials par2YourModNameEnumToolMaterials)
{
super(par1);
this.toolMaterial = par2YourModNameEnumToolMaterials;
this.maxStackSize = 1;
this.setMaxDamage(par2YourModNameEnumToolMaterials.getMaxUses());
this.setTabToDisplayOn(CreativeTabs.tabCombat);
this.weaponDamage = 4 + par2YourModNameEnumToolMaterials.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block.blockID == Block.web.blockID ? 15.0F : 1.5F;
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String func_77825_f()
{
return this.toolMaterial.toString();
}
}
Before i move on i just want to say im not going to be tell you guys want to rename or tell you what code does what this is because i already told you want to rename and the code is easy to understand if you want to take the time to read over it, also if you want to know what the each part of the code does then just comment below and i will make another tutorial on it in a other post. Ok moving on now. Now the thrid class you want to create is "ItemYourModNameSpade". So copy the code below and paste it in your code and then rename all the stuff:
package net.minecraft.src;
public class ItemSpade extends ItemTool
{
/** an array of the blocks this spade is effective against */
private static Block[] blocksEffectiveAgainst = new Block[] {Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium};
public ItemSpade(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1, 1, par2EnumToolMaterial, blocksEffectiveAgainst);
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block == Block.snow ? true : par1Block == Block.blockSnow;
}
}
The fourth class is "ItemYourModNameHoe", so copy the code below and renam the stuff:
package net.minecraft.src;
public class ItemHoe extends Item
{
protected EnumToolMaterial field_77843_a;
public ItemHoe(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1);
this.field_77843_a = par2EnumToolMaterial;
this.maxStackSize = 1;
this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
this.setTabToDisplayOn(CreativeTabs.tabTools);
}
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6))
{
return false;
}
else
{
int var11 = par3World.getBlockId(par4, par5, par6);
int var12 = par3World.getBlockId(par4, par5 + 1, par6);
if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID) && var11 != Block.dirt.blockID)
{
return false;
}
else
{
Block var13 = Block.tilledField;
par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var13.stepSound.getStepSound(), (var13.stepSound.getVolume() + 1.0F) / 2.0F, var13.stepSound.getPitch() * 0.8F);
if (par3World.isRemote)
{
return true;
}
else
{
par3World.setBlockWithNotify(par4, par5, par6, var13.blockID);
par1ItemStack.damageItem(1, par2EntityPlayer);
return true;
}
}
}
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
public String func_77842_f()
{
return this.field_77843_a.toString();
}
}
The firth class is "ItemYourModNamePickaxe", so copy the code below and renam the stuff:
package net.minecraft.src;
public class ItemPickaxe extends ItemTool
{
/** an array of the blocks this pickaxe is effective against */
private static Block[] blocksEffectiveAgainst = new Block[] {Block.cobblestone, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockSteel, Block.oreCoal, Block.blockGold, Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, Block.railDetector, Block.railPowered};
protected ItemPickaxe(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1, 2, par2EnumToolMaterial, blocksEffectiveAgainst);
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block == Block.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (par1Block != Block.blockDiamond && par1Block != Block.oreDiamond ? (par1Block == Block.oreEmerald ? this.toolMaterial.getHarvestLevel() >= 2 : (par1Block != Block.blockGold && par1Block != Block.oreGold ? (par1Block != Block.blockSteel && par1Block != Block.oreIron ? (par1Block != Block.blockLapis && par1Block != Block.oreLapis ? (par1Block != Block.oreRedstone && par1Block != Block.oreRedstoneGlowing ? (par1Block.blockMaterial == Material.rock ? true : par1Block.blockMaterial == Material.iron) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2)) : this.toolMaterial.getHarvestLevel() >= 2);
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block != null && (par2Block.blockMaterial == Material.iron || par2Block.blockMaterial == Material.rock) ? this.efficiencyOnProperMaterial : super.getStrVsBlock(par1ItemStack, par2Block);
}
}
The last class is "ItemYourModNameAxe", so copy the code below and renam the stuff:
package net.minecraft.src;
public class ItemAxe extends ItemTool
{
/** an array of the blocks this axe is effective against */
private static Block[] blocksEffectiveAgainst = new Block[] {Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.pumpkin, Block.pumpkinLantern};
protected ItemAxe(int par1, EnumToolMaterial par2EnumToolMaterial)
{
super(par1, 3, par2EnumToolMaterial, blocksEffectiveAgainst);
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block != null && par2Block.blockMaterial == Material.wood ? this.efficiencyOnProperMaterial : super.getStrVsBlock(par1ItemStack, par2Block);
}
}
Once that is done you have now created your on enum tool material.
I hope you enjoyed this tutorial, it took me awhile.
Creating Enum Armor Materials:
Coming Soon
Creating Blocks:
Coming Soon
Creating Ores:
Coming Soon
Hey guys if you could let me know what you think of the tutorials it would help a lot
Hello nice tutorials simple and easy to understand, great work with them.
one question though, I have created a simple mod all is working great, I created it without the use of ModLoader, is there anyway I can get/add the ingame name of the item I have created without using modloader? Also I did try ModLaoader.addName() and it faild to display it when it tested it in eclips.
Any help on this would be greatly appriceated thanks in advance.
P.s. I did try and search google and is how I found these tutorials you have done lol.
Hello nice tutorials simple and easy to understand, great work with them.
one question though, I have created a simple mod all is working great, I created it without the use of ModLoader, is there anyway I can get/add the ingame name of the item I have created without using modloader? Also I did try ModLaoader.addName() and it faild to display it when it tested it in eclips.
Any help on this would be greatly appriceated thanks in advance.
P.s. I did try and search google and is how I found these tutorials you have done lol.
Thanks for that.
Is this what your modloader.addname looks like and make sure that you have spelled every thing right. Also make sure you add the ";" to the end of the line.
ModLoader.addName(YourItemName, "The In Game Name");
i hoped this help. If it didnt can you post your code.
Hello everyone and this is my tutorial for modding. I will be going slow and telling you guys how to create or make mods in minecraft with modloader. This tutorial will also tell you how to set up it so you can start modding.
I hope you enjoy.
Installing / Setting up:
1. Before we can starting modding we have to set up minecraft coder pack and install modloader. To edit or create mods im going to be using eclipse but you can use any text editor you have (I Recommend using eclipse).
2. To download MCP (minecraft coder pack) goto http://mcp.ocean-lab...hp/MCP_Releases,
make sure you download the latest MCP. Goto http://adf.ly/DDYvr to download modloader or search it up if you have a newer version of minecraft. Now goto http://adf.ly/DDZaK to download eclipse. Make sure that the eclipse you are downloading is Eclipse IDE for Java Developers and choose the 32 bit or 64 bit download
3. Once you have downloaded all of them goto to start and type in "%appdata%", then goto .minecraft\bin and open up the "minecraft.jar" file with "winrar", now you can copy all the "modloaders" files into the "minecraft.jar".
4. Now once you have installed modloader you can set up minecraft coder pack, but before doing that make sure that you run minecraft to see if you have installed modloader right. Once you have tested miencraft open up the "MCP" folder, also open up the ".minecraft" folder and copy the "bin" and "resources" folders and put them in the "MCP\jars" folder. Now you are ready to decompile minecraft, so now go back to the "MCP" folder and open up the "decompile.bat" file. This should take few seconds, once it is done close the "decompile.bat".
5. Once you have closed the "decompile.bat" open up eclipse (from the winrar folder or just extract the files in the winrar folder to a folder to your desktop or somewhere you can easily open eclipse from). Now a window should pop up asking you to pick a default folder. You want to click browse and goto your "MCP" folder and select "eclipse" folder.
6. Now just click ok and you are done.
Creating a class:
To create a Item what we need to do is to create a new class. To do that click on the "client" on the left window, then click on "src" and then "net.minecraft.src;". Now this will open up all the minecraft classes. To make our own class right click on "net.minecraft.src;" and go "new/class". Make sure that when ever you are making a mod with modloader make the class name "mod_" and then your mod name like this "mod_YourModName".
Now that we have made our mod class it should look like this:
Now before we starting making our mod we have to add some more code to make it so thats with modloader:
"extends BaseMod" means it is going to allow us to use the methods in inside the BaseMod.java
"public void load()" is where we are going to be calling all the modloaders methods
"public String getVersion()" we have to return the latest version of minecraft for me it is 1.3.2. This also fixes a error that will get if we dont put this here, you can test it if you want just delete the "public String getVersion()" method and you will see a red line under your class name.
This is the end of the first tutorial. I hope you have learn't how to create a class with eclipse
Creating items:
Lets get started creating our own class. To make a item we want to start off by typing "public static final Item" other the Item we put the name of the item we ant to create. Im going to name mine "redDiamond". So now it should look something like this:
Other we have given our item a name lets give it some properties. To do that we want to add the code below:
"(new Item(1000))" is the item id. The id can not be the same as any other items id.
".setItemName("redDiamond")" this is just setting the item name (THIS IS NOT THE IN GAME NAME).
You can also add on ".setTabToDisplayOn(CreativeTabs.tabMaterials)" this will make it so that the
item will show up in the creative menu under the "tabMaterials". I will put a list of all the tabs you can use at the bottom of this tutorial. this is the code with the creative tab part added on:
Now that we have made our item with properties lets start adding in the image and the in game name to it. To add the in game name we have to put in "ModLoader.addName(redDiamond, "Red Diamond");" the "ModLoader" is how we call a modloader method, so if we add ".addName()" onto it we will call the addName method. Now once you have added "ModLoader.addName()" in the "()" you want to first put the name of the item you want the in game name to be for me it is "redDiamond", after you have done that you put a "," when to double quotes and in side the double quotes you what to put the in game name. Once you have done that your code should look something like this
So after you have done that lets add a image. To add a image to the item you have to do things a little different then we did to add the in game name. You want to add this code "redDiamond.iconIndex = ModLoader.addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png");". Now the "redDiamond" is where you put your item name and then you can add on ".iconIndex". This is calling the method "iconIndex". After you have added that we put in "= ModLoader" this is so that the game knows that we want to call something from the "ModLoader.java" file. After that we put or add in the ".addOverride("/gui/items.png", "/MoreDiamonds/RedDiamonds/diamond.png")" this means that we are going to add a image of our own to the image "items.png". Now the your code should look like this:
Here is the creative tab list:
> Materials
> Brewing
> Combat
> Tools
> Foodstuffs
> Miscellaneous
> Transportation
> Redstone
> Decoration Blocks
> Building Blocks
Ok guys i hope you enjoyed this tutorial that is all we are going to do for now
Creating Weapons:
Hello guys on this tutorial i will be teaching you how to create a weapon (sword). So lets get started.
First you need to know how to create a enum tool material so if you dont know how to create enum tool material please go and do that tutorial first and then come back here. Now if you know how to create a enum tool material lets get started.
first off you want to go to our "mod_YourModName" class with the item in it. Once you are there to make it easy for your self copy the Item we made and paste below the item we made. Now you should have this:
You should get some errors that is fine it just meas that you cant have to items the some name. Now we are going to change the item name and where it has "(new Item(1000))" change Item to waht ever you named your ItemSword class i named mine ItemYourModNameSword so i will change Item to that. After doing that your code should look something like this:
I have also gone a head and changed the creative tab to combat. Once you have done that it gets a little harder. After the Item id number put a ",", then type in what you named your enum tool material class. I named mine "YourModNameEnumToolMaterials" and then you waht to "." then what ever you named your material mine was named "REDDIAMOND" so im going to put that in. Your code should look like this:
and there should be no errors on the weapon item. Now to add the in game name and texture just do the same as i showed you in the Creating Items mod. Now you should have a working weapon.
I hoped you have enjoyed this tutorial if you need any help at all just post a comment below.
Creating Tools:
Hello guys in this tutorial i will be showing you how to create a tool. Im going to be creating a pickaxe. First thing you need to know is how to create a enum tool material so go and do the enum tool material first and then come back here. Now lets get started, first thing you wanna do is to copy the weapon we created above or just copy my code below:
Now before we go any where you guys will have to rename the item. Im going to name mine "redDiamondPickaxe", after that you going to want to change the "ItemYourModNameSword" to your own Item pickaxe (or what ever tool you are making) class, mine is "ItemYourModNamePickaxe". Now i im going to be changing the creative tab to Tools like this:
Now your code should look like this:
Now to add the in game name and texture just do the same thing as the creating items tutorial.
I hoped you have enjoyed this tutorial, fell free to post comments below if you need help.
Creating Enum Tool Materials:
Ok guys in this tutorial im going to be showing you how to create a enum tool material. This is used to create your own tools and weapons. The First thing you want to do is to create a new class i called mine "YourModNameEnumToolMaterials". Your code should look like this:
Before we start adding in some code we first need to make the this class a enum, so to do that we need to change class with enum. Your code should look like this:
Now we can start adding in our own code. Now below is the code you have to add in.
Where it saids "REDDIAMOND" you are going to replace it with the name of the material you are going to make. After you the "{}" you can see some numbers the first number is the "harvest level" this means if it is a 3 it can mine obsidian and so on (if you realling want to know all the other harvest levels and what they do just post a comment below). The second number is "how many uses" you can get out of it. Diamond is 1561 and so on. The thrid number is the "how fast it can mine through the right block", 20.0F can mine dirt instantly (diamond = 8.0F). The fourth number is just the same as the first and the frith number is "how much damage a sword can do" (100 can kill any mob with one hit, diamond = 10). Now Where it saids "private EnumToolMaterial(int par3, int par4, float par5, int par6, int par7)" change "EnumToolMaterial" to what ever you named your enum (class). Your code should look like this:
Now what you want to do is to create some new classes but before do that this is what your going to name the classes "ItemYourModNameTool, ItemYourModNameSword, ItemYourModNameSpade, ItemYourModNameHoe, ItemYourModNamePickaxe, ItemYourModNameAxe" you can change the "YourModName" to your what ever your mod is called. now this is where it gets little bit harder. The first class you want to create is the "ItemYourModNameTool" class. Now im going to be giving you the code to put in here, so just copy this code beloa and put it in to your new class:
Now once you have copy the code you can now change the class name to your class name. Where it saids "protected EnumToolMaterial toolMaterial" change the "EnumToolMaterial" to your enum class anme, so i named mine "YourModNameEnumToolMaterials" so once you have done that you wanna rename anything that has the names "ItemTool", "EnumToolMaterial" and "par3EnumToolMaterial" to your class names. Your code should look like this:
Make sure that your code has no errors in it (if it does then post a comment below and i will try to help you as best i can). Now lets move on to the other class we have to create. The other classes are not as big as this one is there are much smaller .. Now lets get started, first thing you want to do is to create the second class i told you to create and then copy in this code:
Once you have done that then he is the parts you have to rename to your own class:
Once you have renamed all the stuff you can move on to the next class but first i will show you what your code should look like:
Before i move on i just want to say im not going to be tell you guys want to rename or tell you what code does what this is because i already told you want to rename and the code is easy to understand if you want to take the time to read over it, also if you want to know what the each part of the code does then just comment below and i will make another tutorial on it in a other post. Ok moving on now. Now the thrid class you want to create is "ItemYourModNameSpade". So copy the code below and paste it in your code and then rename all the stuff:
The fourth class is "ItemYourModNameHoe", so copy the code below and renam the stuff:
The firth class is "ItemYourModNamePickaxe", so copy the code below and renam the stuff:
The last class is "ItemYourModNameAxe", so copy the code below and renam the stuff:
Once that is done you have now created your on enum tool material.
I hope you enjoyed this tutorial, it took me awhile.
Creating Enum Armor Materials:
Creating Blocks:
Creating Ores:
Hey guys if you could let me know what you think of the tutorials it would help a lot
This was made by DualFusion
one question though, I have created a simple mod all is working great, I created it without the use of ModLoader, is there anyway I can get/add the ingame name of the item I have created without using modloader? Also I did try ModLaoader.addName() and it faild to display it when it tested it in eclips.
Any help on this would be greatly appriceated thanks in advance.
P.s. I did try and search google and is how I found these tutorials you have done lol.
Thanks for that.
Is this what your modloader.addname looks like and make sure that you have spelled every thing right. Also make sure you add the ";" to the end of the line.
i hoped this help. If it didnt can you post your code.
Thanks.