In this tutorial we'll be making a mod that allows players to put dirt into buckets (pretty useless as a real mod, but good for a tutorial).
In a real mod, you'll probably use this with custom liquids. This tutorial explains how to add custom liquids: http://www.minecraft...111-generation/ (by Strengthowns)
We start out with a basic mod_*.java:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_ForgeTutBuckets extends BaseMod {
public static String itemsPng = "/ForgeTutorials/Buckets/items.png";
public static String terrainPng = "/ForgeTutorials/Buckets/terrain.png";
public mod_ForgeTutBuckets() {
}
@Override
public String getVersion() {
return "1.0";
}
@Override
public void load() {
MinecraftForgeClient.preloadTexture(itemsPng);
MinecraftForgeClient.preloadTexture(terrainPng);
}
}
ItemBucket's constructor has 2 parameters: item ID, and ID of a block that will be placed when you right click with a full bucket (e.g. water source blocks). ItemDirtBucket's constructor also has 3rd parameter: icon index.
Next you need to implement IBucketHandler. Change third line to this:
public class ItemDirtBucket extends ItemBucket implements IBucketHandler, ITextureProvider
...and add this method:
@Override
public ItemStack fillCustomBucket(World w, int i, int j, int k) {
return null;
}
It will be called every time player clicks on any block with empty bucket. If it returns null nothing happens. Otherwise, bucket in player's hand will be replaced with ItemStack that this method returned.
Your ItemDirtBucket looks like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class ItemDirtBucket extends ItemBucket implements IBucketHandler, ITextureProvider {
public ItemDirtBucket (int id, int blockId, int icon) {
super(id, blockId);
setIconIndex(icon);
}
@Override
public ItemStack fillCustomBucket(World w, int i, int j, int k) {
return null;
}
public String getTextureFile()
{
return mod_ForgeTutBuckets.itemsPng;
}
}
Now go back to mod_*. Add a new bucket like you do with any other items and add this:
In this tutorial we'll be making a mod that adds a whole new set of armor.
We start out with a basic mod_*.java with no items or blocks because we will be making our own:
package net.minecraft.src;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
The first thing you need to do is import Forge by adding this at the top of the file right under package net.minecraft.src;:
import net.minecraft.src.forge.*;
Now your mod_*.java will look like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
Next we have to add the four armors like we would with any other armor by adding this where we would normally put this:
public static final Item helmetTitanium = (new CamelOreItemArmor(127, armorTITANIUM, 5, 0)).setIconCoord(0, 6).setItemName("helmetTitanium");
public static final Item plateTitanium = (new CamelOreItemArmor(128, armorTITANIUM, 5, 1)).setIconCoord(0, 7).setItemName("chestplateTitanium");
public static final Item legsTitanium = (new CamelOreItemArmor(129, armorTITANIUM, 5, 2)).setIconCoord(0, 8).setItemName("leggingsTitanium");
public static final Item bootsTitanium = (new CamelOreItemArmor(130, armorTITANIUM, 5, 3)).setIconCoord(0, 9).setItemName("bootsTitanium");
The first number (127) is the item id number like usual.
The second thing we have is armorTITANIUM which you will notice causes an error. I will explain that later.
The third number (5) is the material id it is. You have to start with 5 because diamond is 4, and if you added another set of armors they would all be 6.
The last number (0) shows what kind of armor it is (0 for helmet, 1 for chestplate, 2 for leggings, and 3 for boots).
This would make our code look like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Item helmetTitanium = (new CamelOreItemArmor(127, armorTITANIUM, 5, 0)).setIconCoord(0, 6).setItemName("helmetTitanium");
public static final Item plateTitanium = (new CamelOreItemArmor(128, armorTITANIUM, 5, 1)).setIconCoord(0, 7).setItemName("chestplateTitanium");
public static final Item legsTitanium = (new CamelOreItemArmor(129, armorTITANIUM, 5, 2)).setIconCoord(0, 8).setItemName("leggingsTitanium");
public static final Item bootsTitanium = (new CamelOreItemArmor(130, armorTITANIUM, 5, 3)).setIconCoord(0, 9).setItemName("bootsTitanium");
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Item helmetTitanium = (new CamelOreItemArmor(127, armorTITANIUM, 5, 0)).setIconCoord(0, 6).setItemName("helmetTitanium");
public static final Item plateTitanium = (new CamelOreItemArmor(128, armorTITANIUM, 5, 1)).setIconCoord(0, 7).setItemName("chestplateTitanium");
public static final Item legsTitanium = (new CamelOreItemArmor(129, armorTITANIUM, 5, 2)).setIconCoord(0, 8).setItemName("leggingsTitanium");
public static final Item bootsTitanium = (new CamelOreItemArmor(130, armorTITANIUM, 5, 3)).setIconCoord(0, 9).setItemName("bootsTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
}
public String getVersion() {
return "1.0.0";
}
}
now we get back to the armorTITANIUM
This is an enum (you don't have to know what that means) that has certain characteristics about that specific armor.
It defines:
How much damage the armor can take before it is completely degraded
How much the armor reduces the amount of damage that would be dealt to the player
and How enchantable it is.
How we make this enum is right above where we defined the armors we put this:
if you add this to your code it should get rid of that specific error you were getting
as we can see this adds a new armor material that is titanium
the first part ("TITANIUM") is just the name of material
the second number (29) is how much damage the armor can take before it is completely degraded
the next 4 numbers (2,7,5,3) are how much the damage the armor takes for the person (2 is for the helmet, 7 is for the chestplate, 5 is for the leggings, and 3 is for the boots)
and the last number (9) is how enchantible it is (i am not entirely sure on the details of this since it was just recently added)
your code should now look like:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
static EnumArmorMaterial armorTITANIUM = EnumHelper.addArmorMaterial("TITANIUM", 29, new int[] {2, 7, 5, 3}, 9)
public static final Item helmetTitanium = (new CamelOreItemArmor(127, armorTITANIUM, 5, 0)).setIconCoord(0, 6).setItemName("helmetTitanium");
public static final Item plateTitanium = (new CamelOreItemArmor(128, armorTITANIUM, 5, 1)).setIconCoord(0, 7).setItemName("chestplateTitanium");
public static final Item legsTitanium = (new CamelOreItemArmor(129, armorTITANIUM, 5, 2)).setIconCoord(0, 8).setItemName("leggingsTitanium");
public static final Item bootsTitanium = (new CamelOreItemArmor(130, armorTITANIUM, 5, 3)).setIconCoord(0, 9).setItemName("bootsTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
}
public String getVersion() {
return "1.0.0";
}
}
Now that we have this you still see that we have some more errors.
We haven't defind CamelOreItemArmor yet!
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreItem extends Item implements ITextureProvider
{
public CamelOreItem(int i)
{
super(i);
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/gui/items.png";
}
}
We want this to be called CamelOreItemArmor, call the right parameters and extend ItemArmor so we make it like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreItemArmor extends ItemArmor implements ITextureProvider
{
public CamelOreItemArmor(int i, EnumArmorMaterial enumarmormaterial, int j, int k)
{
super(i, enumarmormaterial, j, k);
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/gui/items.png";
}
}
The last thing we have to do to make this complete is add the textures for what it looks like when the texture is actually on you.
The first thing you have to do is implement another interface by adding this right after implements ITextureProvider:
, IArmorTextureProvider
so now it looks like:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreItemArmor extends ItemArmor implements ITextureProvider, IArmorTextureProvider
{
public CamelOreItemArmor(int i, EnumArmorMaterial enumarmormaterial, int j, int k)
{
super(i, enumarmormaterial, j, k);
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/gui/items.png";
}
}
Now all we have to do is add one more method to tell it what image files to use so put this at the end:
This says if the player is wearing a helmet, chestplate, or boots to load titanium_1.png and if the player is wearing leggings to load titanium_2.png.
You can find the template for these images in the armor folder in minecraft.jar.
I think that's it for now. Bye.
How to make things grow with bonemeal By: Methuselah96
In this tutorial we'll be making a mod that allows players to use bonemeal to automatically grow plants.
In a real mod, you'll probably use this with a custom crop. This tutorial explains how to add custom crops and we will be using this code to start: http://www.minecraft...111-generation/ (by Strengthowns)
This is really rather simple.
In your mod_*.java add this in the load function:
That's all you have to do in your mod_*.java.
Now all you have to do is make CamelOreBonemealHandler.
Here is an example of mine with a description below.
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreBonemealHandler implements IBonemealHandler
{
public boolean onUseBonemeal(World world, int bid, int i, int j, int k)
{
if(!world.multiplayerWorld)
{
((BlockNameherecrop)mod_Namehere.BlockNameherecrop).fertilize(world, i, j, k);
}
return true;
}
}
make sure you import forge and implement IBonemealHandler
then all you have to do is put the name of your crop java file where it has the first BlockNameherecrop
then mod_Namehere.BlockNameherecrop is just the name of your new crop
I haven't fully tested this to see if it works, but it would be nice if someone would check to see if it uses up a bonemeal when it's done.
How to make a custom tool set By: Methuselah96
In this tutorial we'll be making a mod that adds a whole new set of tools.
We start out with a basic mod_*.java with no items or blocks because we will be making our own:
package net.minecraft.src;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
The first thing you need to do is import Forge by adding this at the top of the file right under package net.minecraft.src;:
import net.minecraft.src.forge.*;
Now your mod_*.java will look like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
Next we have to add the five tools/weapon like we would with any other tool/weapon by adding this where we would normally put this:
public static final Item shovelTitanium = (new CamelOreItemSpade(127, toolTITANIUM)).setIconCoord(0, 2).setItemName("shovelTitanium");
public static final Item pickaxeTitanium = (new CamelOreItemPickaxe(128, toolTITANIUM)).setIconCoord(0, 3).setItemName("pickaxeTitanium");
public static final Item axeTitanium = (new CamelOreItemAxe(129, toolTITANIUM)).setIconCoord(0, 4).setItemName("hatchetTitanium");
public static final Item swordTitanium = (new CamelOreItemSword(130, toolTITANIUM)).setIconCoord(0, 1).setItemName("swordTitanium");
public static final Item hoeTitanium = (new CamelOreItemHoe(131, toolTITANIUM)).setIconCoord(0, 5).setItemName("hoeTitanium");
The first number (127) is the item id number like usual.
The second thing we have is toolTITANIUM which you will notice causes an error. I will explain that later.
This would make our code look like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Item shovelTitanium = (new CamelOreItemSpade(127, toolTITANIUM)).setIconCoord(0, 2).setItemName("shovelTitanium");
public static final Item pickaxeTitanium = (new CamelOreItemPickaxe(128, toolTITANIUM)).setIconCoord(0, 3).setItemName("pickaxeTitanium");
public static final Item axeTitanium = (new CamelOreItemAxe(129, toolTITANIUM)).setIconCoord(0, 4).setItemName("hatchetTitanium");
public static final Item swordTitanium = (new CamelOreItemSword(130, toolTITANIUM)).setIconCoord(0, 1).setItemName("swordTitanium");
public static final Item hoeTitanium = (new CamelOreItemHoe(131, toolTITANIUM)).setIconCoord(0, 5).setItemName("hoeTitanium");
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion() {
return "1.0.0";
}
}
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Item shovelTitanium = (new CamelOreItemSpade(127, toolTITANIUM)).setIconCoord(0, 2).setItemName("shovelTitanium");
public static final Item pickaxeTitanium = (new CamelOreItemPickaxe(128, toolTITANIUM)).setIconCoord(0, 3).setItemName("pickaxeTitanium");
public static final Item axeTitanium = (new CamelOreItemAxe(129, toolTITANIUM)).setIconCoord(0, 4).setItemName("hatchetTitanium");
public static final Item swordTitanium = (new CamelOreItemSword(130, toolTITANIUM)).setIconCoord(0, 1).setItemName("swordTitanium");
public static final Item hoeTitanium = (new CamelOreItemHoe(131, toolTITANIUM)).setIconCoord(0, 5).setItemName("hoeTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
}
public String getVersion() {
return "1.0.0";
}
}
now we get back to the toolTITANIUM
This is an enum (you don't have to know what that means) that has certain characteristics about that specific tool.
It defines:
What blocks it can harvest successfully.
How many uses it has before it becomes completely degraded
How much faster it breaks the block if it's a certain block
How much damage it does to other entities
and How enchantable it is.
How we make this enum is right above where we defined the armors we put this:
if you add this to your code it should get rid of that specific error you were getting
as we can see this adds a new tool material that is titanium
the first part ("TITANIUM") is just the name of material
the second number (2) defines what blocks it can harvest successfully (diamond = 3, iron = 2, stone = 1, gold and wood = 0)
the next number (500) are how many uses it has before it becomes completely degraded
the fourth number (7F) is how much faster it breaks the block if it's a certain block
the fifth number (3) is how much damage it does to other entities
and the last number (9) is how enchantible it is (i am not entirely sure on the details of this since it was just recently added)
your code should now look like:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
static EnumToolMaterial toolTITANIUM = EnumHelper.addToolMaterial("TITANIUM", 2, 500, 7F, 3, 9);
public static final Item shovelTitanium = (new CamelOreItemSpade(127, toolTITANIUM)).setIconCoord(0, 2).setItemName("shovelTitanium");
public static final Item pickaxeTitanium = (new CamelOreItemPickaxe(128, toolTITANIUM)).setIconCoord(0, 3).setItemName("pickaxeTitanium");
public static final Item axeTitanium = (new CamelOreItemAxe(129, toolTITANIUM)).setIconCoord(0, 4).setItemName("hatchetTitanium");
public static final Item swordTitanium = (new CamelOreItemSword(130, toolTITANIUM)).setIconCoord(0, 1).setItemName("swordTitanium");
public static final Item hoeTitanium = (new CamelOreItemHoe(131, toolTITANIUM)).setIconCoord(0, 5).setItemName("hoeTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
}
public String getVersion() {
return "1.0.0";
}
}
Now that we have this you still see that we have some more errors.
We haven't defind CamelOreItemSpade, CamelOreItemPickaxe, CamelOreItemAxe, CamelOreItemSword, or CamelOreItemHoe yet!
Make five new class called CamelOreItemSpade, CamelOreItemPickaxe, CamelOreItemAxe, CamelOreItemSword, and CamelOreItemHoe and they should all start out like a basic item file with a texture (How to use infinite terrain and sprite indexes).
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreItem extends Item implements ITextureProvider
{
public CamelOreItem(int i)
{
super(i);
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/gui/items.png";
}
}
I'm just going to show you one of them because they will all be basically the same.
The first thing you have to do is have it extend what it really is (i.e. CamelOreItemSpade extends ItemSpade and CamelOreItemPickaxe extends Item Pickaxe)
the only other thing you have to is make sure you have the right parameters in your super tag
All of them are going to look like this:
super(i, enumtoolmaterial);
here is an example CamelOreItemPickaxe:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreItemPickaxe extends ItemPickaxe implements ITextureProvider
{
protected CamelOreItemPickaxe(int i, EnumToolMaterial enumtoolmaterial)
{
super(i, enumtoolmaterial);
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/gui/items.png";
}
}
The last thing we have to do is tell Minecraft that we have these knew tools.
So we have to register them in your mod_CamelOre.java.
You only need to register the pickaxe, shovel, and axe because those are the only ones that make breaking blocks faster.
So we are going to add this:
the first thing is just the name of the item
the second thing is just pickaxe, shovel, or axe
and the last thing is the harvest level that we defined in our enum thing above(What blocks it can harvest successfully.)
when we put this into our mod_CamelOre.java it looks like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
static EnumToolMaterial toolTITANIUM = EnumHelper.addToolMaterial("TITANIUM", 2, 500, 7F, 3, 9);
public static final Item shovelTitanium = (new CamelOreItemSpade(127, toolTITANIUM)).setIconCoord(0, 2).setItemName("shovelTitanium");
public static final Item pickaxeTitanium = (new CamelOreItemPickaxe(128, toolTITANIUM)).setIconCoord(0, 3).setItemName("pickaxeTitanium");
public static final Item axeTitanium = (new CamelOreItemAxe(129, toolTITANIUM)).setIconCoord(0, 4).setItemName("hatchetTitanium");
public static final Item swordTitanium = (new CamelOreItemSword(130, toolTITANIUM)).setIconCoord(0, 1).setItemName("swordTitanium");
public static final Item hoeTitanium = (new CamelOreItemHoe(131, toolTITANIUM)).setIconCoord(0, 5).setItemName("hoeTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
MinecraftForge.setToolClass(pickaxeTitanium, "pickaxe", 2);
MinecraftForge.setToolClass(shovelTitanium, "shovel", 2);
MinecraftForge.setToolClass(axeTitanium, "axe", 2);
}
public String getVersion() {
return "1.0.0";
}
}
That's it I think.
How to set the harvesting level for a block By: Methuselah96
In this tutorial I'll be showing you how to set the harvesting level (or what type of pickaxe you need) for a block. This is extremely easy.
If you haven't read the custom texture tutorial, please do: How to use infinite terrain and sprite indexes.
Ok, we are going to start with a basic block that has a texture already made for it.
Here is our mod_CamelOre.java:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Block oreTitanium = new CamelOreBlockOre(123, 0).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/terrain.png");
ModLoader.RegisterBlock(oreTitanium);
}
public String getVersion() {
return "1.0.0";
}
}
There is only one thing we have to do and that is add this line:
oreTitanium is just the name of the block.
"pickaxe" is what you're setting the harvest level too
I think it can be either pickaxe, shovel, or axe
You can also register the same block with different tools
2 is the harvest level (diamond = 3, iron = 2, stone = 1, gold and wood = 0)
now your mod_CamelOre looks like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Block oreTitanium = new CamelOreBlockOre(123, 0).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/terrain.png");
ModLoader.RegisterBlock(oreTitanium);
MinecraftForge.setBlockHarvestLevel(oreTitanium, "pickaxe", 2);
}
public String getVersion() {
return "1.0.0";
}
}
That's it(I hope).
How to remove tool effectiveness from a block By: Methuselah96
In this tutorial I'll be showing you how to remove the thing that makes diamond pickaxes mine faster for a block. This is also extremely easy.
If you haven't read the harvest level tutorial, please do: How to set the harvesting level for a block.
Ok, we are going to start with a basic block that has a texture already made for it and a harvest level.
Here is our mod_CamelOre.java:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Block oreTitanium = new CamelOreBlockOre(123, 0).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/terrain.png");
ModLoader.RegisterBlock(oreTitanium);
MinecraftForge.setBlockHarvestLevel(oreTitanium, "pickaxe", 2);
}
public String getVersion() {
return "1.0.0";
}
}
There is only one thing we have to do and that is add this line:
oreTitanium is just the name of the block.
"pickaxe" is what tool you're removing the effectiveness from
That's it...
now your mod_CamelOre looks like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Block oreTitanium = new CamelOreBlockOre(123, 0).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/terrain.png");
ModLoader.RegisterBlock(oreTitanium);
MinecraftForge.setBlockHarvestLevel(oreTitanium, "pickaxe", 2);
MinecraftForge.removeBlockEffectiveness(oreTitanium,"pickaxe");
}
public String getVersion() {
return "1.0.0";
}
}
Again, that's it(I hope).
How to add your blocks and damage value items to creative mode
Prerequisites Creating A New Block
Crating A Block With Damage Values - Coming Soon!
Crating An Item With Damage Values - Coming Soon!
Minecraft Version
1.1
Tutorial
In this tutorial I am going to show you how to add blocks, blocks with damage values, and items with damage values to the creative mode inventory. I assume you know how to create a new block and item and install Forge. If you don?t you can read tutorials here: Creating A New Block and How to install Minecraft Forge.
We?re going to start out with a normal block file, CamelOreBlockOre:
package net.minecraft.src;
public class CamelOreBlockOre extends BlockOre
{
public CamelOreBlockOre(int i, int j)
{
super(i, j);
}
}
The first thing we need to do is import something so that we can use it:
import java.util.*;
This makes our CamelOreBlockOre look like this:
package net.minecraft.src;
import java.util.*;
public class CamelOreBlockOre extends BlockOre
{
public CamelOreBlockOre(int i, int j)
{
super(i, j, Material.rock);
}
}
Then this is the basic function that we add to each block file if we want it to show up in creative mode:
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
This will make it so that every block that uses that block file will show up in the inventory making our CamelOreBlockOre look like this:
package net.minecraft.src;
import java.util.*;
public class CamelOreBlockOre extends BlockOre
{
public CamelOreBlockOre(int i, int j)
{
super(i, j, Material.rock);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
}
But, what if we don?t want all of them in creative mode, what if we just want some of the ones that use this block file to be in the inventory. Then we would make an if statement that would look something like this:
If you?re block has 2 damage values that is what you would add. If your block had 3 damage values you would change the 2 to a 3, and so on and so forth.
But again what if only some blocks have damage values and the others are normal in the same block file? Then you would have to make an if statement like before:
public void addCreativeItems(ArrayList itemList)
{
if(blockID == mod_CamelOre.oreTitanium.blockID)
{
for(int l1 = 0; l1 < 2; l1++)
{
itemList.add(new ItemStack(this, 1, l1));
}
} else
{
itemList.add(new ItemStack(this));
}
}[code]
This would make it so only titanium ore would have multiple damage values and the rest of them would only have one.
Then comes the ultimate example. What if some blocks have damage values, some don?t, and some you don?t even want to show in the inventory in the same class? Here it is:
[code] public void addCreativeItems(ArrayList itemList)
{
if(blockID == mod_CamelOre.oreTitanium.blockID)
{
for(int l1 = 0; l1 < 2; l1++)
{
itemList.add(new ItemStack(this, 1, l1));
}
} else
if(blockID == mod_CamelOre.oreAluminum.blockID)
{
itemList.add(new ItemStack(this));
}
}
This basically says that if the block is titanium ore then it will put 2 damage values of it in the inventory. If the block is aluminum ore it will put it in without any damage values. And if the block is anything else it will not be in the inventory. Finally, we?re done the blocks.
Items automatically show up in your inventory so you don?t have to worry about them unless they have damage values. You would add it EXACTLY the same way so here you go:
package net.minecraft.src;
import java.util.*;
public class ItemDye extends Item
{
public ItemDye(int i)
{
super(i);
}
public void addCreativeItems(ArrayList itemList)
{
for (int x = 0; x < 16; x++)
{
itemList.add(new ItemStack(this, 1, x));
}
}
}
Final Code
CamelOreBlockOre.java
package net.minecraft.src;
import java.util.*;
public class CamelOreBlockOre extends BlockOre
{
public CamelOreBlockOre(int i, int j)
{
super(i, j, Material.rock);
}
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this));
}
}
Author
Methuselah96
How to make a new redstone wire By: Methuselah96
In this tutorial I'll be showing you how to make a block that can connect to redstone wire.
If you haven't read the custom texture tutorial, please do: How to use infinite terrain and sprite indexes.
Ok, we are going to start with a basic block that has a texture already made for it.
Here is our mod_CamelOre.java:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public static final Block oreTitanium = new CamelOreBlockCopperWire(123, 0).setHardness(3F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("oreTitanium");
public mod_CamelOre()
{
}
public void load()
{
MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/terrain.png");
ModLoader.RegisterBlock(oreTitanium);
}
public String getVersion() {
return "1.0.0";
}
}
We are not going to do anything to the mod_CamelOre.java, but actually do something to the CamelOreBlockCopperWire.java.
Here it is:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreBlockCopperWire extends BlockRedstoneWire implements ITextureProvider
{
public CamelOreBlockCopperWire(int i, int j)
{
super(i, j);
}
public int idDropped(int i, Random random, int j)
{
return mod_CamelOre.copperWire.blockID;
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/terrain.png";
}
}
This is what we have to add:
public boolean canConnectRedstone(IBlockAccess iba, int i, int j, int k, int dir)
{
return true;
}
Now it can connect to redstone.
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class CamelOreBlockCopperWire extends BlockRedstoneWire implements ITextureProvider
{
public CamelOreBlockCopperWire(int i, int j)
{
super(i, j);
}
public int idDropped(int i, Random random, int j)
{
return mod_CamelOre.copperWire.blockID;
}
public boolean canConnectRedstone(IBlockAccess iba, int i, int j, int k, int dir)
{
return true;
}
public String getTextureFile()
{
return "/CamelMod/CamelOre/terrain.png";
}
}
Tutorial
In this tutorial I am going to teach you how to make Forge give an error if a user isn?t using an up-to-date Forge so that they know why your mod isn?t working. I assume you have installed Forge. If you haven?t you can see my tutorial here: How to install Minecraft Forge.
We are going to start with a basic mod_CamelOre that doesn?t have anything:
package net.minecraft.src;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion()
{
return "1.0.0";
}
}
The first thing we need to do is import forge so that we can use it like this:
import net.minecraft.src.forge.*;
This makes our mod_CamelOre look like this:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
}
public String getVersion()
{
return "1.0.0";
}
}
There are two different kinds of version detecting you can do: regular and strict. I?ll go over regular first.
If you are doing regular version detecting you would add this in your load function:
What this basically says is that the mod CamelOre was developed with Forge 1.2.2. You need to know some terms so I can explain you to this easily. The 1 is the major version number. The first 2 is the minor version number. The second 2 is the revision verison number. Ok, now I can explain it easily. If the major version is different it will crash Minecraft. If the minor version of the user is lower than the minor version that the mod was developed in, it will crash. If it is a newer minor version number it will give a warning. If the revision number is too old it will crash. If the revision number is newer it will do nothing. Here?s a table:
Major Version # Minor Version # Revision Version #
User?s is older than developer?s Crash Crash Crash
User?s is newer than developer?s Crash Warning Nothing
I hope you understood that (it?s hard to explain). This is what our new mod_CamelOre would look like:
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
MinecraftForge.versionDetect("CamelOre", 1, 2, 2);
}
public String getVersion()
{
return "1.0.0";
}
}
Now for strict version detecting. This is what you would add:
The only difference between regular and strict is if the major version number is newer it will crash. Here?s the new table:
Major Version # Minor Version # Revision Version #
User?s is older than developer?s Crash Crash Crash
User?s is newer than developer?s Crash Crash Nothing
That?s it!
Final Code
mod_CamelOre.java
package net.minecraft.src;
import net.minecraft.src.forge.*;
public class mod_CamelOre extends BaseMod
{
public mod_CamelOre()
{
}
public void load()
{
MinecraftForge.versionDetect("CamelOre", 1, 2, 2);
}
public String getVersion()
{
return "1.0.0";
}
}
I can't figure out how to install MCForge, I keep getting errors, in a few files. If you could put a video link or PM me that would be awesome!Nevermind i downloaded the wrong files
Rollback Post to RevisionRollBack
Check out my YOUTUBE
I make Minecraft Videos, So subscribe if you like it and ask me if you want me to do an adventure map!
Sorry, but not really, it still shows it black and white. I know how to do it for the items (.setIconCoord(x, y)) but i don't for the terrain.png. I've looked at your mod (CamelOre) and I STILL don't get it...
Sorry, but not really, it still shows it black and white. I know how to do it for the items (.setIconCoord(x, y)) but i don't for the terrain.png. I've looked at your mod (CamelOre) and I STILL don't get it...
Thanks in advance
Rashed
did you see my picture up above
it starts at the top left corner being 0
then it goes to the square on the right of that being 1
it goes all the way across the top until 15
then it skips down the first square on the second row
and it goes across that row until 31
then 32-63 is on the third row and so on and so on
Yes I did see the picture. but where do I put these numbers?
If I put them after the block id I tried but it still won't work!
If you need my files I will be happy to send them to you!!!
When it comes to Blocks, the 2nd int in most constructors is the texture index.
It sets blockIndexInTexture to that number.
Blocks don't have a .setIconCoords function but all that function does is textureID = (y * 16) + x;
Please visit my main modding topic to vote for what tutorial I should make next.
Please Note: The titles that have smaller font are the ones that have been updated recently.
Table of contents:
How to install Minecraft Forge
How to use infinite terrain and sprite indexes
How to make an advanced configuration files
How to make a custom armor set
How to make custom filled buckets
How to make things grow with bonemeal
How to make a new redstone wire
How to make a custom item renderer - Coming Soon!
How to make a custom tool set
How to set the harvesting level for a block
How to remove tool effectiveness from a block
How to add your blocks and damage value items to creative mode
How to make a new ladder - Coming Soon!
How to make your block replaceable - Coming Soon!
How to use the ore dictionary - Coming Soon!
How to use version detect
How to add items to dungeon chests - Coming Soon!
...AND MORE
How to install Minecraft Forge
By: Methuselah96
How to use infinite terrain and sprite indexes
Moved to http://minecraftforg..._sprite_indexes.
How to make an advanced configuration files
Moved to http://minecraftforg...figuration_file.
How to make custom filled buckets
By: DiEvAl
In this tutorial we'll be making a mod that allows players to put dirt into buckets (pretty useless as a real mod, but good for a tutorial).
In a real mod, you'll probably use this with custom liquids. This tutorial explains how to add custom liquids: http://www.minecraft...111-generation/ (by Strengthowns)
For details about how to use preloadTexture see How to use infinite terrain and sprite indexes.
Now you need to create your ItemDirtBucket class:
ITextureProvider and getTextureFile() are also described in How to use infinite terrain and sprite indexes.
ItemBucket's constructor has 2 parameters: item ID, and ID of a block that will be placed when you right click with a full bucket (e.g. water source blocks). ItemDirtBucket's constructor also has 3rd parameter: icon index.
Next you need to implement IBucketHandler. Change third line to this:
...and add this method:
It will be called every time player clicks on any block with empty bucket. If it returns null nothing happens. Otherwise, bucket in player's hand will be replaced with ItemStack that this method returned.
Your ItemDirtBucket looks like this:
Now go back to mod_*. Add a new bucket like you do with any other items and add this:
Now your mod_* should look like this:
Custom bucket has ID 1337, will place dirt when used, it's texture is at (0,0) in the spritesheet, and it's name is "Dirt Bucket".
You don't want bucket that you can't get without inventory editor, right? So edit fillCustomBucket to something like this:
If a player clicked on dirt or grass, empty bucket in player's hand will be replaced with dirt bucket.
If you want to use your own blocks instead of dirt/grass (and you probably will), use this:
Done!
Screenshots
Sources & Textures
mod_ForgeTutBuckets: http://pastebin.com/P1QfCFhR
DirtBucket: http://pastebin.com/nwuxbTdF
/ForgeTutorials/Buckets/items.png: http://imgur.com/pZlss
How to make a custom armor set
By: Methuselah96
In this tutorial we'll be making a mod that adds a whole new set of armor.
We start out with a basic mod_*.java with no items or blocks because we will be making our own:
The first thing you need to do is import Forge by adding this at the top of the file right under package net.minecraft.src;:
Now your mod_*.java will look like this:
Next we have to add the four armors like we would with any other armor by adding this where we would normally put this:
The first number (127) is the item id number like usual.
The second thing we have is armorTITANIUM which you will notice causes an error. I will explain that later.
The third number (5) is the material id it is. You have to start with 5 because diamond is 4, and if you added another set of armors they would all be 6.
The last number (0) shows what kind of armor it is (0 for helmet, 1 for chestplate, 2 for leggings, and 3 for boots).
This would make our code look like this:
We also have to have the textures for the armors preloaded, which you can learn from How to use infinite terrain and sprite indexes making the code look like:
now we get back to the armorTITANIUM
This is an enum (you don't have to know what that means) that has certain characteristics about that specific armor.
It defines:
How much damage the armor can take before it is completely degraded
How much the armor reduces the amount of damage that would be dealt to the player
and How enchantable it is.
How we make this enum is right above where we defined the armors we put this:
if you add this to your code it should get rid of that specific error you were getting
as we can see this adds a new armor material that is titanium
the first part ("TITANIUM") is just the name of material
the second number (29) is how much damage the armor can take before it is completely degraded
the next 4 numbers (2,7,5,3) are how much the damage the armor takes for the person (2 is for the helmet, 7 is for the chestplate, 5 is for the leggings, and 3 is for the boots)
and the last number (9) is how enchantible it is (i am not entirely sure on the details of this since it was just recently added)
your code should now look like:
Now that we have this you still see that we have some more errors.
We haven't defind CamelOreItemArmor yet!
Make a new class called CamelOreItemArmor and it should start out like a basic item file with a texture (How to use infinite terrain and sprite indexes).
We want this to be called CamelOreItemArmor, call the right parameters and extend ItemArmor so we make it like this:
The last thing we have to do to make this complete is add the textures for what it looks like when the texture is actually on you.
The first thing you have to do is implement another interface by adding this right after implements ITextureProvider:
so now it looks like:
Now all we have to do is add one more method to tell it what image files to use so put this at the end:
This says if the player is wearing a helmet, chestplate, or boots to load titanium_1.png and if the player is wearing leggings to load titanium_2.png.
You can find the template for these images in the armor folder in minecraft.jar.
I think that's it for now. Bye.
How to make things grow with bonemeal
By: Methuselah96
In this tutorial we'll be making a mod that allows players to use bonemeal to automatically grow plants.
In a real mod, you'll probably use this with a custom crop. This tutorial explains how to add custom crops and we will be using this code to start: http://www.minecraft...111-generation/ (by Strengthowns)
This is really rather simple.
In your mod_*.java add this in the load function:
That's all you have to do in your mod_*.java.
Now all you have to do is make CamelOreBonemealHandler.
Here is an example of mine with a description below.
make sure you import forge and implement IBonemealHandler
then all you have to do is put the name of your crop java file where it has the first BlockNameherecrop
then mod_Namehere.BlockNameherecrop is just the name of your new crop
I haven't fully tested this to see if it works, but it would be nice if someone would check to see if it uses up a bonemeal when it's done.
How to make a custom tool set
By: Methuselah96
In this tutorial we'll be making a mod that adds a whole new set of tools.
We start out with a basic mod_*.java with no items or blocks because we will be making our own:
The first thing you need to do is import Forge by adding this at the top of the file right under package net.minecraft.src;:
Now your mod_*.java will look like this:
Next we have to add the five tools/weapon like we would with any other tool/weapon by adding this where we would normally put this:
The first number (127) is the item id number like usual.
The second thing we have is toolTITANIUM which you will notice causes an error. I will explain that later.
This would make our code look like this:
We also have to have the textures for the tools preloaded, which you can learn from How to use infinite terrain and sprite indexes making the code look like:
now we get back to the toolTITANIUM
This is an enum (you don't have to know what that means) that has certain characteristics about that specific tool.
It defines:
What blocks it can harvest successfully.
How many uses it has before it becomes completely degraded
How much faster it breaks the block if it's a certain block
How much damage it does to other entities
and How enchantable it is.
How we make this enum is right above where we defined the armors we put this:
if you add this to your code it should get rid of that specific error you were getting
as we can see this adds a new tool material that is titanium
the first part ("TITANIUM") is just the name of material
the second number (2) defines what blocks it can harvest successfully (diamond = 3, iron = 2, stone = 1, gold and wood = 0)
the next number (500) are how many uses it has before it becomes completely degraded
the fourth number (7F) is how much faster it breaks the block if it's a certain block
the fifth number (3) is how much damage it does to other entities
and the last number (9) is how enchantible it is (i am not entirely sure on the details of this since it was just recently added)
your code should now look like:
Now that we have this you still see that we have some more errors.
We haven't defind CamelOreItemSpade, CamelOreItemPickaxe, CamelOreItemAxe, CamelOreItemSword, or CamelOreItemHoe yet!
Make five new class called CamelOreItemSpade, CamelOreItemPickaxe, CamelOreItemAxe, CamelOreItemSword, and CamelOreItemHoe and they should all start out like a basic item file with a texture (How to use infinite terrain and sprite indexes).
I'm just going to show you one of them because they will all be basically the same.
The first thing you have to do is have it extend what it really is (i.e. CamelOreItemSpade extends ItemSpade and CamelOreItemPickaxe extends Item Pickaxe)
the only other thing you have to is make sure you have the right parameters in your super tag
All of them are going to look like this:
here is an example CamelOreItemPickaxe:
The last thing we have to do is tell Minecraft that we have these knew tools.
So we have to register them in your mod_CamelOre.java.
You only need to register the pickaxe, shovel, and axe because those are the only ones that make breaking blocks faster.
So we are going to add this:
the first thing is just the name of the item
the second thing is just pickaxe, shovel, or axe
and the last thing is the harvest level that we defined in our enum thing above(What blocks it can harvest successfully.)
when we put this into our mod_CamelOre.java it looks like this:
That's it I think.
How to set the harvesting level for a block
By: Methuselah96
In this tutorial I'll be showing you how to set the harvesting level (or what type of pickaxe you need) for a block. This is extremely easy.
If you haven't read the custom texture tutorial, please do: How to use infinite terrain and sprite indexes.
Ok, we are going to start with a basic block that has a texture already made for it.
Here is our mod_CamelOre.java:
There is only one thing we have to do and that is add this line:
oreTitanium is just the name of the block.
"pickaxe" is what you're setting the harvest level too
I think it can be either pickaxe, shovel, or axe
You can also register the same block with different tools
2 is the harvest level (diamond = 3, iron = 2, stone = 1, gold and wood = 0)
now your mod_CamelOre looks like this:
That's it(I hope).
How to remove tool effectiveness from a block
By: Methuselah96
In this tutorial I'll be showing you how to remove the thing that makes diamond pickaxes mine faster for a block. This is also extremely easy.
If you haven't read the harvest level tutorial, please do: How to set the harvesting level for a block.
Ok, we are going to start with a basic block that has a texture already made for it and a harvest level.
Here is our mod_CamelOre.java:
There is only one thing we have to do and that is add this line:
oreTitanium is just the name of the block.
"pickaxe" is what tool you're removing the effectiveness from
That's it...
now your mod_CamelOre looks like this:
Again, that's it(I hope).
How to add your blocks and damage value items to creative mode
Prerequisites
Creating A New Block
Crating A Block With Damage Values - Coming Soon!
Crating An Item With Damage Values - Coming Soon!
Minecraft Version
1.1
Tutorial
In this tutorial I am going to show you how to add blocks, blocks with damage values, and items with damage values to the creative mode inventory. I assume you know how to create a new block and item and install Forge. If you don?t you can read tutorials here: Creating A New Block and How to install Minecraft Forge.
We?re going to start out with a normal block file, CamelOreBlockOre:
The first thing we need to do is import something so that we can use it:
This makes our CamelOreBlockOre look like this:
Then this is the basic function that we add to each block file if we want it to show up in creative mode:
This will make it so that every block that uses that block file will show up in the inventory making our CamelOreBlockOre look like this:
But, what if we don?t want all of them in creative mode, what if we just want some of the ones that use this block file to be in the inventory. Then we would make an if statement that would look something like this:
This makes it so the only block that gets added to the inventory in this file is titanium ore.
That?s how to add a normal block to the inventory.
Now, what if this block has damage values? What are we going to do then? This is what we have to do:
If you?re block has 2 damage values that is what you would add. If your block had 3 damage values you would change the 2 to a 3, and so on and so forth.
But again what if only some blocks have damage values and the others are normal in the same block file? Then you would have to make an if statement like before:
This basically says that if the block is titanium ore then it will put 2 damage values of it in the inventory. If the block is aluminum ore it will put it in without any damage values. And if the block is anything else it will not be in the inventory. Finally, we?re done the blocks.
Items automatically show up in your inventory so you don?t have to worry about them unless they have damage values. You would add it EXACTLY the same way so here you go:
Final Code
CamelOreBlockOre.java
Author
Methuselah96
How to make a new redstone wire
By: Methuselah96
In this tutorial I'll be showing you how to make a block that can connect to redstone wire.
If you haven't read the custom texture tutorial, please do: How to use infinite terrain and sprite indexes.
Ok, we are going to start with a basic block that has a texture already made for it.
Here is our mod_CamelOre.java:
We are not going to do anything to the mod_CamelOre.java, but actually do something to the CamelOreBlockCopperWire.java.
Here it is:
This is what we have to add:
Now it can connect to redstone.
How to use version detect
Prerequisites
How to install Minecraft Forge
Minecraft Version
1.1
Tutorial
In this tutorial I am going to teach you how to make Forge give an error if a user isn?t using an up-to-date Forge so that they know why your mod isn?t working. I assume you have installed Forge. If you haven?t you can see my tutorial here: How to install Minecraft Forge.
We are going to start with a basic mod_CamelOre that doesn?t have anything:
The first thing we need to do is import forge so that we can use it like this:
This makes our mod_CamelOre look like this:
There are two different kinds of version detecting you can do: regular and strict. I?ll go over regular first.
If you are doing regular version detecting you would add this in your load function:
What this basically says is that the mod CamelOre was developed with Forge 1.2.2. You need to know some terms so I can explain you to this easily. The 1 is the major version number. The first 2 is the minor version number. The second 2 is the revision verison number. Ok, now I can explain it easily. If the major version is different it will crash Minecraft. If the minor version of the user is lower than the minor version that the mod was developed in, it will crash. If it is a newer minor version number it will give a warning. If the revision number is too old it will crash. If the revision number is newer it will do nothing. Here?s a table:
Major Version # Minor Version # Revision Version #
User?s is older than developer?s Crash Crash Crash
User?s is newer than developer?s Crash Warning Nothing
I hope you understood that (it?s hard to explain). This is what our new mod_CamelOre would look like:
Now for strict version detecting. This is what you would add:
The only difference between regular and strict is if the major version number is newer it will crash. Here?s the new table:
Major Version # Minor Version # Revision Version #
User?s is older than developer?s Crash Crash Crash
User?s is newer than developer?s Crash Crash Nothing
That?s it!
Final Code
mod_CamelOre.java
Author
Methuselah96
Yes, I do and I can tell you how to as long as you have the ModLoader and ModLoaderMP already installed in MCP.
easy.
no, i don't NEED help but we can make this like a collaboration tutorial of many writers and this could be like the "official mcforge tuts"
go ahead and write some if you want
I make Minecraft Videos, So subscribe if you like it and ask me if you want me to do an adventure map!
Thanks,
Rashed
I make Minecraft Videos, So subscribe if you like it and ask me if you want me to do an adventure map!
sure i should have it up by tomorrow
Awesome and not to pressure you with stuff but also custom armor that doesn't edit original MC classes(If you know how). BOOKMARKED!
I make Minecraft Videos, So subscribe if you like it and ask me if you want me to do an adventure map!
Sorry, but not really, it still shows it black and white. I know how to do it for the items (.setIconCoord(x, y)) but i don't for the terrain.png. I've looked at your mod (CamelOre) and I STILL don't get it...
Thanks in advance
Rashed
Sorry. I wanted to say "Can I help". I should stop typing after midnight...
I'll write a tut about buckets.
EDIT: in your tutorial about textures you said "path to an items.png". Shouldn't it be "path to items.png" because "items" is plural?
i could make video tutorials, but right now i don't think it would be worth it
yes, i do know ho to make custom armor without any edited base files
did you see my picture up above
it starts at the top left corner being 0
then it goes to the square on the right of that being 1
it goes all the way across the top until 15
then it skips down the first square on the second row
and it goes across that row until 31
then 32-63 is on the third row and so on and so on
haha, thanks for trying to correct my grammer but the noun is singular because it is just one image
i have to go now or else i would explain the grammer thing more
and i will put your tutorial up soon
If I put them after the block id I tried but it still won't work!
If you need my files I will be happy to send them to you!!!
Thanks again
Rashed
It sets blockIndexInTexture to that number.
Blocks don't have a .setIconCoords function but all that function does is textureID = (y * 16) + x;