PARTICIPANT IN A FINALISTS JAM
This Blog is an entry in the completed Minetorials : Tutorials with a Minecraft Theme.

Minecraft Blogs / Tutorial

[1.2.5] [Easy to Follow!] Modding with felixmc - How to create your very own basic block with a recipe!

  • 1,511 views, 1 today
  • 13
  • 8
  • 26
felixmc's Avatar felixmc
Level 74 : Legendary Programmer
665
How to code a basic block 1.2.5

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:

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()
{

}

}


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;
}

}

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

Create an account or sign in to comment.

1
09/16/2012 7:27 pm
Level 8 : Apprentice Crafter
Skymantis
Skymantis's Avatar
nice someday i will need this when i make my first mod dont know when
1
09/06/2012 5:20 am
Level 24 : Expert Blacksmith
ALphaslucas
ALphaslucas's Avatar
finally, now i dont have to do freaking dirt to diamonds
1
08/30/2012 8:38 am
Level 69 : High Grandmaster Meme
VeryMadCrafter
VeryMadCrafter's Avatar
Can you make another tut how to make your own mob?
That would be cool!!!
1
07/24/2012 7:04 pm
Level 29 : Expert Modder
Kingofamager
Kingofamager's Avatar
There is something wrong! Dont know why writein this blog of yours i just do.

Somehow i cant reobfuscate can you tell me how to?
1
07/20/2012 11:41 am
Level 43 : Master Taco
cobra_fett
cobra_fett's Avatar
when i open decompile .bat it says cannot find the path specified plz help
1
11/29/2012 6:40 pm
Level 76 : Legendary Modder
Twinklez
Twinklez's Avatar
Make the Path in Environmental Table on JAVA.

DOWNLOAD JRE7.

The path is:
64BIT:
C:UsersUSERNAMEProgram Files (x86)Javajre7bin

32BIT.
C:UsersUSERNAMEProgram FilesJavajre7bin

YOUR WELCOME :D
1
07/16/2012 3:26 pm
Level 61 : High Grandmaster Programmer
NuclearBanana
NuclearBanana's Avatar
2 thing..listen this future modders!!!

1) when u put the block ID - (253, 0)..it is better to replace that 0 with
ModLoader.addOverride("/terrain.png","/Block.png"); ...so the code will look like this -

(253,
ModLoader.addOverride("/terrain.png","/Block.png")
)

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
1
07/16/2012 3:29 pm
Level 74 : Legendary Programmer
felixmc
felixmc's Avatar
^^^^^^^^^^^^^^^
Some great tips!
1
07/16/2012 3:39 pm
Level 61 : High Grandmaster Programmer
NuclearBanana
NuclearBanana's Avatar
I have more, but those are just the tips that every person with java knowlage should know
1
07/16/2012 9:49 am
Level 37 : Artisan Geek
Upper_Echelon
Upper_Echelon's Avatar
Amazing make more of these! Thank you
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome