Minecraft Blogs

Jet's Modding Tutorials/Blocks/1.0.0

  • 4
  • 2
  • 2
avatar Jetthebuizel
Level 46 : Master Gent
129
Hello PMC today I will be teaching you how to code/make a block. First setup MCP. Need help? Go here http://www.minecraftforum.net/topic/473884-modloader-strengths-tutorialshelp-261011/. Things to know.
1.Curly brackets opening { and closing }
2.Setup MCP
3.And IDE preferably Eclipse or EditRocket.

To start lets make a new java source file and name it mod_LEM (The lem and can be anything you want).
Now lets start off this file by putting this on the first line:

package net.minecraft.src;

Alright now put:

public class mod_LEM extends BaseMod

Then put an opening {
And then we describe our block:

public static Block AmethystOre = new BlockAmethystOre(123, 0).setHardness(5.0F).setResistance(1.0F).setLightValue(0.0F).setBlockName("Amethyst Ore");

That will declare our block. (NOTE: The amethyst ore is from my mod so you can name it what you want)
Now press enter a few times and put this. Make sure you have the curly bracket.

public mod_LEM()
{

Now you will want to put this. (NOTE: You can change the crafting recipe to something different. Make sure its either Item.something or Block.something.)

ModLoader.RegisterBlock(AmethystBlock);
ModLoader.AddName(AmethystBlock, "Amethyst Block");
AmethystBlock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/LEM/blocks/amethystblock.png");
ModLoader.AddRecipe(new ItemStack(AmethystBlock, 1), new Object[]
{"SSS", "SSS", "SSS", Character.valueOf('S'), Block.dirt });

NOTE: I know that was big but you can copy and paste it.

Press enter and put a closing bracket }.
Always make sure you have this outside that last curly bracket

@Override
public String getVersion() {
// TODO Auto-generated method stub
return "1.0.0";
}

@Override
public void load(){

}}

NOTE: You put your textures in MCP/jars/bin/minecraft.jar/and what your folder is called.
We're almost done. Now you need to make one more file BlockNamehere (NOTE:Namehere can be changed)
Now you can copy and paste this if you want.

package net.minecraft.src;
import java.util.Random;

public class BlockAmethystBlock extends Block
{
public BlockAmethystBlock(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_LEM.Block.dirt.shiftedIndex;
}
public int quantityDropped(Random random)
{
return 9;
}
}

And you can chagne how many it drops by changing that 9 to another number. You can change that Material.rock to what ever you want too.
Need help email me at: smwhte@gmail.com. Or contact me on skype at. jetthebuizel23
Thanks
CreditStregth's Tutorial
Tags

1
03/29/2012 8:11 pm
Level 36 : Artisan Architect
KevyBevy
Thanks! This helped!
1
03/29/2012 8:55 pm
Level 46 : Master Gent
Jetthebuizel
No problem.
Planet Minecraft Logo

Website

© 2010 - 2020
www.planetminecraft.com

Welcome