665
How to code a basic block 1.2.5
Hello PlanetMinecraft!
Hello PlanetMinecraft!
I'm assuming you have already set up MCP and decompiled everything. If not, go here to these links:
WINDOWS: www.planetminecraft.com/blog/windows-minecraft-modding-how-to-setup-mcp/
MAC: www.planetminecraft.com/blog/mac-minecraft-modding-setting-up-mcp/
1.
You will need to make a file called mod_BlockNameHere. Today, I will be creating a block called Felix Block. So, we need to make a new file called mod_FelixBlock.java. Make the file in your src folder in MCP. What you want to do now, is make sure the file is in PLAIN TEXT FORMAT. Then, copy and paste this code into the file:
FelixBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/felix/FelixBlock.png");
This line declares where your texture will be. In this case, I will have a folder called 'felix' and inside, a texture called FelixBlock.png.
new BlockFelixBlock(253,0).setHardness(3.0F).setLightValue(0.0F).setBlockName("Felix");
The 253 is the block ID of this block. 3.0 is how hard it is, 3 is stone hardness. The light value is how much light it emits. 2 is the highest.
ModLoader.addName(FelixBlock, "Felix Block");
The "Felix Block" is the ingame name of the block.
ModLoader.addRecipe(new ItemStack(FelixBlock), new Object[]{
"X*X", "*X*", "X*X", Character.valueOf('*'), Item.gunpowder, Character.valueOf('X'), Block.stone
This is the recipe. The first " " is the top row of the crafting table, and the next " " is the middle row and so on. * means gunpowder in this case, and X means stone in this case. So, you would craft it like this:
SGS
GSG
SGS
S = Stone
G = Gunpowder
2.
Next, we will create a new file called BlockFelixBlock.java. Same as the mod_FelixBlock but with this code:
return mod_FelixBlock.FelixBlock.blockID;
This means it will drop itself.
recompile your mod, reobfuscate, and run Minecraft to adore your first Minecraft block!
WINDOWS: www.planetminecraft.com/blog/windows-minecraft-modding-how-to-setup-mcp/
MAC: www.planetminecraft.com/blog/mac-minecraft-modding-setting-up-mcp/
1.
You will need to make a file called mod_BlockNameHere. Today, I will be creating a block called Felix Block. So, we need to make a new file called mod_FelixBlock.java. Make the file in your src folder in MCP. What you want to do now, is make sure the file is in PLAIN TEXT FORMAT. Then, copy and paste this code into the file:
mod_FelixBlock.java
package net.minecraft.src;
import java.util.Random;
public class mod_FelixBlock extends BaseMod
{
public static final Block FelixBlock =
new BlockFelixBlock(253,0).setHardness(3.0F).setLightValue(0.0F).setBlockName("Felix");
public mod_FelixBlock()
{
ModLoader.registerBlock(FelixBlock);
FelixBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/felix/FelixBlock.png");
ModLoader.addName(FelixBlock, "Felix Block");
ModLoader.addRecipe(new ItemStack(FelixBlock), new Object[]{
"X*X", "*X*", "X*X", Character.valueOf('*'), Item.gunpowder, Character.valueOf('X'), Block.stone
});
}
public String getVersion()
{
return "1.2.5";
}
public void load()
{
}
}
import java.util.Random;
public class mod_FelixBlock extends BaseMod
{
public static final Block FelixBlock =
new BlockFelixBlock(253,0).setHardness(3.0F).setLightValue(0.0F).setBlockName("Felix");
public mod_FelixBlock()
{
ModLoader.registerBlock(FelixBlock);
FelixBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/felix/FelixBlock.png");
ModLoader.addName(FelixBlock, "Felix Block");
ModLoader.addRecipe(new ItemStack(FelixBlock), new Object[]{
"X*X", "*X*", "X*X", Character.valueOf('*'), Item.gunpowder, Character.valueOf('X'), Block.stone
});
}
public String getVersion()
{
return "1.2.5";
}
public void load()
{
}
}
FelixBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png","/felix/FelixBlock.png");
This line declares where your texture will be. In this case, I will have a folder called 'felix' and inside, a texture called FelixBlock.png.
new BlockFelixBlock(253,0).setHardness(3.0F).setLightValue(0.0F).setBlockName("Felix");
The 253 is the block ID of this block. 3.0 is how hard it is, 3 is stone hardness. The light value is how much light it emits. 2 is the highest.
ModLoader.addName(FelixBlock, "Felix Block");
The "Felix Block" is the ingame name of the block.
ModLoader.addRecipe(new ItemStack(FelixBlock), new Object[]{
"X*X", "*X*", "X*X", Character.valueOf('*'), Item.gunpowder, Character.valueOf('X'), Block.stone
This is the recipe. The first " " is the top row of the crafting table, and the next " " is the middle row and so on. * means gunpowder in this case, and X means stone in this case. So, you would craft it like this:
SGS
GSG
SGS
S = Stone
G = Gunpowder
2.
Next, we will create a new file called BlockFelixBlock.java. Same as the mod_FelixBlock but with this code:
BlockFelixBlock.java
package net.minecraft.src;
import java.util.Random;
public class BlockFelixBlock extends Block
{
protected BlockFelixBlock (int i, int j)
{
super(i,j,Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_FelixBlock.FelixBlock.blockID;
}
}
import java.util.Random;
public class BlockFelixBlock extends Block
{
protected BlockFelixBlock (int i, int j)
{
super(i,j,Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_FelixBlock.FelixBlock.blockID;
}
}
return mod_FelixBlock.FelixBlock.blockID;
This means it will drop itself.
recompile your mod, reobfuscate, and run Minecraft to adore your first Minecraft block!
Tags |
tools/tracking
1146345
6
125-easy-to-follow-minecraft-modding---how-to-create-your-very-own-basic-block
Create an account or sign in to comment.
That would be cool!!!
Somehow i cant reobfuscate can you tell me how to?
DOWNLOAD JRE7.
The path is:
64BIT:
C:UsersUSERNAMEProgram Files (x86)Javajre7bin
32BIT.
C:UsersUSERNAMEProgram FilesJavajre7bin
YOUR WELCOME :D
1) when u put the block ID - (253, 0)..it is better to replace that 0 with
(253,
2) You don't need to put Character.valueOf(''X), Item.appleRed...This is a short version of it ('X'), Item.appleRed ... It is a lot better
Some great tips!