The Meaning of Life, the Universe, and Everything.
Join Date:
12/28/2011
Posts:
49
Member Details
My Minecraft Modding Tutorials
Update status: 1.2.5
Hello everyone, here is my minecraft modding tutorial. I will show you how to create your own minecraft mod with Modloader and ModloaderMp. It will works in singleplayer and in multiplayer. I'll show you the basic of modding but you will have to use your logic to understand and create your own personalised mod.
So here it is!!!
Please, when you create a mod, read the instruction to make sure you don't get an error !!!
Please, start by the block tutorial because you will maybe not understand the other tutorials !!!
Before Modding(If you never mod and don't know how to write new codes and don't know what is mcp):
2. Download Eclipse here . Go on Eclipse IDE for Java Developers and click 32 Bit or 64 Bit to download.
3. Download the lastest Minecraft Coder Pack here .
4. Create a new folder and put all the mcp files in it.
5. Go in %appdata%/Roaming/.minecraft and copy the bin and ressources folder. Paste them in the jars folder of mcp. You have to use a clean minecraft (not modded).
6. Download minecraft_server.jar here and put it in the jars folder of mcp.
7. Download Modloader here and ModloaderMp client and server side here .
8. Put Modloader and ModloaderMp client side files in the minecraft.jar of the jars folder of mcp. Put ModloaderMp server side in the minecraft_server.jar.
9. Run decompile.bat and wait until it finish.
10. Open Eclipse and go in file/Switch Workspace/Other... And then find the mcp folder and select the eclipse folder.
11. You're ready to mod !!!!
Tip1: to create a new file in eclipse, go in File/new/file and make sure you selected Client/src/net/minecraft/src or for server, Server/src/net/minecraft/src.
Tip2: to test your mod just click on the green button called run in eclipse. If you want to test your mod for server, recompile your mod with recompile.bat and run startclient.bat and startserver.bat.
Error for server when decompile:
When you decompile, a lot of you will get a fail to recompile minecraft_server.java or something. It's normal so follow this to correct it:
1. Go in Server/src/net.minecraft.server/minecraftserver.java with eclipse and the error is suppose to be here.
2. In the minecraft_server.java just delete from line 520 to 555 and replace all this for }.
This is what you are suppose to delete:
3. And then save and run recompile.bat.
4. Run updatemd5.bat to make sure everything will be alright when you will reobfuscate later.
5. Everything should be ok and you are ready to mod.
Modding Tutorials:
Your mod file empty
This is what you will have in every mod. It's like the base of your mod.
The last thing where it says "Random", this is what appear when the mod is loaded in the server command. It will say "mod_mymod Random" in this case. Normaly, you put the version of your mod but you can put whatever you want. Client:
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public void load()
{
}
public String getVersion()
{
return "Random";
}
}
Here is how to create a new simple block and don't forget do read what mean what to make sure you understand.
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Myblock = (new BlockMyblock (200, ModLoader.addOverride("/terrain.png", "/Mods/Myblock.png")).setHardness(0.5F).setBlockName("Myblock").setStepSound(Block.soundWoodFootstep).setLightValue(1.0F));
public void load()
{
ModLoader.registerBlock(Myblock);
ModLoader.addName(Myblock, "Block");
}
public String getVersion()
{
return "Random";
}
}
the "new BlockMyblock is the file that is related with your block, so your are supposed to create a file called BlockMyblock.java like I did bellow.
200 is the ID of your block and is has to be from 200 or more.
Modloader.addOverride is the texture and where can we find it. You have to put your texture (16 by 16) in mcp/temp/bin/minecraft and create a new folder called Mods to put all you texture in it. Copy this folder and paste it in mcp/jars/bin/minecraft.jar
Resistance is for explosion and hardness is when you smash on it.
1.0F for lightvalue is the max.
There is more than one soundstep just try to rewrite it yourself and they will all appear.
Modloader.addname sets the name of your block inside minecraft
BlockMyblock.java
package net.minecraft.src;
import java.util.Random;
public class BlockMyblock extends Block
{
public BlockMyblock (int i, int j)
{
super(i ,j, Material.cloth);
}
public int quantityDropped(Random random)
{
return 1;
}
public int idDropped (int i,Random random, int j)
{
return mod_mymod.Myblock.blockID;
}
}
I think you can understand it yourself
Server:
For server side it's the same thing but in your mod_***.java you will have to delete all line starting by ModLoader.addName()
For the Block*****.java nothing changes for any tutorials of creating a block.
Part 2 (Dropping anything you want)
To do this you will need to see part 1 of creating a new block
To make it dropped whatever you want you just have to change the end of BlockMyblock.java. Change where it say "public int idDropped".
Exemple for Item:
public int idDropped (int i,Random random, int j)
{
return Item.coal.shiftedIndex;
}
Exemple for Block
public int idDropped (int i,Random random, int j)
{
return Block.wood.blockID;
}
Exemple for a block that you created in your mod
public int idDropped (int i,Random random, int j)
{
return mod_mymod.Myblock.blockID;
}
Part 3(multi-texture)
To do this you will need to see part 1 of creating a new block. This is how to make your block have a different texture on top, bottom and side.
The 2 things that I add starting by public static int are the texture of your bottom and top in this case but you could add the texture of the side of your block.
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Myblock = (new BlockMyblock (200, ModLoader.addOverride("/terrain.png", "/Mods/Myblock.png")).setHardness(0.5F).setBlockName("Myblock").setStepSound(Block.soundWoodFootstep).setLightValue(1.0F));
public static int MyblockTop;
public static int MyblockBottom;
public void load()
{
MyblockTop = ModLoader.addOverride("/terrain.png", "/Mods/MyblockTop.png");
MyblockBottom = ModLoader.addOverride("/terrain.png", "/Mods/Myblockbottom.png");
ModLoader.registerBlock(Myblock);
ModLoader.addName(Myblock, "Block");
ModLoader.addRecipe(new ItemStack (Myblock, 1), (new Object[] {
"XXX", Character.valueOf('X'), Block.dirt }));
}
public String getVersion()
{
return "Random";
}
}
For your block file just add this bellow the returnid thing. This will say where are the texture of each sides of your block.
0 = bellow
1 = top
2 = side
3 = side
4 = side
5 = side
4 and 5 are opposite like 2 and 3.
If you don't want to use all of the sides of your block, just do what I do. The thing that says "else" is saying that everything that is not 0 and 1 will be the normal texture that we put in the mod file (public static final Block Myblock.....)
Hope you understand what I said.
public int getBlockTextureFromSide(int i)
{
if(i==1)
{
return mod_mymod.MyblockTop;
}
if(i==0)
{
return mod_mymod.MyblockBottom;
}else
{
return blockIndexInTexture;
}
}
Don't forget to put your texture in your folder of texture.
Part 4 (generation)
To do this you will need to see part 1 of creating a new block.
This is how to make your custom block spawning in Minecraft world.
You just have to add the public void generateSurface that you will see in the code bellow
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Myblock = (new BlockMyblock (200, ModLoader.addOverride("/terrain.png", "/Mods/Myblock.png")).setHardness(0.5F).setBlockName("Myblock").setStepSound(Block.soundWoodFootstep).setLightValue(1.0F));
public void load()
{
ModLoader.registerBlock(Myblock);
ModLoader.addName(Myblock, "Block");
}
public void generateSurface(World world, Random rand, int chunkx, int chunkz)
{
for (int l = 0; l<45; l++)
{
int il = chunkx + rand.nextInt(16);
int jl = rand.nextInt(64);
int kl = chunkz + rand.nextInt(16);
(new WorldGenMinable(Myblock.blockID, 20)).generate(world, rand, il, jl, kl);
}
}
public String getVersion()
{
return "Random";
}
}
The number 20 mean the spawn rate
Myblock.blockID mean what is the block you want to generate and that is what we want
Part 5 (special effects when touch)
This will make an effect when your player is going to touch the block
Just add this after the idDropped in your block file.
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
float f = 0.0625F;
return AxisAlignedBB.getBoundingBoxFromPool((float)par2 + f, par3, (float)par4 + f, (float)(par2 + 1) - f, (float)(par3 + 1) - f, (float)(par4 + 1) - f);
}
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
par5Entity.attackEntityFrom(DamageSource.cactus, 1);
}
All you have to do is changing the damagesource at the end. It can be a lot of thing just delete .cactus and reput the point and all the choice will appear.
Part 6 (Block change when powered by redstone like the lamp)
This is how to make that when your new block is powered with redstone, it will be transform in a new one and when the power is off, it will return as normal. Exactly like the lamp
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block NewblockIdle = (new BlockNewblock(203, false, ModLoader.addOverride("/terrain.png", "/Mods/NewblockIdle.png")).setHardness(0.3F).setStepSound(Block.soundStoneFootstep).setBlockName("Newblock"));
public static final Block NewblockActive = (new BlockNewblock(204, true, ModLoader.addOverride("/terrain.png", "/Mods/NewblockActive.png")).setHardness(0.3F).setStepSound(Block.soundStoneFootstep).setBlockName("Newblock").setLightValue(1.0F));
public void load()
{
ModLoader.registerBlock(NewblockIdle);
ModLoader.registerBlock(NewblockActive);
ModLoader.addName(NewblockIdle, "Lamp");
ModLoader.addRecipe(new ItemStack (NewblockIdle, 4), (new Object[] {
"XXX", "XXX", "XXX", Character.valueOf('X'), Block.dirt }));
}
public String getVersion()
{
return "Random";
}
}
If you read the first part you should understand. Except the true and false that I add after the ID. False will be the normal block and true is the block that will appear when powered the other block.
Newblock.java
package net.minecraft.src;
import java.util.Random;
public class BlockNewblock extends Block
{
private final boolean powered;
public BlockNewblock(int i, Boolean par1, int j)
{
super(i, j, Material.redstoneLight);
powered = par1;
}
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 4);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_mymod.NewblockActive.blockID);
}
}
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (!par1World.isRemote)
{
if (powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.scheduleBlockUpdate(par2, par3, par4, blockID, 4);
}
else if (!powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_mymod.NewblockActive.blockID);
}
}
}
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote && powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, mod_mymod.NewblockIdle.blockID);
}
}
public int quantityDropped(Random random)
{
return 1;
}
public int idDropped (int i,Random random, int j)
{
return mod_mymod.NewblockIdle.blockID;
}
}
And this is what you need for the block to work. You could read it to try to understand but... you could.
Part 7 (Block that you can pass through)
This is how to make you able to pass through your new block.
For your basic mod file there is nothing special about it, except that your resistance has to be at 1F.
You have to add 2 things for your block.
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i)
{
return null;
}
Add this
after the iddropped or whatever
And the thing where it says super (i, j, material.cloth) or whatever your material is, it has to be material.portal to make it work.
Creating a new Recipe
Part 1 (crafting recipe)
This how to creating a new crafting recipe. Client:
Add this in your mod_****.java in the section public void load ()
mod_mymod.java
ModLoader.addRecipe(new ItemStack (Item.coal, 1), (new Object[] {
"X X", " X ", "XX ", Character.valueOf('X'), Block.dirt }));
So this is a recipe that will create one coal (Item.coal, 1)
For the second line of code i'll explain it with some images
ModLoader.addRecipe(new ItemStack (Item.coal, 1), (new Object[] {
"X X", " X ", "XX ", Character.valueOf('X'), Block.dirt }));
This how to create a new smelting recipe Client:
Add this in your mod_****.java in the section public void load ()
ModLoader.addSmelting(Block.dirt.blockID, new ItemStack (Block.sand));
This will transform dirt into sand. If you want to transform an item, you have to write Item.*****.shiftedIndex instead of Block.*****.blockID and if you want the result to be an item it has to be Item.**** instead of Block.***.
Server:
For server side nothing changes
Part 3 (add fuel)
This is how to create new fuel for the furnace Client:
Just add this bellow public void() like this:
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public void load()
{
}
public int addFuel(int i, int j)
{
if(i == Block.dirt.blockID)
return 12800;
return 0;
}
public String getVersion()
{
return "Random";
}
}
If you want an item to be fuel you have to put Item.*****.shiftedIndex instead of Block.****.blockID.
I return 12800 but you could return whatever you want. Exemple: coal=1600, lava=20000, blazerod=2400, wood=300. Server:
Same thing for server, nothing changes
Creating a new item
Part 1 (id, texture)
This how to create new item Client:
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Item Myitem = (new Myitem(17000).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/Myitem.png")).setItemName("Myitem"));
public void load()
{
ModLoader.addName(Myitem, "Item");
}
public String getVersion()
{
return "Random";
}
}
ModLoader.addOverride is the same thing as in the 1st part of creating a new block. It says where is the texture of it. So you have to put your texture (16 by 16) in mcp/temp/bin/minecraft and create a new folder called Mods (if you have created it already put it in there). Copy this folder and paste it in mcp/jars/bin/minecraft.jar
Modloader.addName sets the name of your item inside Minecraft
Myitem.java
package net.minecraft.src;
public class Myitem extends Item
{
protected Myitem(int i)
{
super(i);
}
}
This is your item file and there is nothing special in it.
Server:
For server side it's the same thing but in your mod_***.java you will have to delete all line starting by ModLoader.addName()
For the myitem.java nothing changes just like blocks.
Techne
This tutorial is very important for other tutorials you maybe want to do.
What is techne ?
Techne is used to create models.
What are models ?
Models are used for making complexe form, like mob(pig, zombie, etc.) and complicated block (boat, sign, etc.). Remember it's not making the mob it self or the block, it is just making it shape. Making models are normaly very difficult but thanks to Techne.
Download
Here is the official topic to download Techne ----> DOWNLOAD
Creating a new Model with Techne
1. After downloading and installing Techne, open it.
2.There is supposed to be a little window appearing, choose the name of your model but it is facultative.
3. You can choose a base model like pig and then modify it but it is facultative. You can choose "ModelBase" if you don't want to have a model.
4. Make sure the texture is 64 width and 32 Height.
5. Click create and you can start creating your new model. Use right click and mouse to move around the area.
6. First, you have to create a new box by clicking the blue box in left screen.
7. A box should appear, you can move it around by using the position section in left screen. Recommend to stay in one block width and height wich is 16 by 16.
8. To modify the shape of the little box use the dimensions section in left screen.
9. Right know, if I was you, I should not touch to the Offset section in left screen.
10. You can use the rotation section in left screen to make your block be in diagonal.
11. If you want to delete a box, select the box you want and click delete box in left screen. Oh and you can create more than one box.
12. You can change the name of the box in right screen (model tree).
13. Now the texture. After creating your shape, you need to create a new folder (where you want) to put everything you create in it.
14. Click File/Export as/ Texture map and save it in your new folder. In left screen, click Load Texture and find the texture you just created.
15. Now you can modify the texture with whatever program you want and when you save the modification you put on the texture, it will appear immediately in Techne.
16. Now the model file that you will put in your minecraft. Click File/Export as/Java and save it in your new folder.
17. This is it, you just create a new model but to implent it in minecraft follow the Block Manipulation part 3 tutorial. I didn't do a tutorial yet on mob so...
Block manipulation
Part 1 (changing shape)
This is how to change the shape of your block
First you have to add 2 things after the public int idDropped in your block file
1.
public boolean isOpaqueCube()
{
return false;
}
2.
public boolean renderAsNormalBlock()
{
return false;
}
Then you have to set the blockbounds bellow the super(i, j) thing, just like this
public BlockMyblock (int i, int j)
{
super(i ,j, Material.glass);
setBlockBounds(0.25F, 0F, 0.25F, 0.75F, 1F, 0.75F);
}
To make you understand how blockbounds works go see this spoiler
(0F, 0F, 0F, 1F, 1F, 1F)
(0.5F, 0F, 0F, 1F, 1F, 1F)
(0F, 0.5F, 0F, 1F, 1F, 1F)
(0F, 0F, 0.5F, 1F, 1F, 1F)
(0F, 0F, 0F, 0.5F, 1F, 1F)
(0F, 0F, 0F, 1F, 0.5F, 1F)
(0F, 0F, 0F, 1F, 1F, 0.5F)
Part 2 (changing type or render)
This is how to change the type of render of your block.
You have to add like the 1st part these two things bellow idDropped in your block file
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
And to change the render type add this
public int getRenderType()
{
return 0;
}
To make your block renderer different just change the return 0 to something in the list here
0
1
2
3
5
6
10
12
13 (cactus style)
14
Part 3 (Block shape very advanced with Techne)
You need to know how to use Techne in this tutorial. If you don't, I got a tutorial on how to use it.
This is how to implent a block with a very specify shape that you created with Techne. Client:
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Newblock = (new BlockNewblock (200, 0, net.minecraft.src.TileEntityNewblock.class).setBlockName("Newblock"));
public static int modelID;
public void load()
{
ModLoader.addName(Newblock, "Block");
ModLoader.registerBlock(Newblock);
ModLoader.addRecipe(new ItemStack(Newblock, 1), (new Object[]{
"X", Character.valueOf('X'), Block.dirt }));
TileEntityNewblockRenderer tileent1 = new TileEntityNewblockRenderer();
ModLoader.registerTileEntity(TileEntityNewblock.class, "Newblock", tileent1);
modelID = ModLoader.getUniqueBlockModelID(this, true);
}
public void renderInvBlock(RenderBlocks var1, Block var2, int var3, int var4)
{
if (var4 == Newblock.getRenderType())
{
TileEntityRenderer.instance.renderTileEntityAt(new TileEntityNewblock(), 0.0D, 0.0D, 0.0D, 0.0F);
}
}
public String getVersion()
{
return "Random";
}
}
Here I created the block, loaded the TileEntity and make sure it renders the block as an item in minecraft.
BlockNewblock.java
package net.minecraft.src;
import java.util.Random;
public class BlockNewblock extends BlockContainer
{
private Class anEntityClass;
public BlockNewblock(int i, int j, Class class1)
{
super(i, j, Material.cloth);
anEntityClass = class1;
}
public int quantityDropped(Random random)
{
return 1;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return mod_mymod.modelID;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean blockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
{
int p = MathHelper.floor_double((double)((par5EntityPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; //this is a smart equation
byte byte0 = 3;
if (p == 0)
{
byte0 = 4;
}
if (p == 1)
{
byte0 = 3;
}
if (p == 2)
{
byte0 = 2;
}
if (p == 3)
{
byte0 = 1;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, byte0);
return true;
}
public TileEntity getBlockEntity()
{
return new TileEntityNewblock();
}
}
If your block is little and you see in minecraft that the selection of the block is big you can add a block bounds.
ModelNewblock.java
public void renderModel(float f5)
{
Shape1.render(f5);
Shape2.render(f5);
}
This part is made with Techne, you just have to add this thing for each part of your block.
TileEntityNewblock.java
package net.minecraft.src;
public class TileEntityNewblock extends TileEntity
{
public TileEntityNewblock()
{
}
}
Here you don't have to put anything.
TileEntityNewblockRenderer.java
package net.minecraft.src;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class TileEntityNewblockRenderer extends TileEntitySpecialRenderer
{
private ModelNewblock model;
public TileEntityNewblockRenderer()
{
model = new ModelNewblock();
}
public void renderAModelAt(TileEntityNewblock tile, double d, double d1, double d2, float f)
{
int i = 0;
int j = 0;
if (i == 0)
{
j = 0;
}
if (i == 1)
{
j = 90;
}
if (i == 2)
{
j = 180;
}
if (i == 3)
{
j = 270;
}
if (tile.worldObj != null)
{
i = tile.getBlockMetadata();
}
bindTextureByName("/Mods/Newblock.png");
GL11.glPushMatrix(); //start
GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);
GL11.glRotatef(j, 0.0F, 1.0F, 0.0F);
GL11.glScalef(1.0F, -1F, -1F);
model.renderModel(0.0625F);
GL11.glPopMatrix(); //end
}
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
renderAModelAt((TileEntityNewblock) tileentity, d, d1, d2, f);
}
}
Server:
Do the same thing but you don't have to put the modelNewblock.java and the TileEntityNewblock.java
For mod_mymod.java, delete modloader.addName, tileent1 at the end of modloader.registerTileEntity and this in public void load() :
TileEntityNewblockRenderer tileent1 = new TileEntityNewblockRenderer();
And delete this too:
public void renderInvBlock(RenderBlocks var1, Block var2, int var3, int var4)
{
if (var4 == Newblock.getRenderType())
{
TileEntityRenderer.instance.renderTileEntityAt(new TileEntityNewblock(), 0.0D, 0.0D, 0.0D, 0.0F);
}
}
This is how to to create your own material like wood, rock, steel, gold and diamond. You will need this if don't want your sword and tools to have the same properties as wood, rock and all ther stuff.
EnumDirtToolMaterial.java
package net.minecraft.src;
public enum EnumDirtToolMaterial
{
DIRT(1, 30, 1.0F, 0, 10);
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
private final int enchantability;
private EnumDirtToolMaterial(int par3, int par4, float par5, int par6, int par7)
{
harvestLevel = par3;
maxUses = par4;
efficiencyOnProperMaterial = par5;
damageVsEntity = par6;
enchantability = par7;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
public int getEnchantability()
{
return enchantability;
}
}
Ok, to make your tools and sword different from other material you will need to change this: DIRT(1, 30, 1.0F, 0, 10). The first number is the harvest level, the second is the max uses, the third is the effeciency, the fourth is the damage vs mob and the last one defines the natural enchantability factor of the material. To compare with other materials go in EnumToolMaterial.java.
ItemDirtTool.java
package net.minecraft.src;
public class ItemDirtTool extends Item
{
private Block blocksEffectiveAgainst[];
protected float efficiencyOnProperMaterial;
private int damageVsEntity;
protected EnumDirtToolMaterial toolMaterial;
protected ItemDirtTool(int par1, int par2, EnumDirtToolMaterial par3EnumToolMaterial, Block par4ArrayOfBlock[])
{
super(par1);
efficiencyOnProperMaterial = 4F;
toolMaterial = par3EnumToolMaterial;
blocksEffectiveAgainst = par4ArrayOfBlock;
maxStackSize = 1;
setMaxDamage(par3EnumToolMaterial.getMaxUses());
efficiencyOnProperMaterial = par3EnumToolMaterial.getEfficiencyOnProperMaterial();
damageVsEntity = par2 + par3EnumToolMaterial.getDamageVsEntity();
}
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
for (int i = 0; i < blocksEffectiveAgainst.length; i++)
{
if (blocksEffectiveAgainst[i] == par2Block)
{
return efficiencyOnProperMaterial;
}
}
return 1.0F;
}
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(2, par3EntityLiving);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, int par2, int par3, int par4, int par5, EntityLiving par6EntityLiving)
{
par1ItemStack.damageItem(1, par6EntityLiving);
return true;
}
public int getDamageVsEntity(Entity par1Entity)
{
return damageVsEntity;
}
public boolean isFull3D()
{
return true;
}
public int getItemEnchantability()
{
return toolMaterial.getEnchantability();
}
}
You will need to create this too
Part 2 (Sword, Tool)
Creating a new sword and tools (recommended)
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Item DirtSword = (new ItemSword(17000, EnumToolMaterial.WOOD).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtSword.png")).setItemName("Dirt Sword"));
public static final Item DirtAxe = (new ItemAxe(17001, EnumToolMaterial.WOOD).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtAxe.png")).setItemName("Dirt Axe"));
public static final Item DirtPickaxe = (new ItemPickaxe(17002, EnumToolMaterial.WOOD).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtPickaxe.png")).setItemName("Dirt Pickaxe"));
public static final Item DirtSpade = (new ItemSpade(17003, EnumToolMaterial.WOOD).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtSpade.png")).setItemName("Dirt Spade"));
public static final Item DirtHoe = (new ItemHoe(17004, EnumToolMaterial.WOOD).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtHoe.png")).setItemName("Dirt Hoe"));
public void load()
{
ModLoader.addName(DirtSword, "DirtSword");
ModLoader.addName(DirtAxe, "DirtAxe");
ModLoader.addName(DirtPickaxe, "DirtPickaxe");
ModLoader.addName(DirtSpade, "DirtSpade");
ModLoader.addName(DirtHoe, "DirtHoe");
ModLoader.addRecipe(new ItemStack (DirtSword, 1), (new Object[] {
" X ", " X ", " W ", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtAxe, 1), (new Object[] {
"XX ", "XW ", " W ", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtPickaxe, 1), (new Object[] {
"XXX", " W ", " W ", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtSpade, 1), (new Object[] {
" X ", " W ", " W ", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtHoe, 1), (new Object[] {
"XX ", " W ", " W ", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
}
public String getVersion()
{
return "Random";
}
}
If you want to understand you need to read the item tutorial
If you want your sword and tools to have different properties, you have to change EnumToolMaterial.WOOD. Change the "WOOD" for any other material.
If you want it to have the properties of your new material that you made in part 1 (Dirt) change the "new ItemSword(17000, EnumToolMaterial.WOOD)" for "new ItemDirtSword(17000, EnumDirtToolMaterial.DIRT)"
Creating a new sword and tools. If you use this tutorial it's because you want to possibly add some special effect to you sword or tools.
This is how to create a new sword, pickaxe, hoe , axe and shovel.
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Item DirtSword = (new ItemDirtSword(17000, EnumDirtToolMaterial.DIRT).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtSword.png")).setItemName("Dirt Sword"));
public static final Item DirtPickaxe = (new ItemDirtPickaxe(17001, EnumDirtToolMaterial.DIRT).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtPickaxe.png")).setItemName("Dirt Pickaxe"));
public static final Item DirtHoe = (new ItemDirtHoe(17002, EnumDirtToolMaterial.DIRT).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtHoe.png")).setItemName("Dirt Hoe"));
public static final Item DirtShovel = (new ItemDirtShovel(17003, EnumDirtToolMaterial.DIRT).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtShovel.png")).setItemName("Dirt Shovel"));
public static final Item DirtAxe = (new ItemDirtAxe(17004, EnumDirtToolMaterial.DIRT).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtAxe.png")).setItemName("Dirt Axe"));
public void load()
{
ModLoader.addName(DirtSword, "Dirt Sword");
ModLoader.addName(DirtPickaxe, "Dirt Pickaxe");
ModLoader.addName(DirtHoe, "Dirt Hoe");
ModLoader.addName(DirtShovel, "Dirt Shovel");
ModLoader.addName(DirtAxe, "Dirt Axe");
ModLoader.addRecipe(new ItemStack (DirtSword, 1), (new Object[] {
" X ", " X ", " W ",Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtPickaxe, 1), (new Object[] {
"XXX", " W ", " W ",Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtHoe, 1), (new Object[] {
"XX ", " W ", " W ",Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtShovel, 1), (new Object[] {
" X ", " W ", " W ",Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
ModLoader.addRecipe(new ItemStack (DirtAxe, 1), (new Object[] {
"XX ", "XW ", " W ",Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
}
public String getVersion()
{
return "Random";
}
}
ItemDirtSword.java
package net.minecraft.src;
public class ItemDirtSword extends Item
{
private int weaponDamage;
private final EnumDirtToolMaterial toolMaterial;
public ItemDirtSword(int par1, EnumDirtToolMaterial par2EnumToolMaterial)
{
super(par1);
toolMaterial = par2EnumToolMaterial;
maxStackSize = 1;
setMaxDamage(par2EnumToolMaterial.getMaxUses());
weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
}
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block.blockID != Block.web.blockID ? 1.5F : 15F;
}
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, int par2, int par3, int par4, int par5, EntityLiving par6EntityLiving)
{
par1ItemStack.damageItem(2, par6EntityLiving);
return true;
}
public int getDamageVsEntity(Entity par1Entity)
{
return weaponDamage;
}
public boolean isFull3D()
{
return true;
}
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 0x11940;
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
public int getItemEnchantability()
{
return toolMaterial.getEnchantability();
}
}
This is how to create your own armor with it own properties.
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Item DirtHelmet = (new DirtItemArmor(17000, EnumDirtArmorMaterial.DIRT, ModLoader.addArmor("dirt"), 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtHelmet.png")).setItemName("Dirt Helmet");
public static final Item DirtChest = (new DirtItemArmor(17001, EnumDirtArmorMaterial.DIRT, ModLoader.addArmor("dirt"), 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtChest.png")).setItemName("Dirt Chest");
public static final Item DirtLegs = (new DirtItemArmor(17002, EnumDirtArmorMaterial.DIRT, ModLoader.addArmor("dirt"),2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtLegs.png")).setItemName("Dirt Legs");
public static final Item DirtBoots = (new DirtItemArmor(17003, EnumDirtArmorMaterial.DIRT, ModLoader.addArmor("dirt"),3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/DirtBoots.png")).setItemName("Dirt Boots");
public void load()
{
ModLoader.addName(DirtHelmet, "Dirt Helmet");
ModLoader.addName(DirtChest, "Dirt Chest");
ModLoader.addName(DirtLegs, "Dirt Legs");
ModLoader.addName(DirtBoots, "Dirt Boots");
ModLoader.addRecipe(new ItemStack (DirtHelmet, 1), (new Object[] {
"XXX", "X X", " ", Character.valueOf('X'), Block.dirt }));
ModLoader.addRecipe(new ItemStack (DirtChest, 1), (new Object[] {
"X X", "XXX", "XXX", Character.valueOf('X'), Block.dirt }));
ModLoader.addRecipe(new ItemStack (DirtLegs, 1), (new Object[] {
"XXX", "X X", "X X", Character.valueOf('X'), Block.dirt }));
ModLoader.addRecipe(new ItemStack (DirtBoots, 1), (new Object[] {
"X X", "X X", Character.valueOf('X'), Block.dirt }));
}
public String getVersion()
{
return "Random";
}
}
You should understand everything if you read the item tutorial except the ModLoader.addArmor. This means you have to put 2 texture in mcp/temp/bin/minecraft/armor and mcp/jars/bin/minecraft.jar/armor (dirt_1.png and dirt_2.png). Go in the armor folder and you'll see why we call it this way.
EnumDirtArmorMaterial.java
package net.minecraft.src;
import java.util.Random;
public enum EnumDirtArmorMaterial
{
DIRT("DIRT", 25, 29, new int[] {2, 7, 5, 3}, 9);
private int maxDamageFactor;
private int damageReductionAmountArray[];
private int enchantability;
private EnumDirtArmorMaterial(String s, int i, int j, int ai[], int k)
{
maxDamageFactor = j;
damageReductionAmountArray = ai;
enchantability = k;
}
public int func_40576_a(int i)
{
return ItemArmor.getMaxDamageArray()[i] * maxDamageFactor;
}
public int getDamageReductionAmount(int i)
{
return damageReductionAmountArray[i];
}
public int getEnchantability()
{
return enchantability;
}
}
This is like the EnumDirtToolMaterial.java, it is new material for armor so if you want to create a new armor with new properties you have to create this. If you want to change the properties (DIRT("DIRT", 25, 29, new int[] {2, 7, 5, 3}, 9)) of your armor, just go in EnumArmorMaterial.java and compare with the other materials.
DirtItemArmor.java
package net.minecraft.src;
public class DirtItemArmor extends ItemArmor
{
private static final int maxDamageArray[] = {
11, 16, 15, 13
};
public final int armorType;
public final int damageReduceAmount;
public final int renderIndex;
private final EnumDirtArmorMaterial material;
public DirtItemArmor(int i, EnumDirtArmorMaterial enumarmormaterial, int j, int k)
{
super(i, EnumArmorMaterial.DIAMOND, j, k);
material = enumarmormaterial;
armorType = k;
renderIndex = j;
damageReduceAmount = enumarmormaterial.getDamageReductionAmount(k);
setMaxDamage(enumarmormaterial.func_40576_a(k));
maxStackSize = 1;
}
public int getItemEnchantability()
{
return material.getEnchantability();
}
static int[] getMaxDamageArray()
{
return maxDamageArray;
}
}
This one, just copy it and change the dirt. You don't need to understand it but you have to know that when you create this, it's because you created the EnumDirtArmorMaterial.java.
Creating a new Tree
Part 1 (Mod file and generation)
This is your mod file for your new tree, there should be some error because you didn't create the other file that goes with it and that is the part 2.
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Newlog = (new BlockNewlog (200, ModLoader.addOverride("/terrain.png", "/Mods/Newlog.png")).setHardness(2.0F).setBlockName("New log").setStepSound(Block.soundWoodFootstep).setRequiresSelfNotify());
public static final Block Newleaf = (new BlockNewleaf (201, ModLoader.addOverride("/terrain.png", "/Mods/Newleaf.png")).setHardness(0.2F).setBlockName("New leaf").setStepSound(Block.soundGrassFootstep).setRequiresSelfNotify());
public static final Block Newsapling = (new BlockNewsapling (202, ModLoader.addOverride("/terrain.png", "/Mods/Newsapling.png")).setHardness(0.0F).setBlockName("New sapling").setStepSound(Block.soundGrassFootstep).setRequiresSelfNotify());
public void load()
{
ModLoader.registerBlock(Newlog);
ModLoader.registerBlock(Newleaf);
ModLoader.registerBlock(Newsapling);
ModLoader.addName(Newlog, "New Log");
ModLoader.addName(Newleaf, "New Leaf");
ModLoader.addName(Newsapling, "New Sapling");
}
public String getVersion()
{
return "Random";
}
public void generateSurface(World world, Random rand, int chunkx, int chunkz)
{
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkx, chunkz);
WorldGenNewtree tree = new WorldGenNewtree();
if(biome instanceof BiomeGenDesert)
{
for(int x = 0; x < 1; x++)
{
int Xcoord = chunkx + rand.nextInt(16);
int Zcoord = chunkz + rand.nextInt(16);
int i = world.getHeightValue(Xcoord, Zcoord);
tree.generate(world, rand, Xcoord, i, Zcoord);
}
}
}
}
You should understand everything if you read the block tutorial, but I explain you something in the generatesurface thing. Where it says "if(biome instanceof BiomeGenDesert)" you can change the BiomeGenDesert to whatever biome you want to spawn your tree.
Part 2 (All the other file)
This will be all the other file that concerns your tree like the log, the leaf, the sappling and the worldgen of your tree.
BlockNewlog.java
package net.minecraft.src;
import java.util.Random;
public class BlockNewlog extends Block
{
protected BlockNewlog(int i, int j)
{
super(i, j, Material.wood);
}
public int quantityDropped(Random random)
{
return 1;
}
public int idDropped(int i, Random random, int j)
{
return mod_mymod.Newlog.blockID;
}
public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
{
super.harvestBlock(world, entityplayer, i, j, k, l);
}
public void onBlockRemoval(World world, int i, int j, int k)
{
byte byte0 = 4;
int l = byte0 + 1;
if(world.checkChunksExist(i - l, j - l, k - l, i + l, j + l, k + l))
{
for(int i1 = -byte0; i1 <= byte0; i1++)
{
for(int j1 = -byte0; j1 <= byte0; j1++)
{
for(int k1 = -byte0; k1 <= byte0; k1++)
{
int l1 = world.getBlockId(i + i1, j + j1, k + k1);
if(l1 != mod_mymod.Newleaf.blockID)
{
continue;
}
int i2 = world.getBlockMetadata(i + i1, j + j1, k + k1);
if((i2 & 8) == 0)
{
world.setBlockMetadata(i + i1, j + j1, k + k1, i2 | 8);
}
}
}
}
}
}
protected int damageDropped(int i)
{
return i;
}
}
I didn't figure out how to make your sapling grow your tree like the other but it's coming.
BlockNewsapling.java
package net.minecraft.src;
import java.util.Random;
public class BlockSapling extends BlockFlower
{
protected BlockSapling(int par1, int par2)
{
super(par1, par2);
float f = 0.4F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (par1World.isRemote)
{
return;
}
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9 && par5Random.nextInt(7) == 0)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if ((i & 8) == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, i | 8);
}
else
{
growTree(par1World, par2, par3, par4, par5Random);
}
}
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
par2 &= 3;
if (par2 == 1)
{
return 63;
}
if (par2 == 2)
{
return 79;
}
if (par2 == 3)
{
return 30;
}
else
{
return super.getBlockTextureFromSideAndMetadata(par1, par2);
}
}
/**
* Attempts to grow a sapling into a tree
*/
public void growTree(World par1World, int par2, int par3, int par4, Random par5Random)
{
int i = par1World.getBlockMetadata(par2, par3, par4) & 3;
Object obj = null;
int j = 0;
int k = 0;
boolean flag = false;
if (i == 1)
{
obj = new WorldGenTaiga2(true);
}
else if (i == 2)
{
obj = new WorldGenForest(true);
}
else if (i == 3)
{
j = 0;
do
{
if (j < -1)
{
break;
}
k = 0;
do
{
if (k < -1)
{
break;
}
if (func_50076_f(par1World, par2 + j, par3, par4 + k, 3) && func_50076_f(par1World, par2 + j + 1, par3, par4 + k, 3) && func_50076_f(par1World, par2 + j, par3, par4 + k + 1, 3) && func_50076_f(par1World, par2 + j + 1, par3, par4 + k + 1, 3))
{
obj = new WorldGenHugeTrees(true, 10 + par5Random.nextInt(20), 3, 3);
flag = true;
break;
}
k--;
}
while (true);
if (obj != null)
{
break;
}
j--;
}
while (true);
if (obj == null)
{
j = k = 0;
obj = new WorldGenTrees(true, 4 + par5Random.nextInt(7), 3, 3, false);
}
}
else
{
obj = new WorldGenTrees(true);
if (par5Random.nextInt(10) == 0)
{
obj = new WorldGenBigTree(true);
}
}
if (flag)
{
par1World.setBlock(par2 + j, par3, par4 + k, 0);
par1World.setBlock(par2 + j + 1, par3, par4 + k, 0);
par1World.setBlock(par2 + j, par3, par4 + k + 1, 0);
par1World.setBlock(par2 + j + 1, par3, par4 + k + 1, 0);
}
else
{
par1World.setBlock(par2, par3, par4, 0);
}
if (!((WorldGenerator)(obj)).generate(par1World, par5Random, par2 + j, par3, par4 + k))
{
if (flag)
{
par1World.setBlockAndMetadata(par2 + j, par3, par4 + k, blockID, i);
par1World.setBlockAndMetadata(par2 + j + 1, par3, par4 + k, blockID, i);
par1World.setBlockAndMetadata(par2 + j, par3, par4 + k + 1, blockID, i);
par1World.setBlockAndMetadata(par2 + j + 1, par3, par4 + k + 1, blockID, i);
}
else
{
par1World.setBlockAndMetadata(par2, par3, par4, blockID, i);
}
}
}
public boolean func_50076_f(World par1World, int par2, int par3, int par4, int par5)
{
return par1World.getBlockId(par2, par3, par4) == blockID && (par1World.getBlockMetadata(par2, par3, par4) & 3) == par5;
}
protected int damageDropped(int par1)
{
return par1 & 3;
}
}
WorldGenNewtree.java
package net.minecraft.src;
import java.util.Random;
public class WorldGenNewtree extends WorldGenerator
{
public WorldGenNewtree()
{
}
public boolean generate(World world, Random random, int i, int j, int k)
{
int l = random.nextInt(1) + 4;
boolean flag = true;
if(j < 1 || j + l + 1 > 256)
{
return false;
}
for(int i1 = j; i1 <= j + 1 + l; i1++)
{
byte byte0 = 1;
if(i1 == j)
{
byte0 = 0;
}
if(i1 >= (j + 1 + l) - 2)
{
byte0 = 2;
}
for(int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
{
for(int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
{
if(i1 >= 0 && i1 < 256)
{
int j3 = world.getBlockId(i2, i1, l2);
if(j3 != 0 && j3 != mod_mymod.Newleaf.blockID)
{
flag = false;
}
} else
{
flag = false;
}
}
}
}
if(!flag)
{
return false;
}
int j1 = world.getBlockId(i, j - 1, k);
if(j1 != Block.sand.blockID && j1 != Block.dirt.blockID && j1 != Block.grass.blockID || j >= 256 - l - 1)
//sand, dirt, grass = the block that the tree can spawn on
{
return false;
}
world.setBlock(i, j - 1, k, Block.dirt.blockID);//dirt = block created under the tree
for(int k1 = (j - 3) + l; k1 <= j + l; k1++)
{
int j2 = k1 - (j + l);
int i3 = 1 - j2 / 2;
for(int k3 = i - i3; k3 <= i + i3; k3++)
{
int l3 = k3 - i;
for(int i4 = k - i3; i4 <= k + i3; i4++)
{
int j4 = i4 - k;
if((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)])
{
setBlockAndMetadata(world, k3, k1, i4, mod_mymod.Newleaf.blockID, 0);
}
}
}
}
for(int l1 = 0; l1 < l; l1++)
{
int k2 = world.getBlockId(i, j + l1, k);
if(k2 == 0 || k2 == mod_mymod.Newleaf.blockID)
{
setBlockAndMetadata(world, i, j + l1, k, mod_mymod.Newlog.blockID, 0);
}
}
return true;
}
}
Creating a new flower
This is how spawn a new flower in Minecraft world Client:
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final BlockFlower Newflower = (BlockFlower)(new BlockFlower(204, ModLoader.addOverride("/terrain.png", "/Mods/Newflower.png")).setHardness(0.0F).setBlockName("Flower").setStepSound(Block.soundGrassFootstep));
public void load()
{
ModLoader.registerBlock(Newflower);
ModLoader.addName(Newflower, "Flower");
}
public void generateSurface(World var1, Random var2, int var3, int var4)
{
int var5;
int var6;
int var7;
int var8;
for(var5 = 0; var5 < 2; ++var5)
{
var6 = var3 + var2.nextInt(16) + 8;
var7 = var2.nextInt(128);
var8 = var4 + var2.nextInt(16) + 8;
(new WorldGenFlowers(mod_mymod.Newflower.blockID)).generate(var1, var2, var6, var7, var8);
}
}
public String getVersion()
{
return "Random";
}
}
If you read creating a new block tutorial, you should understand everything except the genereteSurface thing but just put it there and it's going to be ok.
And the name of my flower is Newflower so don't delete anything else if you copy paste.
Server:
It supposed to be the same thing for server
Creating new Torch
This is how to create a new torch with his own texture. Client:
mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Block Newtorch = (new BlockTorch (201, ModLoader.addOverride("/terrain.png", "/Mods/Newtorch.png")).setHardness(0.0F).setBlockName("Torch").setStepSound(Block.soundWoodFootstep).setLightValue(1.0F).setRequiresSelfNotify());
public void load()
{
ModLoader.registerBlock(Newtorch);
ModLoader.addName(Newtorch, "Torch");
ModLoader.addRecipe(new ItemStack (Newtorch, 1), (new Object[] {
"X", "W", Character.valueOf('X'), Block.dirt, Character.valueOf('W'), Item.stick }));
}
public String getVersion()
{
return "Random";
}
}
If you read the creating a new block and recipe tutorial, you should understand everything. Server:
For server it's the same thing but don't forget that you have to delete the line where it says ModLoader.addName.
Creating a new food
This is how to create a new food like a cookie.
If you want to understand more, read the new item tutorial and the crafting recipe tutorial.
Mod_mymod.java
package net.minecraft.src;
import java.util.Random;
public class mod_mymod extends BaseModMp
{
public static final Item Cookie = (new ItemFood(17005, 10, true).setIconIndex(ModLoader.addOverride("/gui/items.png", "/Mods/Cookie.png")).setItemName("Cookie"));
public void load()
{
ModLoader.addName(Cookie, "Cookie");
ModLoader.addRecipe(new ItemStack (Cookie, 1), (new Object[] {
"WWW", "XXX",Character.valueOf('X'), Item.sugar, Character.valueOf('W'), Item.wheat }));
}
public String getVersion()
{
return "Random";
}
}
The number 10 in the public static final Item cookie means the number of half heart your food will give you.
After Modding
1. When everything is finished and you tested your mod to see if it works, you have to first run recompile.bat
2. Then you have to run reobfuscate.bat
3. Then you go in the reobf folder of mcp and there is your mod file recompiled client an server side. Don't forget to take the texture folder of your mod (it's just for client, you don't need it for server).
4. If you are having problems to reobfuscate the server side go in this spoiler:
1. Copy all the the code of your mod (Client and Server) and put them in two separete folder (one for server and one for client). They are in mcp/src/minecraft/net/minecraft/src for client and in mcp/src/minecraft_server/net/minecraft/src for server.
2. Delete all the code that you copied.
3. Run recompile.bat
4. Run updatemd5.bat and enter "yes".
5. After updating md5 you just have to reput your mod files where you copied them.
6. Run recompile.bat and after, run reobfuscate.bat
7. Everything should work and your mod files should all be in reobfuscate.
To do (comment your idea and maybe i'll put it in my to do list)
- item place block when right click
- sapling for the new tree that make the tree grow
- Nether genereation
- New mob (creating an existing mob with a different texture)
- New liquid
- New mob (your own creating)
Errors ?
If you get an error or just have a problem, comment your error log and/or all your mod files. Send it with a spoiler so it uses less space. thanks !!
This how to make a spoiler but you have to delete the spaces I put.
[ s p o i l e r ]
Unrecoverable error during obfuscation, see log file for details.
RetroGuard error: COM.rl.obf.classfile.ClassFileException: ClassNotFound com/sk8
9q/worldedit/LocalPlayer
==================
Decompile failed
Press any key to continue . . .
Help?
Ok, make sure that everything you used is up to date (mcp, minecraft, minecraft_server, modloader, modloadermp) and make sure you put the right thing in minecraft.jar and minecraft_server.jar
If you are having problems again the only thing I can say is retry again
Oh and make sure you minecraft.jar and server are clean and not modded
I've tried your block tutorial. However, blocks don't spawn in-world for me, nor do they appear on the creative menu. *Shrug* No errors.
Maybe it's me. I tried x2Robbie2x tutorial on youtube as well and had the same exact problem.
Also, this sentence is a bit ambigous:
Modloader.addOverride is the texture and where can we find it. You have to put your texture (16 by 16) in mcp/temp/bin/minecraft and create a new folder called Mods to put all you texture in it. Copy this folder...
Does "this folder" mean the mods folder I've created or the entire mcp/temp/bin/minecraft directory?
I've tried your block tutorial. However, blocks don't spawn in-world for me, nor do they appear on the creative menu. *Shrug* No errors.
Maybe it's me. I tried x2Robbie2x tutorial on youtube as well and had the same exact problem.
Also, this sentence is a bit ambigous:
Does "this folder" mean the mods folder I've created or the entire mcp/temp/bin/minecraft directory?
I did:
/mods ----> /jars/bin/minecraft.jar
Yes, You created a Mods folder in mcp/temp/bin/minecraft to put all your texture in. But to make it works, you have to create de same exact folder in mcp/jars/bin/minecraft.jar. So you just have to copy your "Mods" folder.
you dont understand or? I delete my .minecraft folder, then i run minecraft. So i have a clean jar. And then i download a new minecraft_server.jar... so the Jars are CLEAN.
Sorry because error log are very helpful to make me understand. Just send it to me and I'll help you. (Did you copy the bin and ressources folder or you just copy the minecraft.jar)
Yes, You created a Mods folder in mcp/temp/bin/minecraft to put all your texture in. But to make it works, you have to create de same exact folder in mcp/jars/bin/minecraft.jar. So you just have to copy your "Mods" folder.
Thank you. I will keep banging my head at it until either it works or, more likely, the API comes out and changes modding for 1.3.
Oooooh yes. I talk about this error in the third tip of my "Before Modding" tutorial. It's the exception 2 error. Everything is ok, you are ready to mod but you have to make a little change in the server file. Follow the instruction of the spoiler and you should be alright.
Oh and you will have to run updatemd5.bat. If not, the reobfuscate will not work for the server (I talk about this problem at the "after modding" tutorial.
You may have decompiled with an earlier version of MCP. To fix the recompile error for in the server.jar you now need to delete lines 520-555.
Also, your text cited for removal includes one extraneous curly brace. Deleting this brace then adding another results in a non-change and a resulting error. May I suggest removing that last brace?
**Edit: All is working well for me now. Thank you for this tutorial.
You may have decompiled with an earlier version of MCP. To fix the recompile error for in the server.jar you now need to delete lines 520-555.
Also, your text cited for removal includes one extraneous curly brace. Deleting this brace then adding another results in a non-change and a resulting error. May I suggest removing that last brace?
**Edit: All is working well for me now. Thank you for this tutorial.
I think I copy/paste it to fast but thanks I fixed it.
Damn it, it says that I deleted the Packet class, but there were errors in it -.-' Here's the error:
== MCP 6.2 (data: 6.2, client: 1.2.5, server: 1.2.5) ==
[10:05:31] java.lang.NoClassDefFoundError: net/minecraft/src/Packet
[10:05:31] Caused by: java.lang.ClassNotFoundException: net.minecraft.src.Packet
[10:05:31] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[10:05:31] at java.security.AccessController.doPrivileged(Native Method)
[10:05:31] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[10:05:31] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[10:05:31] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[10:05:31] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[10:05:31] Could not find the main class: net.minecraft.server.MinecraftServer.
Program will exit.
[10:05:31] Exception in thread "main"
'"C:\Program Files\Java\jdk1.6.0_30\bin\java" -Xincgc -Xms1024M -Xmx1024M -cp ".
.\bin\minecraft_serve...' failed : 1
FATAL ERROR
Traceback (most recent call last):
File "runtime\startserver.py", line 30, in startserver
File "D:\MCP mit ModLoaderMP\runtime\commands.py", line 1055, in startserver
self.runmc(forkcmd)
File "D:\MCP mit ModLoaderMP\runtime\commands.py", line 1104, in runmc
raise CalledProcessError(process.returncode, forkcmd, output)
CalledProcessError: Command '"C:\Program Files\Java\jdk1.6.0_30\bin\java" -Xincg
c -Xms1024M -Xmx1024M -cp "..\bin\minecraft_server;..\lib;..\lib\*;..\jars\minec
raft_server.jar" net.minecraft.server.MinecraftServer' returned non-zero exit st
atus 1
Drücken Sie eine beliebige Taste . . .
Question: When I recompiled and reobfuscated the .jar server file, there were no reobfuscated classes for the server -.- What can I do? In the recompiliation/reobfuscation it says : can not find server md5s
Question: When I recompiled and reobfuscated the .jar server file, there were no reobfuscated classes for the server -.- What can I do? In the recompiliation/reobfuscation it says : can not find server md5s
I talk about this in my "after modding" tutorial and how to make your server file to decompile when it doesn't.
Hello everyone, here is my minecraft modding tutorial. I will show you how to create your own minecraft mod with Modloader and ModloaderMp. It will works in singleplayer and in multiplayer. I'll show you the basic of modding but you will have to use your logic to understand and create your own personalised mod.
So here it is!!!
Please, when you create a mod, read the instruction to make sure you don't get an error !!!
Please, start by the block tutorial because you will maybe not understand the other tutorials !!!
Before Modding(If you never mod and don't know how to write new codes and don't know what is mcp):
1. Download Java JDK and JRE here .
2. Download Eclipse here . Go on Eclipse IDE for Java Developers and click 32 Bit or 64 Bit to download.
3. Download the lastest Minecraft Coder Pack here .
4. Create a new folder and put all the mcp files in it.
5. Go in %appdata%/Roaming/.minecraft and copy the bin and ressources folder. Paste them in the jars folder of mcp. You have to use a clean minecraft (not modded).
6. Download minecraft_server.jar here and put it in the jars folder of mcp.
7. Download Modloader here and ModloaderMp client and server side here .
8. Put Modloader and ModloaderMp client side files in the minecraft.jar of the jars folder of mcp. Put ModloaderMp server side in the minecraft_server.jar.
9. Run decompile.bat and wait until it finish.
10. Open Eclipse and go in file/Switch Workspace/Other... And then find the mcp folder and select the eclipse folder.
11. You're ready to mod !!!!
Tip1: to create a new file in eclipse, go in File/new/file and make sure you selected Client/src/net/minecraft/src or for server, Server/src/net/minecraft/src.
Tip2: to test your mod just click on the green button called run in eclipse. If you want to test your mod for server, recompile your mod with recompile.bat and run startclient.bat and startserver.bat.
Error for server when decompile:
When you decompile, a lot of you will get a fail to recompile minecraft_server.java or something. It's normal so follow this to correct it:
1. Go in Server/src/net.minecraft.server/minecraftserver.java with eclipse and the error is suppose to be here.
2. In the minecraft_server.java just delete from line 520 to 555 and replace all this for }.
This is what you are suppose to delete:
4. Run updatemd5.bat to make sure everything will be alright when you will reobfuscate later.
5. Everything should be ok and you are ready to mod.
Modding Tutorials:
Your mod file empty
This is what you will have in every mod. It's like the base of your mod.
The last thing where it says "Random", this is what appear when the mod is loaded in the server command. It will say "mod_mymod Random" in this case. Normaly, you put the version of your mod but you can put whatever you want.
Client:
mod_mymod.java
Server:
For server side it's the same thing
Creating a new block
Part1 (Id, texture, lightvalue, stepsound, hardness, resistance, name)
Client:
Here is how to create a new simple block and don't forget do read what mean what to make sure you understand.
mod_mymod.java
the "new BlockMyblock is the file that is related with your block, so your are supposed to create a file called BlockMyblock.java like I did bellow.
200 is the ID of your block and is has to be from 200 or more.
Modloader.addOverride is the texture and where can we find it. You have to put your texture (16 by 16) in mcp/temp/bin/minecraft and create a new folder called Mods to put all you texture in it. Copy this folder and paste it in mcp/jars/bin/minecraft.jar
Resistance is for explosion and hardness is when you smash on it.
1.0F for lightvalue is the max.
There is more than one soundstep just try to rewrite it yourself and they will all appear.
Modloader.addname sets the name of your block inside minecraft
BlockMyblock.java
I think you can understand it yourself
Server:
For server side it's the same thing but in your mod_***.java you will have to delete all line starting by ModLoader.addName()
For the Block*****.java nothing changes for any tutorials of creating a block.
Part 2 (Dropping anything you want)
To do this you will need to see part 1 of creating a new block
To make it dropped whatever you want you just have to change the end of BlockMyblock.java. Change where it say "public int idDropped".
Exemple for Item:
Exemple for Block
Exemple for a block that you created in your mod
Part 3 (multi-texture)
To do this you will need to see part 1 of creating a new block.
This is how to make your block have a different texture on top, bottom and side.
The 2 things that I add starting by public static int are the texture of your bottom and top in this case but you could add the texture of the side of your block.
mod_mymod.java
For your block file just add this bellow the returnid thing. This will say where are the texture of each sides of your block.
0 = bellow
1 = top
2 = side
3 = side
4 = side
5 = side
4 and 5 are opposite like 2 and 3.
If you don't want to use all of the sides of your block, just do what I do. The thing that says "else" is saying that everything that is not 0 and 1 will be the normal texture that we put in the mod file (public static final Block Myblock.....)
Hope you understand what I said.
Don't forget to put your texture in your folder of texture.
Part 4 (generation)
To do this you will need to see part 1 of creating a new block.
This is how to make your custom block spawning in Minecraft world.
You just have to add the public void generateSurface that you will see in the code bellow
mod_mymod.java
The number 20 mean the spawn rate
Myblock.blockID mean what is the block you want to generate and that is what we want
Part 5 (special effects when touch)
This will make an effect when your player is going to touch the block
Just add this after the idDropped in your block file.
All you have to do is changing the damagesource at the end. It can be a lot of thing just delete .cactus and reput the point and all the choice will appear.
Part 6 (Block change when powered by redstone like the lamp)
This is how to make that when your new block is powered with redstone, it will be transform in a new one and when the power is off, it will return as normal. Exactly like the lamp
mod_mymod.java
If you read the first part you should understand. Except the true and false that I add after the ID. False will be the normal block and true is the block that will appear when powered the other block.
Newblock.java
And this is what you need for the block to work. You could read it to try to understand but... you could.
Part 7 (Block that you can pass through)
This is how to make you able to pass through your new block.
For your basic mod file there is nothing special about it, except that your resistance has to be at 1F.
You have to add 2 things for your block.
Add this
after the iddropped or whatever
And the thing where it says super (i, j, material.cloth) or whatever your material is, it has to be material.portal to make it work.
Creating a new Recipe
Part 1 (crafting recipe)
This how to creating a new crafting recipe.
Client:
Add this in your mod_****.java in the section public void load ()
mod_mymod.java
So this is a recipe that will create one coal (Item.coal, 1)
For the second line of code i'll explain it with some images
ModLoader.addRecipe(new ItemStack (Item.coal, 1), (new Object[] {
"X X", " X ", "XX ", Character.valueOf('X'), Block.dirt }));
ModLoader.addRecipe(new ItemStack (Item.coal, 1), (new Object[] {
"X X", "CCC", "XX ", Character.valueOf('X'), Block.dirt, Character.valueOf('C), Block.planks }));
Server:
For server side nothing changes
Part 2 (smelting recipe)
This how to create a new smelting recipe
Client:
Add this in your mod_****.java in the section public void load ()
This will transform dirt into sand. If you want to transform an item, you have to write Item.*****.shiftedIndex instead of Block.*****.blockID and if you want the result to be an item it has to be Item.**** instead of Block.***.
Server:
For server side nothing changes
Part 3 (add fuel)
This is how to create new fuel for the furnace
Client:
Just add this bellow public void() like this:
If you want an item to be fuel you have to put Item.*****.shiftedIndex instead of Block.****.blockID.
I return 12800 but you could return whatever you want. Exemple: coal=1600, lava=20000, blazerod=2400, wood=300.
Server:
Same thing for server, nothing changes
Creating a new item
Part 1 (id, texture)
This how to create new item
Client:
mod_mymod.java
ModLoader.addOverride is the same thing as in the 1st part of creating a new block. It says where is the texture of it. So you have to put your texture (16 by 16) in mcp/temp/bin/minecraft and create a new folder called Mods (if you have created it already put it in there). Copy this folder and paste it in mcp/jars/bin/minecraft.jar
Modloader.addName sets the name of your item inside Minecraft
Myitem.java
This is your item file and there is nothing special in it.
Server:
For server side it's the same thing but in your mod_***.java you will have to delete all line starting by ModLoader.addName()
For the myitem.java nothing changes just like blocks.
Techne
This tutorial is very important for other tutorials you maybe want to do.
What is techne ?
Techne is used to create models.
What are models ?
Models are used for making complexe form, like mob(pig, zombie, etc.) and complicated block (boat, sign, etc.). Remember it's not making the mob it self or the block, it is just making it shape. Making models are normaly very difficult but thanks to Techne.
Download
Here is the official topic to download Techne ----> DOWNLOAD
Creating a new Model with Techne
1. After downloading and installing Techne, open it.
2.There is supposed to be a little window appearing, choose the name of your model but it is facultative.
3. You can choose a base model like pig and then modify it but it is facultative. You can choose "ModelBase" if you don't want to have a model.
4. Make sure the texture is 64 width and 32 Height.
5. Click create and you can start creating your new model. Use right click and mouse to move around the area.
6. First, you have to create a new box by clicking the blue box in left screen.
7. A box should appear, you can move it around by using the position section in left screen. Recommend to stay in one block width and height wich is 16 by 16.
8. To modify the shape of the little box use the dimensions section in left screen.
9. Right know, if I was you, I should not touch to the Offset section in left screen.
10. You can use the rotation section in left screen to make your block be in diagonal.
11. If you want to delete a box, select the box you want and click delete box in left screen. Oh and you can create more than one box.
12. You can change the name of the box in right screen (model tree).
13. Now the texture. After creating your shape, you need to create a new folder (where you want) to put everything you create in it.
14. Click File/Export as/ Texture map and save it in your new folder. In left screen, click Load Texture and find the texture you just created.
15. Now you can modify the texture with whatever program you want and when you save the modification you put on the texture, it will appear immediately in Techne.
16. Now the model file that you will put in your minecraft. Click File/Export as/Java and save it in your new folder.
17. This is it, you just create a new model but to implent it in minecraft follow the Block Manipulation part 3 tutorial. I didn't do a tutorial yet on mob so...
Block manipulation
Part 1 (changing shape)
This is how to change the shape of your block
First you have to add 2 things after the public int idDropped in your block file
1.
2.
Then you have to set the blockbounds bellow the super(i, j) thing, just like this
To make you understand how blockbounds works go see this spoiler
(0F, 0F, 0F, 1F, 1F, 1F)
(0.5F, 0F, 0F, 1F, 1F, 1F)
(0F, 0.5F, 0F, 1F, 1F, 1F)
(0F, 0F, 0.5F, 1F, 1F, 1F)
(0F, 0F, 0F, 0.5F, 1F, 1F)
(0F, 0F, 0F, 1F, 0.5F, 1F)
(0F, 0F, 0F, 1F, 1F, 0.5F)
Part 2 (changing type or render)
This is how to change the type of render of your block.
You have to add like the 1st part these two things bellow idDropped in your block file
And to change the render type add this
To make your block renderer different just change the return 0 to something in the list here
0
1
2
3
5
6
10
12
13 (cactus style)
14
Part 3 (Block shape very advanced with Techne)
You need to know how to use Techne in this tutorial. If you don't, I got a tutorial on how to use it.
This is how to implent a block with a very specify shape that you created with Techne.
Client:
mod_mymod.java
Here I created the block, loaded the TileEntity and make sure it renders the block as an item in minecraft.
BlockNewblock.java
If your block is little and you see in minecraft that the selection of the block is big you can add a block bounds.
ModelNewblock.java
This part is made with Techne, you just have to add this thing for each part of your block.
TileEntityNewblock.java
Here you don't have to put anything.
TileEntityNewblockRenderer.java
Server:
Do the same thing but you don't have to put the modelNewblock.java and the TileEntityNewblock.java
For mod_mymod.java, delete modloader.addName, tileent1 at the end of modloader.registerTileEntity and this in public void load() :
And delete this too:
Credit: Ducky.
Creating a new kit
part 1 (New material)
This is how to to create your own material like wood, rock, steel, gold and diamond. You will need this if don't want your sword and tools to have the same properties as wood, rock and all ther stuff.
EnumDirtToolMaterial.java
Ok, to make your tools and sword different from other material you will need to change this: DIRT(1, 30, 1.0F, 0, 10). The first number is the harvest level, the second is the max uses, the third is the effeciency, the fourth is the damage vs mob and the last one defines the natural enchantability factor of the material. To compare with other materials go in EnumToolMaterial.java.
ItemDirtTool.java
You will need to create this too
Part 2 (Sword, Tool)
Creating a new sword and tools (recommended)
mod_mymod.java
If you want to understand you need to read the item tutorial
If you want your sword and tools to have different properties, you have to change EnumToolMaterial.WOOD. Change the "WOOD" for any other material.
If you want it to have the properties of your new material that you made in part 1 (Dirt) change the "new ItemSword(17000, EnumToolMaterial.WOOD)" for "new ItemDirtSword(17000, EnumDirtToolMaterial.DIRT)"
Creating a new sword and tools. If you use this tutorial it's because you want to possibly add some special effect to you sword or tools.
This is how to create a new sword, pickaxe, hoe , axe and shovel.
mod_mymod.java
ItemDirtSword.java
ItemDirtPickaxe.java
ItemDirtHoe.java
ItemDirtAxe.java
ItemDirtShovel.java
Part 3 (Armor)
This is how to create your own armor with it own properties.
mod_mymod.java
You should understand everything if you read the item tutorial except the ModLoader.addArmor. This means you have to put 2 texture in mcp/temp/bin/minecraft/armor and mcp/jars/bin/minecraft.jar/armor (dirt_1.png and dirt_2.png). Go in the armor folder and you'll see why we call it this way.
EnumDirtArmorMaterial.java
This is like the EnumDirtToolMaterial.java, it is new material for armor so if you want to create a new armor with new properties you have to create this. If you want to change the properties (DIRT("DIRT", 25, 29, new int[] {2, 7, 5, 3}, 9)) of your armor, just go in EnumArmorMaterial.java and compare with the other materials.
DirtItemArmor.java
This one, just copy it and change the dirt. You don't need to understand it but you have to know that when you create this, it's because you created the EnumDirtArmorMaterial.java.
Creating a new Tree
Part 1 (Mod file and generation)
This is your mod file for your new tree, there should be some error because you didn't create the other file that goes with it and that is the part 2.
You should understand everything if you read the block tutorial, but I explain you something in the generatesurface thing. Where it says "if(biome instanceof BiomeGenDesert)" you can change the BiomeGenDesert to whatever biome you want to spawn your tree.
Part 2 (All the other file)
This will be all the other file that concerns your tree like the log, the leaf, the sappling and the worldgen of your tree.
BlockNewlog.java
BlockNewleaf.java
I didn't figure out how to make your sapling grow your tree like the other but it's coming.
BlockNewsapling.java
WorldGenNewtree.java
Creating a new flower
This is how spawn a new flower in Minecraft world
Client:
mod_mymod.java
If you read creating a new block tutorial, you should understand everything except the genereteSurface thing but just put it there and it's going to be ok.
And the name of my flower is Newflower so don't delete anything else if you copy paste.
Server:
It supposed to be the same thing for server
Creating new Torch
This is how to create a new torch with his own texture.
Client:
mod_mymod.java
If you read the creating a new block and recipe tutorial, you should understand everything.
Server:
For server it's the same thing but don't forget that you have to delete the line where it says ModLoader.addName.
Creating a new food
This is how to create a new food like a cookie.
If you want to understand more, read the new item tutorial and the crafting recipe tutorial.
Mod_mymod.java
The number 10 in the public static final Item cookie means the number of half heart your food will give you.
After Modding
1. When everything is finished and you tested your mod to see if it works, you have to first run recompile.bat
2. Then you have to run reobfuscate.bat
3. Then you go in the reobf folder of mcp and there is your mod file recompiled client an server side. Don't forget to take the texture folder of your mod (it's just for client, you don't need it for server).
4. If you are having problems to reobfuscate the server side go in this spoiler:
1. Copy all the the code of your mod (Client and Server) and put them in two separete folder (one for server and one for client). They are in mcp/src/minecraft/net/minecraft/src for client and in mcp/src/minecraft_server/net/minecraft/src for server.
2. Delete all the code that you copied.
3. Run recompile.bat
4. Run updatemd5.bat and enter "yes".
5. After updating md5 you just have to reput your mod files where you copied them.
6. Run recompile.bat and after, run reobfuscate.bat
7. Everything should work and your mod files should all be in reobfuscate.
To do (comment your idea and maybe i'll put it in my to do list)
- item place block when right click
- sapling for the new tree that make the tree grow
- Nether genereation
- New mob (creating an existing mob with a different texture)
- New liquid
- New mob (your own creating)
Errors ?
If you get an error or just have a problem, comment your error log and/or all your mod files. Send it with a spoiler so it uses less space. thanks !!
This how to make a spoiler but you have to delete the spaces I put.
[ s p o i l e r ]
[ / s p o i l e r ]
# found jad, jad patches, ff patches, osx patches, srgs, name csvs, doc csvs, pa
ram csvs, astyle, astyle config
> Creating Retroguard config files
!! Modified jar detected. Unpredictable results !!
== Decompiling client using JAD ==
> Creating SRGs
> Applying Retroguard
'"C:\Program Files\Java\jdk1.7.0_03\bin\java" -cp "runtime\bin\retroguard.jar;li
b;lib\*;jars\bin\mine...' failed : 1
== ERRORS FOUND ==
Unrecoverable error during obfuscation, see log file for details.
RetroGuard error: COM.rl.obf.classfile.ClassFileException: ClassNotFound com/sk8
9q/worldedit/LocalPlayer
==================
Decompile failed
Press any key to continue . . .
Help?
Ok, make sure that everything you used is up to date (mcp, minecraft, minecraft_server, modloader, modloadermp) and make sure you put the right thing in minecraft.jar and minecraft_server.jar
If you are having problems again the only thing I can say is retry again
Oh and make sure you minecraft.jar and server are clean and not modded
Please tell me whats wrong.
I'll repeat, you have to use a CLEAN minecraft.jar and minecraft_server.jar. It means that no mod are installed in those two jar.
Maybe it's me. I tried x2Robbie2x tutorial on youtube as well and had the same exact problem.
Also, this sentence is a bit ambigous:
Does "this folder" mean the mods folder I've created or the entire mcp/temp/bin/minecraft directory?
I did:
/mods ----> /jars/bin/minecraft.jar
Yes, You created a Mods folder in mcp/temp/bin/minecraft to put all your texture in. But to make it works, you have to create de same exact folder in mcp/jars/bin/minecraft.jar. So you just have to copy your "Mods" folder.
Sorry because error log are very helpful to make me understand. Just send it to me and I'll help you. (Did you copy the bin and ressources folder or you just copy the minecraft.jar)
Thank you. I will keep banging my head at it until either it works or, more likely, the API comes out and changes modding for 1.3.
Oooooh yes. I talk about this error in the third tip of my "Before Modding" tutorial. It's the exception 2 error. Everything is ok, you are ready to mod but you have to make a little change in the server file. Follow the instruction of the spoiler and you should be alright.
Oh and you will have to run updatemd5.bat. If not, the reobfuscate will not work for the server (I talk about this problem at the "after modding" tutorial.
You may have decompiled with an earlier version of MCP. To fix the recompile error for in the server.jar you now need to delete lines 520-555.
Also, your text cited for removal includes one extraneous curly brace. Deleting this brace then adding another results in a non-change and a resulting error. May I suggest removing that last brace?
**Edit: All is working well for me now. Thank you for this tutorial.
I think I copy/paste it to fast but thanks I fixed it.
Did you test the server side of your mod by starting the startserver.bat (and the startclient.bat to test it)
I talk about this in my "after modding" tutorial and how to make your server file to decompile when it doesn't.