Blogs Tutorial

[Modding Tutorial #2] Simple Block.

  • 861 views 0 today
  • 3
  • 0
  • 8
Twinklez
Lvl 76Legendary Modder
327
Number 2 of this whole series. Please if you have any errors / problems just comment or PM me :)
YOU MUST READ THE FIRST TUTORIAL IF YOU DON'T KNOW HOW TO SET UP MCP with ECLIPSE!!!

So today we are going to make a new simple block with the statistics as like pretty much a normal block.

You must create two files. One being the main ModLoader class extender, and the Block file.
Open these spoilers to get the code. The " // " means a comment AKA it's just explaining. The code doesn't read the comments. So these are pretty safe to copy and paste.

BUT SINCE THIS IS A CUSTOM BLOCK USING THE BLOCK.CLASS YOU DO NOT NEED TO MAKE A NEW BLOCK!!!! :D

mod_YOURMOD [Change YOURMOD to any name
[Change NAME to your block name!]]
package net.minecraft.src;

public class mod_YOURMOD extends BaseMod
{
public static final Block NAME = (new Block (175, ModLoader.addOverride("/terrain.png", "/a.png")).setBlockName("NAME").setHardness(1F).setResistance(1F));

//Hardness means how long it takes to break. 1F means gravel with hand.
//Resistance means TNT / Creeper protection. 1F means instant break ROFL.
//Every new block with .setBlockName NEEDS TO BE DIFFERENT!!!
// 150 is the ID number. Blocks must be around 150 - 256.
//Block picture is the picture so if its a.png your have to create a a.png inside the mod contents.

public mod_YOURMOD()
{
ModLoader.registerBlock(NAME);
//Change the INGAMENAME to the name you want it to be in the game. ironBlock = Block of Iron.
ModLoader.addName(NAME, "INGAMENAME");
ModLoader.addRecipe(new ItemStack(NAME, 1), new Object [] {
"XXX", "YYY", "XXX", 'X', Block.stone, 'Y', Block.dirt });

// Now recipes are the confusing part. "" means the recipe. '' means the block.
// So XXX YYY XXX means the first layer second layer then the third layer.
// XXX So the X is stone. And the Y is dirt. And that makes the BLOCK!
// YYY
// XXX
// The NAME, 1 means How many this recipe creates. If you change 1 to 16 it will create 16. DO NOT MAKE IT OVER 64!
}

public void load()
{ //Just ModLoader configuration. Not required. Unless you want to rofl.

}

public String getVersion()
{
return "1.4.5"; //Make this the latest minecraft version or the current one.
}
}

3 Update Logs

Update #3 : by Twinklez 12/07/2012 11:42:26 pmDecember 8, 2012 @ 4:42 am UTC

Changed methods for easier learning.
LOAD MORE LOGS

More like this

  Have something to say?

Boose38
03/19/2013 10:06 pm
Level 15 : Journeyman Grump
Confuzzling, I'm trying my best to try to understand a word of this, but when I do, thanks!
1
Boose38
03/19/2013 10:11 pm
Level 15 : Journeyman Grump
Okay, I get it PARTIALLY. How do you make a class file and how the heck do you open it?
1
awj001
12/04/2012 7:10 pm
Level 8 : Apprentice Network
Good job!
1
Danthec00lman
12/01/2012 2:40 pm
Level 49 : Master Blockhead
Hey, I know Javascript, but, what's the difference between Java and Javascript??? :)
1
Twinklez
12/01/2012 3:41 pm
Level 76 : Legendary Modder
Java = Programming for Games. etc.
Javascript = Programming for mostly websites.
1
Danthec00lman
12/02/2012 1:09 pm
Level 49 : Master Blockhead
Ok, but are the languages similar? Because I see some javascript stuff in the coding thing. :)
1
Twinklez
12/02/2012 1:19 pm
Level 76 : Legendary Modder
Javascript mostly has some statements like public, etc. etc.

BUT THEY ARE SUPER DIFFERENT.
1
Danthec00lman
12/02/2012 1:36 pm
Level 49 : Master Blockhead
Oh, Ok :D
1

Welcome