Sign in to follow this  
Followers 0

Modloader Modding Tutorials[Block][Food][Ore Generation]

5 posts in this topic

Posted · Report post

Modding tutorials for Minecraft 1.0.0

I am Sackorice from TTG

Requirements:

[hide]Java Development Kit (JDK) - http://www.oracle.co...oads/index.html

Java Runtime Environments (JRE) - http://www.oracle.co...oads/index.html

Eclipse (not required but helps so much) - http://www.eclipse.org/downloads/ [choose the first link]

Minecraft Coder Pack (MCP) - http://mcp.ocean-lab...hp/MCP_Releases[/hide]

---------------------------------

I uploaded a Presetup MCP folder for 1.0.0 all you need to do is Unzip and run Decompile http://www.mediafire...bq089tpfysagq3z

What each color means

green = a piece of code (in help sections)

brown = Help: filename

blue = a modding tutorial

Fixing ModLoader Errors

just put that in your mod_Namehere

public String getVersion()   {	 // TODO Auto-generated method stub	 return null;   }   public void load()   {	 // TODO Auto-generated method stub   }

Creating Your First Block

BlockNamehere.java

package net.minecraft.src;import java.util.Random;public class BlockNamehere extends Block{	public BlockNamehere(int i, int j)	{		super(i, j, Material.ground);		  	}	public int idDropped(int i, Random random)	{	   return mod_Namehere.Namehere.blockID;	}	public int quantityDropped(Random random)	{			return 3;	}}
mod_Namehere.java

package net.minecraft.src;public class mod_Namehere extends BaseMod{   public static Block Namehere;   public String Version()   {	  return "1.0.0";   }   public mod_Namehere()   {	  ModLoader.RegisterBlock(Namehere);	  Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Blocks/Namehere.png");	  ModLoader.AddName(Namehere, "Namehere");	  ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {"###", "###", "###", Character.valueOf('#'), Item.seeds});   }   static   {		   new BlockNamehere(210, 0).setHardness(1.0F).setResistance(1.0F).setLightValue(1.0F).setBlockName("1");   }}
HELP: BlockNamehere.java

At return mod_Namehere.Namehere.blockID;

This is what the block drops, Change mod_Namehere.Namehere not the .blockID

examples

return Block.grass.blockID;

return Item.clay.shiftedIndex;

HELP: mod_Namehere

At new BlockNamehere(190,

change 190, that is the block ID be careful not to use the same ID again

At .setHardness(1.0F)

change the 1.0, dirt is 0.5; stone is 1.5; 10 is unbreakable

At .setResistance(2500.0F)

this is how resistant the block is to Explosives

change the 2500.0, obsidian is 2000.0F all other blocks are 5.0F

At .setLightValue(1.0F)

this is how bright your block is

1.0F is as high as it goes, Torches are 0.9375F and redstone is 0.5F

At ModLoader.AddName(Namehere, "Nameingamehere");

this is the ingame name, so change Namehere to the block name (in mod_Namehere) and change Nameingamehere to whatever you want it to say ingame

At Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Namehere.png");

this is the texture, change the Namehere.blockIndexInTexture and in the () change "/Namehere.png" ex. "/Mod/Fireblock.png" the /Mod/ is a folder and the Fireblock.png is the image file

Creating your First Item

Again use the template to your advantage

ItemNamehere.java

package net.minecraft.src;import java.util.Random;public class ItemNamehere extends Item{		public ItemNamehere (int i)		{				super(i);				maxStackSize = 64;		}}
mod_Namehere.java

package net.minecraft.src;public class mod_Namehere extends BaseMod{   public static Item Namehere;   public String Version()   {	  return "1.0.0";   }   public mod_Namehere()   {	  Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/Namehere.png");	  ModLoader.AddName(Namehere, "Namehere");	  ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {"###", "###", "###", Character.valueOf('#'), Item.seeds});   }   static   {		   new Item(1000).setItemName("1");   }}
HELP: mod_Namehere.java

At setItemName

this is the coding name not the ingame name

Creating a Food

This is the same as the item tutorial with some small tweaks

mod_Namehere

package net.minecraft.src;public class mod_Namehere extends BaseMod{   public static Item Namehere;   public String Version()   {	  return "1.0.0";   }   public mod_Namehere()   {	  Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/Namehere.png");	  ModLoader.AddName(Namehere, "Namehere");   }   static   {		   new ItemFood(1000, 10, true).setItemName("1");   }}
HELP:

At new ItemFood(28000, 4, 1F,

1F stands for half a heart so 5F is 2.5 hearts

An Item That Spawns a Mob!

ItemNamehere

package net.minecraft.src;import java.util.*;public class ItemNamehere extends Item{	private World worldObj;		public ItemNamehere (int i)		{				super(i);				maxStackSize = 1;		}		public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)	{		if(!world.multiplayerWorld)		{					ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a pig!");			EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Pig", entityplayer.worldObj);						entityliving.setLocationAndAngles(i, j + 1, k, 0F, 0F);			entityplayer.worldObj.entityJoinedWorld(entityliving);						entityplayer.swingItem();		}		return true;	}}
mod_Namehere

package net.minecraft.src;public class mod_Namehere extends BaseMod{   public static Item Namehere;   public String Version()   {	  return "1.0.0";   }   public mod_Namehere()   {	  Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Items/Namehere.png");	  ModLoader.AddName(Namehere, "Namehere");	  ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {"###", "###", "###", Character.valueOf('#'), Item.seeds});   }   static   {		   new Item(1000).setItemName("1");   }}
NOTE** The mod_Namehere isn't different then the Item tutorial only the ItemNamehere.java file is being altered

HELP: ItemNamehere.java

At ModLoader.getMinecraftInstance().thePlayer.addChatMessage("A pig has Spawned!")

this is the function that makes a message pop up on the screen

Making the Block more Advanced!

This tutorial edits the BlockNamehere.java file

slipperiness = 1.5F;
it would go under
super(i, j, Material.ground);
Makes you run faster as long as your on that specific block, great for long distance travel

A Bouncy Block

public void onEntityWalking(World world, int x, int y, int z, Entity entity)	{			entity.motionY += 2.0;	}
goes here

public int idDropped(int i, Random random)	{	   return mod_Namehere.Namehere.blockID;	}		public void onEntityWalking(World world, int x, int y, int z, Entity entity)	{			entity.motionY += 2.0;	}	public int quantityDropped(Random random)	{			return 1;	}}

Creating Armor

mod_Namehere

package net.minecraft.src;import net.minecraft.client.Minecraft;public class mod_Namehere extends BaseMod{	public mod_Namehere()	{		NamehereHelmet.iconIndex = ModLoader.addOverride("/gui/items.png", "/Armor/Nameherehelmet.png");		NamehereBody.iconIndex = ModLoader.addOverride("/gui/items.png", "/Armor/Nameherebody.png");		NamehereLegs.iconIndex = ModLoader.addOverride("/gui/items.png", "/Armor/Nameherelegs.png");		NamehereBoots.iconIndex = ModLoader.addOverride("/gui/items.png", "/Armor/Namehereboots.png");		ModLoader.AddName(NamehereHelmet, "Namehere Helmet");		ModLoader.AddName(NamehereBody, "Namehere Chestplate");		ModLoader.AddName(NamehereLegs, "Namehere Leggings");		ModLoader.AddName(NamehereBoots, "Namehere Boots");		ModLoader.AddRecipe(new ItemStack(NamehereHelmet, 1), new Object[] {"sss", "s s", "   ", Character.valueOf('s'), Item.seeds});		ModLoader.AddRecipe(new ItemStack(NamehereBody, 1), new Object[] {"s s", "sss", "sss", Character.valueOf('s'), Item.seeds});		ModLoader.AddRecipe(new ItemStack(NamehereLegs, 1), new Object[] {"sss", "s s", "s s", Character.valueOf('s'), Item.seeds});		ModLoader.AddRecipe(new ItemStack(NamehereBoots, 1), new Object[] {"   ", "s s", "s s", Character.valueOf('s'), Item.seeds});	}	static	{		new ItemArmor(1000, 3, ModLoader.AddArmor("NamehereArmor"), 0).setItemName("1");		new ItemArmor(1001, 3, ModLoader.AddArmor("NamehereArmor"), 1).setItemName("2");		new ItemArmor(1002, 3, ModLoader.AddArmor("NamehereArmor"), 2).setItemName("3");		new ItemArmor(1003, 3, ModLoader.AddArmor("NamehereArmor"), 3).setItemName("4");	}	public String Version()	{		return "1.0.0";	}	public static Item NamehereHelmet;	public static Item NamehereBody;	public static Item NamehereLegs;	public static Item NamehereBoots;}
HELP:

At ("NamehereArmor"), 0))

the 0 is the type of armor

types 0-Helmet 1-Body 2-Legs 3-Boots

Adding Armor effects

put

ModLoader.SetInGameHook(this, true, false);
under all your recipes

add

public boolean OnTickInGame(Minecraft minecraft)	{		ItemStack boots = minecraft.thePlayer.inventory.armorInventory[0];		ItemStack legs = minecraft.thePlayer.inventory.armorInventory[1];		ItemStack chest = minecraft.thePlayer.inventory.armorInventory[2];		ItemStack helm = minecraft.thePlayer.inventory.armorInventory[3];		if(boots == null || legs == null || chest == null || helm == null)		{			return true;		}		if(boots.itemID == NamehereBoots.shiftedIndex && legs.itemID == NamehereLegs.shiftedIndex && chest.itemID == NamehereBody.shiftedIndex && helm.itemID == NamehereHelmet.shiftedIndex)		{		   minecraft.thePlayer.air = minecraft.thePlayer.maxAir;		}				return true;	}
into

ModLoader.AddRecipe(new ItemStack(NamehereBoots, 1), new Object[] {			"   ", "r r", "r r", Character.valueOf('r'), Item.redstone		});				ModLoader.SetInGameHook(this, true, false);	}		public boolean OnTickInGame(Minecraft minecraft)	{		ItemStack boots = minecraft.thePlayer.inventory.armorInventory[0];		ItemStack legs = minecraft.thePlayer.inventory.armorInventory[1];		ItemStack chest = minecraft.thePlayer.inventory.armorInventory[2];		ItemStack helm = minecraft.thePlayer.inventory.armorInventory[3];		if(boots == null || legs == null || chest == null || helm == null)		{			return true;		}		if(boots.itemID == NamehereBoots.shiftedIndex && legs.itemID == NamehereLegs.shiftedIndex && chest.itemID == NamehereBody.shiftedIndex && helm.itemID == NamehereHelmet.shiftedIndex)		{		   minecraft.thePlayer.air = minecraft.thePlayer.maxAir;		}				return true;	}
at the bottom where it says minecraft.thePlayer.air = minecraft.thePlayer.maxAir;

you can change it to minecraft.thePlayer.isImmuneToFire = true;

Sugar-Cane Like block

This tutorial is more difficult and i'm not the best with these kinds of mods I might not be able to help as much

mod_Namehere

package net.minecraft.src;import java.util.Random;public class mod_Namehere extends BaseMod{	public mod_Namehere()	{		ModLoader.RegisterBlock(Namehere);		ModLoader.AddName(Namehere, "Namehere");		ModLoader.AddRecipe(new ItemStack(Item.redstone, 3), new Object[] {			"#", Character.valueOf('#'), Namehere		});	}	public void GenerateSurface(World world, Random random, int i, int j)	{		if(random.nextInt(20) == 0)		{			for(int k = 0; k < 16; k++)			{				for(int l = 0; l < 16; l++)				{					int i1 = random.nextInt(200);					if(world.getBlockId(i + l, i1, j + k) != Block.grass.blockID || !world.isAirBlock(i + l, i1 + 1, j + k))					{						continue;					}					int j1 = random.nextInt(2);					if(j1 == 0)					{						world.setBlock(i + l, i1 + 1, j + k, Namehere.blockID);					}					if(j1 == 1)					{						world.setBlock(i + l, i1 + 1, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 2, j + k, Namehere.blockID);					}					if(j1 == 2)					{						world.setBlock(i + l, i1 + 1, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 2, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 3, j + k, Namehere.blockID);					}										if(j1 == 3)					{						world.setBlock(i + l, i1 + 1, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 2, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 3, j + k, Namehere.blockID);												world.setBlock(i + l, i1 + 4, j + k, Namehere.blockID);					}				}			}		}	}	public String Version()	{		return "1.7.3";	}	public static Block Namehere = (new BlockNamehere(124, ModLoader.addOverride("/terrain.png", "/Namehere.png"))).setHardness(0.0F).setResistance(0.0F).setBlockName("Namehere");}
BlockNamehere

package net.minecraft.src;import java.util.Random;public class BlockNamehere extends Block{	protected BlockNamehere(int i, int j)	{		super(i, Material.plants);		blockIndexInTexture = j;		float f = 0.375F;		setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);		setTickOnLoad(true);	}	public void updateTick(World world, int i, int j, int k, Random random)	{		if(world.isAirBlock(i, j + 1, k))		{			int l;			for(l = 1; world.getBlockId(i, j - l, k) == blockID; l++) { }			if(l < 3)			{				int i1 = world.getBlockMetadata(i, j, k);				if(i1 == 15)				{					world.setBlockWithNotify(i, j + 1, k, blockID);					world.setBlockMetadataWithNotify(i, j, k, 0);				} else				{					world.setBlockMetadataWithNotify(i, j, k, i1 + 1);				}			}		}	}	public boolean canPlaceBlockAt(World world, int i, int j, int k)	{		int l = world.getBlockId(i, j - 1, k);		if(l == blockID)		{			return true;		}		return l == Block.grass.blockID || l == Block.dirt.blockID;	}	public void onNeighborBlockChange(World world, int i, int j, int k, int l)	{		checkBlockCoordValid(world, i, j, k);	}	protected final void checkBlockCoordValid(World world, int i, int j, int k)	{		if(!canBlockStay(world, i, j, k))		{			dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k));			world.setBlockWithNotify(i, j, k, 0);		}	}	public boolean canBlockStay(World world, int i, int j, int k)	{		return canPlaceBlockAt(world, i, j, k);	}	public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)	{		return null;	}	public int idDropped(int i, Random random)	{		return mod_Namehere.Namehere.blockID;	}	public boolean isOpaqueCube()	{		return false;	}	public boolean renderAsNormalBlock()	{		return false;	}	public int getRenderType()	{		return 1;	}}
Help: mod_Namehere

At

if(j1 == 1)					{						world.setBlock(i + l, i1 + 1, j + k, Namehere.blockID);						world.setBlock(i + l, i1 + 2, j + k, Namehere.blockID);					}
if you want it to grow more then add extra lines and just +1 more

like this

world.setBlock(i + l, i1 + 3, j + k, Namehere.blockID);world.setBlock(i + l, i1 + 4, j + k, Namehere.blockID);
Help: BlockNamehere

At

public boolean canPlaceBlockAt(World world, int i, int j, int k)	{		int l = world.getBlockId(i, j - 1, k);		if(l == blockID)		{			return true;		}		return l == Block.grass.blockID || l == Block.dirt.blockID;
you can change or add more blocks that it can spawn on

Making Tools!

mod_Namehere

package net.minecraft.src;import net.minecraft.client.Minecraft;public class mod_Namehere extends BaseMod{	public mod_Namehere()	{		NameherePickaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Tools/Nameherepick.png");		NamehereShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/Tools/Nameherespade.png");		NamehereAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Tools/Namehereaxe.png");		NamehereHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Tools/Nameherehoe.png");		NamehereSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/Tools/Nameheresword.png");		ModLoader.AddName(NameherePickaxe, "Namehere Pickaxe");		ModLoader.AddName(NamehereShovel, "Namehere Shovel");		ModLoader.AddName(NamehereAxe, "Namehere Axe");		ModLoader.AddName(NamehereHoe, "Namehere Hoe");		ModLoader.AddName(NamehereSword, "Namehere Sword");		ModLoader.AddRecipe(new ItemStack(NameherePickaxe, 1), new Object[] {"sss", " | ", " | ", Character.valueOf('s'), Item.seeds, Character.valueOf('|'), Item.stick});		ModLoader.AddRecipe(new ItemStack(NamehereShovel, 1), new Object[] {" s ", " | ", " | ", Character.valueOf('s'), Item.seeds, Character.valueOf('|'), Item.stick});		ModLoader.AddRecipe(new ItemStack(NamehereAxe, 1), new Object[] {"ss ", "s| ", " | ", Character.valueOf('s'), Item.seeds, Character.valueOf('|'), Item.stick});		ModLoader.AddRecipe(new ItemStack(NamehereHoe, 1), new Object[] {"ss ", " | ", " | ", Character.valueOf('s'), Item.seeds, Character.valueOf('|'), Item.stick});		ModLoader.AddRecipe(new ItemStack(NamehereSword, 1), new Object[] {" s ", " s ", " | ", Character.valueOf('s'), Item.seeds, Character.valueOf('|'), Item.stick});		}	static	{		new ItemPickaxe(1000, EnumToolMaterial.EMERALD).setItemName("1");		new ItemSpade(1001, EnumToolMaterial.EMERALD).setItemName("2");		new ItemAxe(1002, EnumToolMaterial.EMERALD).setItemName("3");		new ItemHoe(1003, EnumToolMaterial.EMERALD).setItemName("4");		new ItemSword(1004, EnumToolMaterial.EMERALD).setItemName("5");	}	public String Version()	{		return "1.0.0";	}	public static Item NameherePickaxe;	public static Item NamehereShovel;	public static Item NamehereAxe;	public static Item NamehereHoe;	public static Item NamehereSword;}
This is just like making an item except you dont need to make ItemNamehere.java files!

now for the only difficult part. find EnumToolMaterial.java file and open it up

at the top where it says

WOOD("WOOD", 0, 0, 59, 2.0F, 0, 15),

STONE("STONE", 1, 1, 131, 4F, 1, 5),

IRON("IRON", 2, 2, 250, 6F, 2, 14),

EMERALD("EMERALD", 3, 3, 1561, 8F, 3, 10),

GOLD("GOLD", 4, 0, 32, 12F, 0, 22);

delete the ; after the Gold line and put a comma there

for a new material

Namehere("NAMEHERE", 5, #, ##, #F, #, ###);

# = 0 means it can only mine stone/coal, 1 means iron, 2 means gold/diamond/redstone/lupis, 3 means obsidian

## = how many uses

#F = How strong it is against ores

### = not sure XD put the same number as emerald (aka diamond)

Making a Sword Catch Mobs on Fire!

Add

public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1)	{		entityliving.fire=300;		  return false;	}
to you ItemNamehere.java file

Making an Ore Generate

mod_Namehere

public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)	{		for(int i = 0; i < Rarity; i++)		{			int randPosX = chunkX + rand.nextInt(16);			int randPosY = rand.nextInt(Height);			int randPosZ = chunkZ + rand.nextInt(16);			(new WorldGenMinable(mod_Namehere.Namehere.blockID, Vein Size)).generate(world, rand, randPosX, randPosY, randPosZ);		}	}
goes in after

public String Version(){return "1.0.0";}

How to give foods a potion effect

Applying a potion effect to a food. This is very easy to do. You simply make a food(follow the tutorial above), and add this bit of code to it

.setPotionEffect(Potion.hunger.id, 30, 0, 0.8F)
so it would fit in like this:

public static final Item Namehere = new ItemFood(5001, 4, 1F, false).setPotionEffect(Potion.hunger.id, 30, 0, 1F).setItemName("anynamehere");
Note that .setPotionEffect MUST go before .setItemName otherwise you will get recompilation errors. I use the hunger potion in this example, which is what is used in rotten flesh. You can use any potion effect when doing this. They are all listed in Potion.java. I'm not sure what the 0 means, but the 30 is the time the effect lasts for. An int of 20 here lasts for 6 seconds, so 30 is about 9 seconds. The float(1F) is the chance of the potion being successful. Rotten flesh has 0.8F here, and it has an 80% chance of giving you food poisoning. Having 1F in this position should be a 100% success rate.

How to edit Start Menu

Do you want to make your Minecraft Menu look like this?

Posted Image

1. Open Minecraft.jar and open the lang folder and open en_US.lang

gui.done=Donegui.cancel=Cancelgui.toMenu=Back to title screengui.up=Upgui.down=Downgui.yes=Yesgui.no=Nomenu.singleplayer=Singleplayermenu.multiplayer=Multiplayermenu.mods=Texture Packsmenu.options=Options...menu.quit=Quit
Now you can edit the text after the .

and for the text color http://minecraftonli...ki/Colour_Codes

use

4 for Red

c for Rose

6 for Gold

e for Yellow

2 for Green

a for Lightgreen

b for Lightblue

3 for Cyan

1 for Navy

9 for Blue

d for Lightpurple

5 for Purple

f for White

7 for Lightgray

8 for Gray

0 for Black

chen1126 likes this

Share this post


Link to post
Share on other sites

Posted · Report post

ohhh nice :Dyou changed the quit button to "rage quit" by your self? haven't played minecraft a while :)

Share this post


Link to post
Share on other sites

Posted · Report post

ohhh nice :biggrin: you changed the quit button to "rage quit" by your self? haven't played minecraft a while :)

ha yeah me and my friend were joking around and he always rage quits so I put it as that

Share this post


Link to post
Share on other sites

Posted · Report post

ty

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0