Note: Anything i put in [] is your
option to the thing you name it; and no spaces;
If You Dont Know How To Setup The Forge Workspace And Stuff, goto another modding thing, you need eclispe and stuff
Setting Up The Main Content in the mod
Create a new package the src folder should be : src\minecraft
Name the package whatever you want;
I Created Another Package Called Main , in the first package i created
now created a class Called [your mod] in the package you want
put this code in it:
package [package]; //The package your mod is in
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
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.event.FMLInitializationEvent;
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 [package you mod is it].*;
@NetworkMod(clientSideRequired=true,serverSideRequired=false, //Whether client side and server side are needed
clientPacketHandlerSpec = @SidedPacketHandler(channels = {"NitroMod" }, packetHandler = ClientPacketHandler.class), //For clientside packet handling
serverPacketHandlerSpec = @SidedPacketHandler(channels = {"NitroMod" }, packetHandler = ServerPacketHandler.class)) //For serverside packet handling
@Mod(modid="[modname]",name="[modname]",version="[modversion]")
public class [whatyourclassiscalled] { //The class file
@Instance("[modname]") //The instance, this is very important later on
public static [whatyourclassiscalled] instance = newwhatyourclassiscalled]();
@SidedProxy(clientSide = "[packageyourclassisin].ClientProxy", serverSide = "[packageyourclassisin].CommonProxy")
public static CommonProxy proxy;
@Init
public void InitCobaltCraft(FMLInitializationEvent event){ //Your main initialization method
NetworkRegistry.instance().registerGuiHandler(this, proxy); //Registers the class that deals with GUI data
proxy.registerTiles();
proxy.registerBlocks();
proxy.addNames();
proxy.addRecipes();
}
}
edit all those[]
your will get some errors on eclispe, and that is what where about to fix;
create a new class called CommonProxy:
make it in your main class package;
put this code in :
package [packageyourclassisin];
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;
import [yourpackagethemainclassisin].*;
public class CommonProxy 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 addNames(){ //For adding Item's ingame names
}
public void addRecipes(){ //For adding your Item's recipes
}
}
that is pretty staight , but create another class called ClientProxy in the same folder;
code:
package [yourpackagethatthemainclassisin];
import [themainpackage].*;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxy extends CommonProxy {
public void registerRenderInformation(){
}
}
now another called ServerPacketHandler
in the same folder;
code:
package [mainpackage];
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 ServerPacketHandler implements IPacketHandler{
@Override[/color][/size]
public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data)); //Handles incoming data
EntityPlayer sender = (EntityPlayer) player;
}
}
and finally the ClientPacketHandler
in the same folder
code:
package [mainpackage];
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)[/color][/size]
public class ClientPacketHandler implements IPacketHandler{
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data)); //Handles incoming data
}
}
now the important stuff is in;
Making Your First Basic Item:
now that we have the main classes lets make a first basic item;
i Created a package called Item,
create a class in the package you want then
name it the something like Mutationstone or something
then put this code in:
package [packageitisin];
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
public class [classname] extends Item{
public [classname](int par1)
{
super(par1);
setCreativeTab(CreativeTabs.tabMaterials);//you can get the name of all the tabs by type CreativeTabs.Then it will list;
setUnlocalizedName("[name]");
//textures will be registered automatically in the base folder , \textures\items\*texture*.*text*
}
}
then added this code in the mainclass: under the code: @instance("[modname"])
under the next line add:
public static Item [itemname] = new [classname](ItemID);
then add
import [packagename].[itempackagenameorso].*;
that fixes up the thing so lets
add this to the commonproxy under the addNames() method
if you want to add a recipe do this under the addRecipes() method
the recipe is like this ; "xxx" the character will be represented soon after,it dosen't need to be x
recipe2 is if you want, it is the second line in the crafting table
recipe3 is if you want 2, it is the third line in the crafting table
3
If You Dont Know How To Setup The Forge Workspace And Stuff, goto another modding thing, you need eclispe and stuff
Create a new package the src folder should be : src\minecraft
Name the package whatever you want;
I Created Another Package Called Main , in the first package i created
now created a class Called [your mod] in the package you want
put this code in it:
your will get some errors on eclispe, and that is what where about to fix;
create a new class called CommonProxy:
make it in your main class package;
put this code in :
code:
in the same folder;
code:
and finally the ClientPacketHandler
in the same folder
code:
now that we have the main classes lets make a first basic item;
i Created a package called Item,
create a class in the package you want then
name it the something like Mutationstone or something
then put this code in:
under the next line add:
then add
that fixes up the thing so lets
add this to the commonproxy under the addNames() method
if you want to add a recipe do this under the addRecipes() method
the recipe is like this ; "xxx" the character will be represented soon after,it dosen't need to be x
recipe2 is if you want, it is the second line in the crafting table
recipe3 is if you want 2, it is the third line in the crafting table
// and so on;
with that you have a new item;
when recompiling, run recompiling.bat in the mcp folder, you also need jdk
startclient.bat and you see your mod there