Minecraft Blogs / Tutorial

Creating stuff with ModLoader||Items

  • 312 views, 2 today
  • 2
  • 0
  • 1
GoldButterKnife's Avatar GoldButterKnife
Level 32 : Artisan Creeper Hugger
28
Start off with a new class called mod_nuggetIron. As that's what I'll be teaching you how to make. In another tutorial I will show how to use these to make an iron block.
Here's the Code that I will be explaining:


mod_nuggetIron.java

package net.minecraft.src;

public class mod_nuggetIron extends BaseMod
{

public static final Item ni = new Item(222).setItemName("ni");

public void load()
{
ni.iconIndex = ModLoader.addOverride("/gui/items.png","/ni.png");
ModLoader.addName(ni,"Iron Nuggets");
ModLoader.addShapelessRecipe(new ItemStack(ni, 9), new Object [] {
"$", Character.valueOf('$'), (Item.ingotIron)});
}
public String getVersion()
{
return "1.2.5";
}
}

Click to reveal
This is telling that it's using ModLoader, and declaring the class name.


- public static final Item ni = new Item(222).setItemName("ni");

"public static final Item ni = new Item(222)" This is letting Java know that the Item "ni" will be using the Item ID, 222.

".setItemName("ni")" Delaring the variable to be used for the item.


- ni.iconIndex = ModLoader.addOverride("/gui/items.png","/ni.png");

"ModLoader.addOverride" Letting ModLoader know that this will be adding an override for the items.png file.

"("/gui/items.png","/ni.png")" "/ni.png" means it will be using the texture called ni located inside the minecraft.jar, you will have to create the texture.


- ModLoader.addName(ni,"Iron Nuggets");

This is giving the Item a name to be displayed ingame.
(variable,"INGAMENAME");


- ModLoader.addShapelessRecipe(new ItemStack(ni, 9), new Object [
{ "$", Character.valueOf('$'), (Item.ingotIron)});]addShapelessRecipe means you will be creating a recipe which has no set shape. Just like making a gold ingot into gold nuggets.


- public String getVersion() { return "1.2.5"; }
This lets Minecraft know what version the mod is made for so it knows if it is capable of running the mod.


Well that's my first tutorial ever... Let me know if I should do one for blocks and food! Feel free to take the code that I used for this. I honestly don't care. But have fun making the texture for it :)
Tags

1 Update Logs

Update #1 : by GoldButterKnife 07/09/2012 8:33:13 pmJul 9th, 2012

Made minor tweaks.

Create an account or sign in to comment.

1
07/09/2012 7:15 pm
Level 6 : Apprentice Explorer
Larvitarian
Larvitarian's Avatar
:D i want a tutorial on how to make blocks; and maybe a mob tutorial if you can, so i can make the add on for Mo' Noms
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome