Lets make a basic block first! We will make Copper Ore as our first block!
Main Class
package chickensballz.Tutorial.common; //the package
import net.minecraft.block.Block; //Imports that you will need
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.SidedProxy;
import chickensballz.MoAdventure.common.TutorialModCommonProxy;
import chickensballz.MoAdventure.common.blocks.BlockCopperOre; //change this to your block
import chickensballz.MoAdventure.common.handlers.MoAdventureClientPacketHandler;
import chickensballz.MoAdventure.common.handlers.MoAdventureServerPacketHandler;
@NetworkMod(clientSideRequired=true,serverSideRequired=true,
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"NameoftheMod"}, packetHandler = MoAdventureClientPacketHandler.class),
serverPacketHandlerSpec = @SidedPacketHandler(channels = {"NameoftheMod"}, packetHandler = MoAdventureServerPacketHandler.class))
@Mod(modid="Name",name="Name",version="Version of the mod")
public class TutorialMod {
@Instance("Name") //The instance
public static TutorialMod instance = new TutorialMod();
@SidedProxy(clientSide = "chickensballz.Tutorial.client.TutorialModClientProxy", serverSide = "chickensballz.common.TutorialModCommonProxy")
public static MoAdventureCommonProxy proxy;
public static Block CopperOre;
@PreInit
public void PreInit(FMLPreInitializationEvent e){
CopperOre = new BlockCopperOre(3800).setHardness(3.0F).setResistance(10.0F).setUnlocalizedName("copperOre").setCreativeTab(CreativeTabs.tabBlock); //Hardness = How long it takes to break the block, Resistance = Resistance to explosion, UnlocalizedName = needed for texture and other stuff.
@Init
public void InitTutorialMod(FMLInitializationEvent event){
proxy.registerBlocks();
NetworkRegistry.instance().registerGuiHandler(this, proxy);
}
}
BlockCopperOre
package chickensballz.Tutorial.common.blocks; //package
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; //imports that you will need
public class BlockCopperOre extends Block
{
public BlockCopperOre(int par1)
{
super(par1, Material.rock); //The material of the block
}
public void registerIcons(IconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon("folder:UnlocalizedNameHere"); //texture
}
}
CommonProxy
package chickensballz.Tutorial.common; //package
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; //list of imports you will need
public class TutorialModCommonProxy implements IGuiHandler{ //DO NOT CHANGE ANYTHING EXCEPT ITS NAME
public void registerRenderInformation()
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
public void registerTiles(){
}
public void registerBlocks(){
GameRegistry.registerBlock(TutorialMod.CopperOre, "copperOre"); //name
LanguageRegistry.addName(TutorialMod.CopperOre, "Copper Ore "); //in-game name
}
public void registerItems(){
}
}
Basic Item
Copper Ore without Copper Ingot is stupid! Let's make Copper Ingot now!
Main Class
Add this
public static Item CopperIngot;
under
public static TutorialModCommonProxy proxy;
Add this under PreInit
CopperIngot = new ItemCopperIngot(ItemID).setCreativeTab(CreativeTabs.tabMaterials);
Common Proxy
Add this!
GameRegistry.registerItem(TutorialMod..CopperIngot, "copperIngot"); //name
LanguageRegistry.addName(TutorialMod.CopperIngot, "Copper Ingot"); //In-game name
I will have to create a new folder in /forge/mcp/eclipse/Minecraft/bin called assets. inside the assets folder, you will have to create a new folder called ChickensBallz, then, inside THAT folder, create a new folder called textures, then, in the texture folder, create 2 folders called blocks and items. Finally, you can put your textures there.
Enchanted Effect on Items
This is really easy, first, open your ItemClass and add this
public boolean hasEffect(ItemStack par1ItemStack) {
return true;
Change true to false if you don't want the enchanted effect.
Here is the final code.
package chickensballz.Tutorial.common;
import chickensballz.Tutorial.common.TutorialMod;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
public class ItemCopperSword extends ItemSword{
public ItemCopperSword(int par1, EnumToolMaterial par2EnumToolMaterial) {
super(par1, par2EnumToolMaterial);
}
private EnumToolMaterial material;
public void registerIcons(IconRegister iconRegister) {
itemIcon = iconRegister.registerIcon("tutorialmod:copperSword");
}
public boolean hasEffect(ItemStack par1ItemStack) {
return false;
}
}
Tools tutorial coming soon?
Extended Tool Tips for Items
Add this into your itemclass
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean i)
{
list.add("\u00A76Copper is good <3");
Result
Change the 6 in
\u00A76
to other for other cool color/effects!
0 - Black 1 - Dark Blue 2 - Dark Green 3 - Cyan 4 - Dark Red 5 - Purple 6 - Gold 7 - Gray 8 - Dark Gray 9 - Blue a - Green b - Aqua c - Red d - Pink e - Yellow f -White
Format Code -
k - Random Stuffs l - Bold m - Strikethrough n - Underline
o - Italic
Block Generation
In this tutorial, I am going to make my Copper Ore spawn naturally.
Make a new class called CopperOreWorldGeneration
Copy and paste
package chickensballz.Tutorial.common; //package
import java.util.Random;
import net.minecraft.world.World; //Imports
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
public class CopperOreWorldGeneration implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
switch (world.provider.dimensionId) {
case -1:
generateNether();
break;
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
break;
case 1:
generateEnd();
break;
}
}
public void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
for (int i = 0; i < 40; i++) { //40 is how many block will spawn in one chunk.
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(64); //64 is the height
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(TutorialMod.CopperOre.blockID, 10)).generate(world, rand, randPosX, randPosY, randPosZ); //Change 10 to any number, this is how many block will spawn together.
}
}
public void generateNether() {
}
public void generateEnd() {
}
}
I would suggest that you create tutorials about things which aren't already covered by others
All the stuff in the vote section are quite basic stuff which have been made several tutorials about!
the tutorial is a bit of on the texture side due to the recent updates but except that it should be correct.
I used it on my learningMod ages ago and when I updated it to 1.6 all I had to change was the textures
So it works, if you have problems following it, I would suggest you try again and if you still have a problem then go here: http://www.minecraftforge.net/forum/index.php/board,73.0.html and get help I'm sure it will be easy for us there to help you with your troubles
How Create a 3D item? for Example a Sword, I need add a 3D Sword in my mod, As i do (I need the code, model the swords is very easy), and the code for put the Sword in the hand of Steve, but only if you can, but only the code for the sword to add...
For the basic set up, take a look over at fisherman77's guide!
= Easy
= Normal
= Advanced
Basic Block
Main Class
BlockCopperOre
CommonProxy
Basic Item
Main Class
Add this under
Add this under PreInit
Common Proxy
Add this!
ItemCopperIngot
Crafting and Smelting Recipe
Imports you will need.
Crafting Recipe
The Recipe will be like this = Empty Empty
================== Empty Empty
================== Empty Empty =
Smelting Recipe
The Recipe will be like this = ->
Texture
This is the code from my BlockCopperOre. Now, how do you do textures? folder is the name of the folder, UnlocalizedName is the name of the texture. THE TEXTURE MUST BE A PNG PICTURE. For example if I used I will have to create a new folder in /forge/mcp/eclipse/Minecraft/bin called assets. inside the assets folder, you will have to create a new folder called ChickensBallz, then, inside THAT folder, create a new folder called textures, then, in the texture folder, create 2 folders called blocks and items. Finally, you can put your textures there.
Enchanted Effect on Items
Change true to false if you don't want the enchanted effect.
Here is the final code.
Tools tutorial coming soon?
Extended Tool Tips for Items
Result
Change the 6 in to other for other cool color/effects!
0 - Black
1 - Dark Blue
2 - Dark Green
3 - Cyan
4 - Dark Red
5 - Purple
6 - Gold
7 - Gray
8 - Dark Gray
9 - Blue
a - Green
b - Aqua
c - Red
d - Pink
e - Yellow
f - White
Format Code -
k - Random Stuffs
l - Bold
m -
Strikethroughn - Underline
o - Italic
Block Generation
Make a new class called CopperOreWorldGeneration
Copy and paste
Now... In your CommonProxy
All the stuff in the vote section are quite basic stuff which have been made several tutorials about!
Why re-invent the wheel, you could do beginner stuff which not everyone has done over and over? ^^
Already done:
http://www.minecraftforge.net/wiki/Containers_and_GUIs
I used it on my learningMod ages ago and when I updated it to 1.6 all I had to change was the textures
So it works, if you have problems following it, I would suggest you try again and if you still have a problem then go here:
http://www.minecraftforge.net/forum/index.php/board,73.0.html and get help I'm sure it will be easy for us there to help you with your troubles
you can instead use this code:
This works especially well if you are making a single class for your mod items to extend.