Basic Blocks
A basic block is a block basically like dirt, or stone so you're going to be making plenty of these. So let's start out with our Core File shall we? We just need to add a few lines of code to our old class (if you don't know they're red and you can delete the comments I've made if you haven't realized that yet :D):
Core Class:
package mymod.common;
import net.minecraft.src.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.SidedProxy;
//These register the blocks and items you have yet to make.
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "ID of Your Mod", name = "Name of Your Mod", version = "Version of Your Mod")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
@SidedProxy(clientSide = "mymod.client.ClientProxy", serverSide = "mymod.common.CommonProxy")
public static CommonProxy proxy;
//This is the basic method that you need to be able to use other methods.
public static Block BasicBlock;
@Init
public void Init(FMLInitializationEvent event)
{
//All you have to know here is that 3000 is the actual item ID of your block and that 0 is the texture from the spritesheet you've made. 0 would be all the way at the top left. GameRegistry.registerBlock registers the block into Minecraft. LanguageRegistry.addName gives the Block it's name. The actual name is inside of the quotations. Change that to whatever you need it to be.
BasicBlock = new BlockBasicBlock(3000, 0);
GameRegistry.registerBlock(BasicBlock);
LanguageRegistry.addName(BasicBlock, "Basic Block");
proxy.registerRenderThings();
}
}
Next, let's make the actual Block class since we have an error in the core file. Name it BlockBasicBlock or BlockWhateverYouWant. Then copy and paste this code, I've made some comments to guide you through it. After that's done that should be all!
BlockBasicBlock:
package mymod.common;
import net.minecraft.src.*;
import java.util.Random;
import java.util.List;
public class BlockBasicBlock extends Block
{
public BlockBasicBlock(int a, int b)
{
//These are the methods that really matter. Material.rock means what type of block it is, keep experimenting with that, you might be suprised!
super(a, b, Material.rock);
//Name of the block.
this.setBlockName("Normal Block");
//How long it will take to mine the block.
this.setHardness(10F);
//How strong it is against an exposion (TNT, Creeper, etc.)
this.setResistance(100F);
//What sounds it makes when you step on it.
this.setStepSound(soundStoneFootstep);
//What Creative Tab to display it on, I'll put a tutorial on how to make your own eventually.
this.setCreativeTab(CreativeTabs.tabBlock);
}
//What block is dropped when mined.
public int idDropped(int a, Random random,int b)
{
return TestMod.NormalBlock.blockID;
}
//How many blocks are dropped when mined.
public int quantityDropped(Random random)
{
return 1;
}
//This is basically called a Subscript and will show under the block name if you scroll over it. I'll probably put up a tutorial on this later.
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("A Normal Block");
}
//This was explained in the 16X textures tutorial. This just basically sets what spritesheet to use.
public String getTextureFile()
{
return "/myblocks.png";
}
}
Core Class:
package mymod.common;
import net.minecraft.src.*;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.SidedProxy;
//These register the blocks and items you have yet to make.
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "ID of Your Mod", name = "Name of Your Mod", version = "Version of Your Mod")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class CoreModFileName
{
@SidedProxy(clientSide = "mymod.client.ClientProxy", serverSide = "mymod.common.CommonProxy")
public static CommonProxy proxy;
//This is the basic method that you need to be able to use other methods.
public static Block BasicBlock;
@Init
public void Init(FMLInitializationEvent event)
{
//All you have to know here is that 3000 is the actual item ID of your block and that 0 is the texture from the spritesheet you've made. 0 would be all the way at the top left. GameRegistry.registerBlock registers the block into Minecraft. LanguageRegistry.addName gives the Block it's name. The actual name is inside of the quotations. Change that to whatever you need it to be.
BasicBlock = new BlockBasicBlock(3000, 0);
GameRegistry.registerBlock(BasicBlock);
LanguageRegistry.addName(BasicBlock, "Basic Block");
proxy.registerRenderThings();
}
}
Next, let's make the actual Block class since we have an error in the core file. Name it BlockBasicBlock or BlockWhateverYouWant. Then copy and paste this code, I've made some comments to guide you through it. After that's done that should be all!
BlockBasicBlock:
package mymod.common;
import net.minecraft.src.*;
import java.util.Random;
import java.util.List;
public class BlockBasicBlock extends Block
{
public BlockBasicBlock(int a, int b)
{
//These are the methods that really matter. Material.rock means what type of block it is, keep experimenting with that, you might be suprised!
super(a, b, Material.rock);
//Name of the block.
this.setBlockName("Normal Block");
//How long it will take to mine the block.
this.setHardness(10F);
//How strong it is against an exposion (TNT, Creeper, etc.)
this.setResistance(100F);
//What sounds it makes when you step on it.
this.setStepSound(soundStoneFootstep);
//What Creative Tab to display it on, I'll put a tutorial on how to make your own eventually.
this.setCreativeTab(CreativeTabs.tabBlock);
}
//What block is dropped when mined.
public int idDropped(int a, Random random,int b)
{
return TestMod.NormalBlock.blockID;
}
//How many blocks are dropped when mined.
public int quantityDropped(Random random)
{
return 1;
}
//This is basically called a Subscript and will show under the block name if you scroll over it. I'll probably put up a tutorial on this later.
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("A Normal Block");
}
//This was explained in the 16X textures tutorial. This just basically sets what spritesheet to use.
public String getTextureFile()
{
return "/myblocks.png";
}
}