Minecraft Blogs / Tutorial

modding tutorial 4:food

  • 1,002 views, 2 today
  • 4
  • 2
  • 2
waterskier's Avatar waterskier
Level 54 : Grandmaster Pony
158
Hey everyone I have another tutorial for you. In this one I will teach you how to make food. From now on instead of doing something like yourore in the name I will do something like copperore. In this one I will make a cheeseburger. Let's get started.

this should be very easy for you guys we only need 1 class
mod_cheeseburger
first we need to add our getversion and load methods and then it should look like this
mod_cheeseburger 1
package net.minecraft.src;

public class mod_cheeseburger extends BaseMod
{
public void load()
{
}

public String getVersion()
{
return "1.2.5";
}
}

after that we need to put this into the class
public static final Item cheeseburger = new ItemFood(165, 4, 1F, false).setItemName("cheeseburger");
this is saying we have a new item and it's not a normal item it's a food item
then we tell the game about what the food does with 3 integers and a boolean (see bottom)
the first int is the item id
the second is how many chicken legs it heals but if the integer is 2 then it heals 1 chicken leg 4=2 6=3 ect.
the third is the saturation (invisible bar that tells the food bar when to lose a chicken leg)
the boolean is weather or not people can feed it to wolves (obviously false is no and true is yes)
then we need to add the name and add the texture
Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/cheeseburger.png");
ModLoader.addName(cheeseburger, "cheeseburger");

then we are done here is what it should look like
mod_cheeseburger final
package net.minecraft.src;

public class mod_cheeseburger extends BaseMod
{
public static final Item cheeseburger = new ItemFood(165, 4, 1F, false).setItemName("cheeseburger");

public void load()
{
Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/cheeseburger.png");
ModLoader.addName(cheeseburger, "cheeseburger");
}

public String getVersion()
{
return "1.2.5";
}
}

boolean-A binary variable, having two possible values called o trueo and o false.o .

thanks for reading! Leave any error code in the comments along with suggestions for future tutorials,and as always diamond and subscribe!
Tags

Create an account or sign in to comment.

1
06/02/2012 6:49 am
Level 12 : Journeyman Bunny
iCraftedYou
iCraftedYou's Avatar
where is cheeseburger.png located?
1
05/12/2012 4:06 am
Level 8 : Apprentice Miner
TheNewHope
TheNewHope's Avatar
Usefull. Thanks! I had this idea of adding more food as a mod, but never found out how to :3
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome