What separates this tutorial page from the other fifty? Well, everything and nothing! To explain, this is gonna be more community-oriented. That means that yes, I will make modding tutorials, but no, I will not make a modding tutorial that says the exact thing that wuppy21 said in his - that is pointless and wasted time. Instead, I might put in quotes tutorials from tutorials by other modders that are good along with a link to the original page, giving them the credit they deserve. I also might edit additional detail that I thought they left out or change it to work with the latest version of Forge. What else does this mean? You can share your own tutorials! If you're good at some particular subject, plop down a quick reply! I'll read over it, and if it's good, I'll link to it on this first post!
I like the way simo did his tutorials a while back with linking to the replies, so I'll be right there doing Quick Replies with the rest of you! Oh, and if you see just a bunch of code in one of the replies, that means that it works, and I'm gonna work on explaining it later.
Tutorial Directory The links work now!
Setting Up Difficulty: 2/10 Last Update: 3/16/13 Minecraft Version: 1.5.0 MCP Version: 7.42 Author: fisherman77
Creating a Basic Block Difficulty: 3/10 Last Update: 3/28/13 Minecraft Version: 1.5.1 MCP Version: 7.44 Author: fisherman77
Creating a Basic Item Difficulty: 3/10 Last Update: 3/17/13 Minecraft Version: 1.5.0 MCP Version: 7.42 Author: fisherman77
i'm not saying yours are terrible, cause they're not, you explain it well. i just put the link for people who want to update as fast as possible
Ya, I get that - it's fine! It's just that I plan to do more than just Forge-specific tutorials, such as adding blocks and items and that stuff. I also want to do stuff that's awesome, such as extending mobs to make them tamable, fly[able?], names above their heads; structure generation; etc.
Awesome, but could you make a tutorial on creating a mob with Forge 1.3.1/1.3.2? I tried to follow the tutorial on the wiki and it didn't work, or help me whatsoever. My mobs work, they just do not render with my models, and instead use the biped model.
In this tutorial, I'm gonna show you how to set everything up to make a working mod that adds completely nothing, but serves as a foundation. I'm gonna get to explaining more later, because there's plenty of other tutorials that cover this well, and I just want to get to the stuff that changed in 1.5 first.
Setting Up
This is based off of Deverion's Forge Modding tutorial, with a few extra stuff added in.
Tutorial.java:
package fisherman77.Tutorial.common; //The package your mod is in
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
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 fisherman77.Tutorial.client.TutorialClientProxy;
import fisherman77.Tutorial.common.handlers.TutorialClientPacketHandler;
import fisherman77.Tutorial.common.handlers.TutorialServerPacketHandler;
@NetworkMod(clientSideRequired=true,serverSideRequired=true, //Whether client side and server side are needed
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialClientPacketHandler.class), //For clientside packet handling
serverPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialServerPacketHandler.class)) //For serverside packet handling
@Mod(modid="Tutorial",name="fish's Tutorial",version="1.5.0")
public class Tutorial {
@Instance("Tutorial") //The instance, this is very important later on
public static Tutorial instance = new Tutorial();
@SidedProxy(clientSide = "fisherman77.Tutorial.client.TutorialClientProxy", serverSide = "fisherman77.Tutorial.common.TutorialCommonProxy") //Tells Forge the location of your proxies
public static TutorialCommonProxy proxy;
@PreInit
public void PreInit(FMLPreInitializationEvent e)
{
}
@Init
public void InitTutorial(FMLInitializationEvent event){ //Your main initialization method
//MULTIPLAYER ABILITY
NetworkRegistry.instance().registerGuiHandler(this, proxy); //Registers the class that deals with GUI data
//BLOCKS (METHOD)
proxy.registerBlocks(); //Calls the registerBlocks method
}
}
TutorialClientProxy.java:
package fisherman77.Tutorial.client;
import fisherman77.Tutorial.common.TutorialCommonProxy;
import net.minecraftforge.client.MinecraftForgeClient;
public class TutorialClientProxy extends TutorialCommonProxy {
public void registerRenderInformation(){
}
}
We would usually have to preload a texture in the registerRenderInformation method, something like:
But, in 1.5, this isn't the case! No more preloading textures!
TutorialCommonProxy.java:
package fisherman77.Tutorial.common;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
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;
public class TutorialCommonProxy implements IGuiHandler{ //THIS IS IMPORTANT, CANNOT BE A PROXY/GUI HANDLER WITHOUT THIS!!
public void registerRenderInformation() //Client side texture registering
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
public void registerTiles(){ //For registering TileEntities
}
public void registerBlocks(){ //For registering Blocks
}
public void registerItems(){ //For adding Items
}
}
TutorialClientHandler.java:
package fisherman77.Tutorial.common.handlers;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.*;
@SideOnly(Side.CLIENT)
public class TutorialClientPacketHandler implements IPacketHandler{
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data)); //Handles incoming data
}
}
TutorialServerPacketHandler.java:
package fisherman77.Tutorial.common.handlers;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class TutorialServerPacketHandler implements IPacketHandler{
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data)); //Handles incoming data
EntityPlayer sender = (EntityPlayer) player;
}
}
In this tutorial, I'm gonna show you how to create a new block. This block will do -you guessed it- nothing right now, but hey, not blocks don't usually do too much! If you follow along my other tutorials, You'll see that blocks can actually do quite a lot!
Creating A Basic Block
First, we've gotta register it in our main classes, Tutorial.java, which is our main class, and then for organization, we use CommonProxy to add in the recipes.
Tutorial.java:
package fisherman77.Tutorial.common; //The package your mod is in
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
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 fisherman77.Tutorial.client.TutorialClientProxy;
import fisherman77.Tutorial.common.biome.BiomeGenGlacier;
import fisherman77.Tutorial.common.blocks.TutorialBlockBlock;
import fisherman77.Tutorial.common.blocks.BlockGreenTutorial;
import fisherman77.Tutorial.common.config.TutorialConfigCore;
import fisherman77.Tutorial.common.tabs.TabTutorial;
import fisherman77.Tutorial.common.handlers.TutorialClientPacketHandler;
import fisherman77.Tutorial.common.handlers.TutorialServerPacketHandler;
@NetworkMod(clientSideRequired=true,serverSideRequired=true, //Whether client side and server side are needed
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialClientPacketHandler.class), //For clientside packet handling
serverPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialServerPacketHandler.class)) //For serverside packet handling
@Mod(modid="Tutorial",name="Glacier Ice",version="1.5.0")
public class Tutorial {
@Instance("Tutorial") //The instance, this is very important later on
public static Tutorial instance = new Tutorial();
@SidedProxy(clientSide = "fisherman77.Tutorial.client.TutorialClientProxy", serverSide = "fisherman77.Tutorial.common.TutorialCommonProxy") //Tells Forge the location of your proxies
public static TutorialCommonProxy proxy;
//BLOCKS
public static Block TutorialBlock; //this is declaring a variable for our block that we can refer to later
@PreInit
public void PreInit(FMLPreInitializationEvent e)
{
TutorialBlock = new BlockTutorialBlock(4095).setUnlocalizedName("TutorialBlock");
}
@Init
public void InitTutorial(FMLInitializationEvent event){ //Your main initialization method
//MULTIPLAYER ABILITY
NetworkRegistry.instance().registerGuiHandler(this, proxy); //Registers the class that deals with GUI data
//BLOCKS (METHOD)
proxy.registerBlocks(); //Calls the registerBlocks method
}
}
We have now created a variable for the block, and then in the PreInit method, stated that the BlockTutorialBlock.java class is the java class for Tutorial Block. In addition, we have also given Tutorial Block an ID. Block IDs are allowed to range from 158 - 4096 in Forge, so don't just confine yourself to below 256! This helps reduce incompatibilities with other mods that add blocks that want to use the same ID as you. I'll make an ID list later, but until then, go to this outdated one: http://www.minecraft...opic,638.0.html
TutorialCommonProxy.java:
package fisherman77.Tutorial.common;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
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;
public class TutorialCommonProxy implements IGuiHandler{ //THIS IS IMPORTANT, CANNOT BE A PROXY/GUI HANDLER WITHOUT THIS!!
public void registerRenderInformation() //Client side texture registering
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
public void registerTiles(){ //For registering TileEntities
}
public void registerBlocks(){ //For registering Blocks
//Tutorial Block
GameRegistry.registerBlock(Tutorial.TutorialBlock, "TutorialBlock");
LanguageRegistry.addName(Tutorial.TutorialBlock, "Tutorial Block");
}
public void registerItems(){ //For adding Items
}
}
Now we have registered the block using GameRegistry, and have also given it our desired in-game name with LanguageRegistry.
TutorialBlock.java:
package fisherman77.Tutorial.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.*;
import fisherman77.Tutorial.common.Tutorial;
public class BlockTutorialBlock extends Block{
public BlockTutorialBlock(int ID){
super(ID,Material.rock); //The ID and material
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("Tutorial:TutorialBlock"); //adding in a texture, 1.5.1 style!
}
}
*Note that in 1.5.1 we changed from the func_#### thing that was pretty random to referring to the texturing method as registerIcons().
To explain, we have set the foundation from where a lot of cool things for our block can come from in this class, and we have also given our block a 16x16 px texture. Now, here's the tricky part!
Now, we must put our .png inside the right file system for it to work. Here's how we arrange the folders:
In this tutorial, I'm gonna show you how to create a basic item. Does it do anything? No. Is it still awesome? Yes.
Creating a Basic Item
Tutorial.java.java:
package fisherman77.Tutorial.common; //The package your mod is in
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
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 fisherman77.Tutorial.client.TutorialClientProxy;
import fisherman77.Tutorial.common.handlers.TutorialClientPacketHandler;
import fisherman77.Tutorial.common.handlers.TutorialServerPacketHandler;
@NetworkMod(clientSideRequired=true,serverSideRequired=true, //Whether client side and server side are needed
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialClientPacketHandler.class), //For clientside packet handling
serverPacketHandlerSpec = @SidedPacketHandler(channels = {"Tutorial"}, packetHandler = TutorialServerPacketHandler.class)) //For serverside packet handling
@Mod(modid="Tutorial",name="fish's Tutorial",version="1.5.0")
public class Tutorial {
@Instance("Tutorial") //The instance, this is very important later on
public static Tutorial instance = new Tutorial();
@SidedProxy(clientSide = "fisherman77.Tutorial.client.TutorialClientProxy", serverSide = "fisherman77.Tutorial.common.TutorialCommonProxy") //Tells Forge the location of your proxies
public static TutorialCommonProxy proxy;
//ITEMS
public static Item TutorialItem;
@PreInit
public void PreInit(FMLPreInitializationEvent e)
{
TutorialItem = new ItemTutorialItem(5000).setUnlocalizedName("TutorialItem");
}
@Init
public void InitTutorial(FMLInitializationEvent event){ //Your main initialization method
//MULTIPLAYER ABILITY
NetworkRegistry.instance().registerGuiHandler(this, proxy); //Registers the class that deals with GUI data
//BLOCKS (METHOD)
proxy.registerBlocks(); //Calls the registerBlocks method
//ITEMS (METHOD)
proxy.registerItems();
}
}
ItemTutorialItem is the specific class for our item. For example, coal's is ItemCoal.java
5000 is the Item's ID. This can be really any number, but try to keep it below 30000 unless you need to go higher, because it'll just get confusing. Also make sure to keep it above 4096. Since blocks can have the IDs 4096 and below, we like to keep those IDs open so that we can have as many blocks as possible. If you ignore that, then Forge will reassign a random Item ID above 4096 for you.
Also, we have now called up the registerItems() method in our main class, just thought I should note that change, since it wasn't in the original mod file.
TutorialCommonProxy.java:
package fisherman77.Tutorial.common;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
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;
public class TutorialCommonProxy implements IGuiHandler{ //THIS IS IMPORTANT, CANNOT BE A PROXY/GUI HANDLER WITHOUT THIS!!
public void registerRenderInformation() //Client side texture registering
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
public void registerTiles(){ //For registering TileEntities
}
public void registerBlocks(){ //For registering Blocks
}
public void registerItems(){ //For adding Items
LanguageRegistry.addName(Tutorial.TutorialItem, "Tutorial Item");
}
}
Now we just assigned our preferred name using LanguageRegistry
TutorialItem.java:
package fisherman77.zeuscraft.common.items;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.*;
import fisherman77.zeuscraft.common.Zeuscraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class ItemNectar extends Item {
public ItemNectar(int par1) {
super(par1); //Returns super constructor: par1 is ID
}
@Override
public void func_94581_a(IconRegister iconRegister)
{
iconIndex = iconRegister.func_94245_a("Tutorial:TutorialItem");
}
}
To explain, we have set the foundation from where a lot of cool things for our item can come from in this class, and we have also given our block a 16x16 px texture. Now, here's the tricky part!
Now, we must put our .png inside the right file system for it to work. Here's how we arrange the folders:
Since we've already created our block and Item, this tutorial's gonna be really short, and actually only deal with one class, our CommonProxy.
TutorialCommonProxy:
package fisherman77.Tutorial.common;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
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;
public class TutorialCommonProxy implements IGuiHandler{ //THIS IS IMPORTANT, CANNOT BE A PROXY/GUI HANDLER WITHOUT THIS!!
public void registerRenderInformation() //Client side texture registering
{
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { //For GUI's
return null;
}
public void registerTiles(){ //For registering TileEntities
}
public void registerBlocks(){ //For registering Blocks
//Tutorial Block
GameRegistry.registerBlock(Tutorial.TutorialBlock, "TutorialBlock");
LanguageRegistry.addName(Tutorial.TutorialBlock, "Tutorial Block");
GameRegistry.addRecipe(new ItemStack(Tutorial.TutorialBlock,1), "XXX","XXX","XXX", Character.valueOf('X'), Block.bedrock);
}
public void registerItems(){ //For adding Items
//Tutorial Item
LanguageRegistry.addName(Tutorial.TutorialItem, "Tutorial Item");
GameRegistry.addRecipe(new ItemStack(Zeuscraft.Column,1), "XBX","XMX","XXX", Character.valueOf('X'), Block.bedrock, Character.valueOf('B'), Item.appleRed, Character.valueOf('M'), Tutorial.TutorialBlock);
}
}
As you can see, you use the same format for both blocks and items.
The "XBX", "XMX", "XXX" would look like this on a crafting table:
XBX
XMX
XXX
Also, as you can see in TutorialItem's crafting recipe, we can incorporate our own custom blocks/items into our recipe by referring back to our main class (in this tutorial, Tutorial.java)
It's time for some fun! Today, I'm gonna show you how to make a more advanced item, one that spawns a block.
Block-Spawning Item
Lot's of this is based off of Flint and Steel, since it spawns a fire block, so refer to there if you feel confused. For this example, we'll use a trowel. When right clicked, the trowel will spawn bricks.
ItemTutorial.java:
package fisherman77.Tutorial.common.items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.*;
import fisherman77.Tutorial.common.Tutorial;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
public class ItemTrowel extends Item {
public ItemTrowel(int par1) {
super(par1); //Returns super constructor: par1 is ID
}
@Override
public void func_94581_a(IconRegister iconRegister)
{
iconIndex = iconRegister.func_94245_a("Tutorial:Trowel");
}
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
if (par7 == 0)
{
--par5;
}
if (par7 == 1)
{
++par5;
}
if (par7 == 2)
{
--par6;
}
if (par7 == 3)
{
++par6;
}
if (par7 == 4)
{
--par4;
}
if (par7 == 5)
{
++par4;
}
if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
{
return false;
}
else
{
int var11 = par3World.getBlockId(par4, par5, par6);
if (var11 == 0)
{
par3World.func_94575_c(par4, par5, par6, Block.brick.blockID);
}
par1ItemStack.damageItem(1, par2EntityPlayer);
return true;
}
}
}
You can change the "brick" to whatever block you want it to spawn
This is a really quick tutorial. I just thought it's kind of cool. If you have a really special item, and you want to make it seem really cool like those enchanted tools and such.
Epic Rare Item
All you have to do is simply insert this somewhere in your Item's class:
And now I'm gonna show you how to create a custom creative tab, and how to add items and blocks to that creative tab.
Custom Creative Tab
First, I think I learned this from Deverion's tutorials, so I give him credit.
Let's add our tab into our main class:
//TUTORIAL CREATIVE TAB
public static CreativeTabs tabTutorial = new TabTutorial(CreativeTabs.getNextID(),"Tutorial"); //Our custom creative tab's object
Instead of CreativeTabs.getNextID() we can also insert an ID for our creative tab, and I've seen people do that, but hold yourself to a higher standard and don't cause unnecessary conflicts with other mods.
Next for our tab's class:
TabTutorial.java:
package fisherman77.Tutorial.common.tabs;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.*;
import fisherman77.Tutorial.common.Tutorial;
public class TabTutorial extends CreativeTabs {
public TabTutorial(int position, String tabID) {
super(position, tabID);
}
@SideOnly(Side.CLIENT)
public int getTabIconItemIndex()
{
return Tutorial.TutorialItem.itemID; //this is the item that is displayed on your tab's icon
}
public String getTranslatedTabLabel()
{
return "Tutorial"; //the name that shows up in-game
}
}
Lastly, we can now add items and blocks into our creative tab.
Insert this into the top of your item's/block's class:
setCreativeTab(Tutorial.tabTutorial);
So here's what a finished item class would look like:
package fisherman77.Tutorial.common.items;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.*;
import fisherman77.zeuscraft.common.Zeuscraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class ItemMegaDiamond extends Item {
public ItemMegaDiamond(int par1) {
super(par1); //Returns super constructor: par1 is ID
setCreativeTab(Tutorial.tabTutorial);
}
@Override
public void func_94581_a(IconRegister iconRegister)
{
iconIndex = iconRegister.func_94245_a("Tutorial:MegaDiamond");
}
}
And a block class:
package fisherman77.Tutorial.common.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.*;
import fisherman77.Tutorial.common.Tutorial;
public class BlockTutorialBlock extends Block{
public BlockTutorialBlock(int ID){
super(ID,Material.rock); //The ID and material
setCreativeTab(Tutorial.tabTutorial);
}
@Override
public void func_94332_a(IconRegister par1IconRegister)
{
this.field_94336_cN = par1IconRegister.func_94245_a("Tutorial:TutorialBlock"); //adding in a texture, 1.5 style!
}
}
Is there a way to make a place able item? (i want glas)
No. You're thinking of blocks. BUT! You can also Make a block that has a custom model to make it look similar to an item. Maybe I'll do a tutorial on that someday.
Hey fishy. It's me Do you know how to make 2 items that use the same class have different textures? Because if you have to create a class for each item then that's a pain in the ass D:
Hey fishy. It's me Do you know how to make 2 items that use the same class have different textures? Because if you have to create a class for each item then that's a pain in the ass D:
Hey! The answer is: I don't think so. Just copy and paste the code is your best bet!
What separates this tutorial page from the other fifty? Well, everything and nothing! To explain, this is gonna be more community-oriented. That means that yes, I will make modding tutorials, but no, I will not make a modding tutorial that says the exact thing that wuppy21 said in his - that is pointless and wasted time. Instead, I might put in quotes tutorials from tutorials by other modders that are good along with a link to the original page, giving them the credit they deserve. I also might edit additional detail that I thought they left out or change it to work with the latest version of Forge. What else does this mean? You can share your own tutorials! If you're good at some particular subject, plop down a quick reply! I'll read over it, and if it's good, I'll link to it on this first post!
I like the way simo did his tutorials a while back with linking to the replies, so I'll be right there doing Quick Replies with the rest of you! Oh, and if you see just a bunch of code in one of the replies, that means that it works, and I'm gonna work on explaining it later.
Tutorial Directory
The links work now!
Setting Up
Difficulty: 2/10
Last Update: 3/16/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Creating a Basic Block
Difficulty: 3/10
Last Update: 3/28/13
Minecraft Version: 1.5.1
MCP Version: 7.44
Author: fisherman77
Creating a Basic Item
Difficulty: 3/10
Last Update: 3/17/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Crafting Recipes
Difficulty: 1/10
Last Update: 3/17/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Block-Spawning Item
Difficulty: 2/10
Last Update: 3/17/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Epic Rare Item
Difficulty: 1/10
Last Update: 3/17/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Custom Creative Tab
Difficulty: 1/10
Last Update: 3/17/13
Minecraft Version: 1.5.0
MCP Version: 7.42
Author: fisherman77
Possibly, I'm not that familiar with that at all though...
He is right! That is useful too!
Ya, I get that - it's fine! It's just that I plan to do more than just Forge-specific tutorials, such as adding blocks and items and that stuff. I also want to do stuff that's awesome, such as extending mobs to make them tamable, fly[able?], names above their heads; structure generation; etc.
Download the AliensVsPredator Minecraft Mod today at http://aliensvspredator.org
Download the AliensVsPredator Minecraft Mod today at http://aliensvspredator.org
Setting Up
This is based off of Deverion's Forge Modding tutorial, with a few extra stuff added in.
Tutorial.java:
TutorialClientProxy.java:
We would usually have to preload a texture in the registerRenderInformation method, something like:
But, in 1.5, this isn't the case! No more preloading textures!
TutorialCommonProxy.java:
TutorialClientHandler.java:
TutorialServerPacketHandler.java:
Creating A Basic Block
First, we've gotta register it in our main classes, Tutorial.java, which is our main class, and then for organization, we use CommonProxy to add in the recipes.
Tutorial.java:
We have now created a variable for the block, and then in the PreInit method, stated that the BlockTutorialBlock.java class is the java class for Tutorial Block. In addition, we have also given Tutorial Block an ID. Block IDs are allowed to range from 158 - 4096 in Forge, so don't just confine yourself to below 256! This helps reduce incompatibilities with other mods that add blocks that want to use the same ID as you. I'll make an ID list later, but until then, go to this outdated one: http://www.minecraft...opic,638.0.html
TutorialCommonProxy.java:
Now we have registered the block using GameRegistry, and have also given it our desired in-game name with LanguageRegistry.
TutorialBlock.java:
*Note that in 1.5.1 we changed from the func_#### thing that was pretty random to referring to the texturing method as registerIcons().
To explain, we have set the foundation from where a lot of cool things for our block can come from in this class, and we have also given our block a 16x16 px texture. Now, here's the tricky part!
Now, we must put our .png inside the right file system for it to work. Here's how we arrange the folders:
/mcp/eclipse/Minecraft/bin/mods/Tutorial/textures/blocks/TutorialBlock.png
That is the file path that we need in order to make sure the textures work. Note that you will most likely have to create the "mods" folder.
Now we're done! You've just created for yourself a basic block in Minecraft 1.5
Awesome. Ya, there was one error - you need to setUnlocalizedName on your block in you mod file. Just fixed it.
Creating a Basic Item
Tutorial.java.java:
ItemTutorialItem is the specific class for our item. For example, coal's is ItemCoal.java
5000 is the Item's ID. This can be really any number, but try to keep it below 30000 unless you need to go higher, because it'll just get confusing. Also make sure to keep it above 4096. Since blocks can have the IDs 4096 and below, we like to keep those IDs open so that we can have as many blocks as possible. If you ignore that, then Forge will reassign a random Item ID above 4096 for you.
Also, we have now called up the registerItems() method in our main class, just thought I should note that change, since it wasn't in the original mod file.
TutorialCommonProxy.java:
Now we just assigned our preferred name using LanguageRegistry
TutorialItem.java:
To explain, we have set the foundation from where a lot of cool things for our item can come from in this class, and we have also given our block a 16x16 px texture. Now, here's the tricky part!
Now, we must put our .png inside the right file system for it to work. Here's how we arrange the folders:
/mcp/eclipse/Minecraft/bin/mods/Tutorial/textures/items/TutorialItem.png
That is the file path that we need in order to make sure the textures work. Note that you will most likely have to create the "mods" folder.
Now we're done! You've just created for yourself a basic item in Minecraft 1.5.
Crafting Recipes
Since we've already created our block and Item, this tutorial's gonna be really short, and actually only deal with one class, our CommonProxy.
TutorialCommonProxy:
As you can see, you use the same format for both blocks and items.
The "XBX", "XMX", "XXX" would look like this on a crafting table:
XBX
XMX
XXX
Also, as you can see in TutorialItem's crafting recipe, we can incorporate our own custom blocks/items into our recipe by referring back to our main class (in this tutorial, Tutorial.java)
Block-Spawning Item
Lot's of this is based off of Flint and Steel, since it spawns a fire block, so refer to there if you feel confused. For this example, we'll use a trowel. When right clicked, the trowel will spawn bricks.
ItemTutorial.java:
You can change the "brick" to whatever block you want it to spawn
Epic Rare Item
All you have to do is simply insert this somewhere in your Item's class:
So here's an example:
Custom Creative Tab
First, I think I learned this from Deverion's tutorials, so I give him credit.
Let's add our tab into our main class:
Instead of CreativeTabs.getNextID() we can also insert an ID for our creative tab, and I've seen people do that, but hold yourself to a higher standard and don't cause unnecessary conflicts with other mods.
Next for our tab's class:
TabTutorial.java:
Lastly, we can now add items and blocks into our creative tab.
Insert this into the top of your item's/block's class:
So here's what a finished item class would look like:
And a block class:
No. You're thinking of blocks. BUT! You can also Make a block that has a custom model to make it look similar to an item. Maybe I'll do a tutorial on that someday.
Visit my youtube channel? http://www.youtube.com/user/TheCoolgatty
Hey! The answer is: I don't think so. Just copy and paste the code is your best bet!