Minecraft Blogs / Tutorial

modding tutorials 3: blocks

  • 784 views, 1 today
  • 8
  • 2
  • 5
waterskier's Avatar waterskier
Level 54 : Grandmaster Pony
158
hey everyone. Today I'm going to be showing you how to make a new block with the properties of stone. Let's get started.

we need 2 classes to make a block
Blockyourblock and mod_yourblock

mod_yourblock
just like always we need our mod_ classes to extend basemod, have load, and have getversion
mod_ start
package net.minecraft.src;

public class mod_yourblock extends BaseMod
{
public void load()
{
}

public String getVersion()
{
return "1.2.5";
}
}

after that you need to add this in the load method
yourblock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/yourblock.png");
ModLoader.registerBlock(yourblock);
ModLoader.addName(yourblock, "yourblock");
on the first/second line you see the addoverride method
this means that blocks are normally on terrain.png and you are overriding that and saying instead you want it to show yourblock.png
then on the rest we are just registering and adding a name to the block
next we need to add this but not inside load
public static final Block yourblock = new Blockyourblock(160, 0).setBlockName("yourblock").setHardness(3F).setResistance(4F).setLightValue(1F);
this is giving the block all of its properties
160 is the block id and the others set the name,how hard it it,how much blast resistance it has, and how much light it puts out.
your mod_ class should now look like this
mod_ finished
package net.minecraft.src;

public class mod_Block extends BaseMod
{
public static final Block yourblock = new Blockyourblock(160, 0).setBlockName("yourblock").setHardness(3F).setResistance(4F).setLightValue(1F);

public void load()
{
Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/yourblock.png");
ModLoader.registerBlock(yourblock);
ModLoader.addName(yourblock, "yourblock");
}

public String getVersion()
{
return "1.2.5";
}
}


now the blockyourblock class
copy and paste this in to start
Blockyourblock start
package net.minecraft.src;
import java.util.Random;

public class Blockyourblock extends Block
{

then you need this
public BlockNamehere(int i, int j)
{
super(i, j, Material.stone);
}

public int idDropped(int i, Random random, int j)
{
return mod_yourblock.yourblock.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}}
this says the material, what it drops, and how much it drops
here is how it should look when its done
Blockyourblock finished
package net.minecraft.src;
import java.util.Random;

public class Blockyourblock extends Block
{
public Blockyourblock(int i, int j)
{
super(i, j, Material.stone);
}

public int idDropped(int i, Random random, int j)
{
return mod_yourblock.yourblock.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}}

thanks for reading.Leave any error code in the comments along with suggestions for new tutorials,and as always diamond and subscribe!!!

p.s. the tutorials will be continuing on youtube so I don't have too many on my profile
and sorry about the tutorial being sloppy because I am really sick
Tags

Create an account or sign in to comment.

1
05/12/2012 5:32 am
Level 45 : Master Lava Rider
BurningSkullz99
BurningSkullz99's Avatar
TOO COMPLICATED AHHHH I NEED HELP!!!
1
05/11/2012 6:01 pm
Level 18 : Journeyman Mountaineer
Fink The Mink
Fink The Mink's Avatar
Next week do mobs :D
1
05/12/2012 3:06 am
Level 54 : Grandmaster Pony
waterskier
waterskier's Avatar
ok ill do that for next week then prbly biomes after that
1
05/06/2012 9:08 pm
Level 66 : High Grandmaster Hero
sed11
sed11's Avatar
1 question.
What do we change to show what it drops?like rename what? *The return mod_yourblock.yourblock.blockID.Replace with a number?*

EDIT: Nevermind a video you made helped........
1
05/04/2012 8:59 pm
Level 24 : Expert Narwhal
Cutieblackbear
Cutieblackbear's Avatar
:D
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome