Hey guys, some of you may (probably not) but I have a mod called Mo' Food, and I'm trying to update it and I can't seem to find a line of code so that my food doesn't just heal the health. You know, the food bar, can someone help? (I probably sound like a n00b lol) Thanks guys,
I'm just going to copy and paste a tutorial I made regarding the subject. Keep in mind you don't need any extra java files when using this, all you need is your mod_NameHere.java file. Also this is for ModLoader which I hope your using.
Tutorial for ModLoder
So I had a hard time finding one so I decided to create a tutorial on creating a new food item for 1.8.1.
Create a new file called mod_Food.java with this code:
package net.minecraft.src
public class mod_Food extends BaseMod
{
public mod_Food()
{
}
public String Version()
{
return "Food Mod for 1.8.1";
}
}
Now we need to first create the food, we do so by adding the following line within the mod_Food class:
public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");
The 601 is the ID for the new food item.
The 6 is how many "hunger bar slots" it will fill. 1 would be half of a "hunger bar slot", 2 would be a whole "hunger bar slot". The maximum number is 20 (or 10 "hunger bar slots"). Just for reference:
1 = ½ "hunger bar slot"
2 = 1 "hunger bar slot"
3 = 1 ½ "hunger bar slots"
4 = 2 "hunger bar slots"
etc.
The false represents whether or not a Wolf can eat it to heal. Put true if you want Wolfs to be able to heal with the new food item.
Now we need to set the food items texture and name, place the following code within the mod_Food constructor:
Now your mod_Food.java file should look just like the one below:
public class mod_Food extends BaseMod
{
public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");
public mod_Food()
{
DirtPie.iconIndex = ModLoader.addOverride("/gui/items.png", "/Food/DirtPie.png");
ModLoader.AddName(DirtPie, "Dirt Pie");
ModLoader.AddRecipe(new ItemStack(DirtPie, 1), new Object[]
{ "###", "###", "###", Character.valueOf('#'), Block.dirt});
}
public String Version()
{
return "Food Mod for 1.8.1";
}
}
Congrats, we just created a new food item that restores 3 "hunger bar slots" upon eating.
Just as a reference, when I say "hunger bar slots" I mean these:
Hopefully I helped and if your having any problems I'll do my best to help.
I'm just going to copy and paste a tutorial I made regarding the subject. Keep in mind you don't need any extra java files when using this, all you need is your mod_NameHere.java file. Also this is for ModLoader which I hope your using.
Tutorial for ModLoder
So I had a hard time finding one so I decided to create a tutorial on creating a new food item for 1.8.1.
Create a new file called mod_Food.java with this code:
package net.minecraft.src
public class mod_Food extends BaseMod
{
public mod_Food()
{
}
public String Version()
{
return "Food Mod for 1.8.1";
}
}
Now we need to first create the food, we do so by adding the following line within the mod_Food class:
public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");
The 601 is the ID for the new food item.
The 6 is how many "hunger bar slots" it will fill. 1 would be half of a "hunger bar slot", 2 would be a whole "hunger bar slot". The maximum number is 20 (or 10 "hunger bar slots"). Just for reference:
1 = ½ "hunger bar slot"
2 = 1 "hunger bar slot"
3 = 1 ½ "hunger bar slots"
4 = 2 "hunger bar slots"
etc.
The false represents whether or not a Wolf can eat it to heal. Put true if you want Wolfs to be able to heal with the new food item.
Now we need to set the food items texture and name, place the following code within the mod_Food constructor:
Now your mod_Food.java file should look just like the one below:
public class mod_Food extends BaseMod
{
public static final Item DirtPie = new ItemFood(601, 6, false).setItemName("DirtPie");
public mod_Food()
{
DirtPie.iconIndex = ModLoader.addOverride("/gui/items.png", "/Food/DirtPie.png");
ModLoader.AddName(DirtPie, "Dirt Pie");
ModLoader.AddRecipe(new ItemStack(DirtPie, 1), new Object[]
{ "###", "###", "###", Character.valueOf('#'), Block.dirt});
}
public String Version()
{
return "Food Mod for 1.8.1";
}
}
Congrats, we just created a new food item that restores 3 "hunger bar slots" upon eating.
Just as a reference, when I say "hunger bar slots" I mean these:
Hopefully I helped and if your having any problems I'll do my best to help.
Thanks man, :biggrin.gif: I just have one question, I don't believe i saw it in their but will the animation follow or is this a whole new line in itself?
Thanks man, :biggrin.gif: I just have one question, I don't believe i saw it in their but will the animation follow or is this a whole new line in itself?
Yes the animation will be apart of the food, your pretty much making a copy of ItemFood so everything that file does this file will do.
Just remember when testing you have to have a depleted health bar in order to eat food, when I first made one I didn't get why I couldn't eat the food then I realized I needed to lose some of the health bar before being able to eat.
J05H
Tutorial for ModLoder
So I had a hard time finding one so I decided to create a tutorial on creating a new food item for 1.8.1.
Create a new file called mod_Food.java with this code:
Now we need to first create the food, we do so by adding the following line within the mod_Food class:
The 601 is the ID for the new food item.
The 6 is how many "hunger bar slots" it will fill. 1 would be half of a "hunger bar slot", 2 would be a whole "hunger bar slot". The maximum number is 20 (or 10 "hunger bar slots"). Just for reference:
1 = ½ "hunger bar slot"
2 = 1 "hunger bar slot"
3 = 1 ½ "hunger bar slots"
4 = 2 "hunger bar slots"
etc.
The false represents whether or not a Wolf can eat it to heal. Put true if you want Wolfs to be able to heal with the new food item.
Now we need to set the food items texture and name, place the following code within the mod_Food constructor:
All this does is set the DirtPie's icon to "/Food/DirtPie.png" and then assigns the in-game name "Dirt Pie" to the new food item.
Last, we'll make a quick recipe so we can craft the new food item.
Add the following code within the mod_Food constructor:
Now your mod_Food.java file should look just like the one below:
Congrats, we just created a new food item that restores 3 "hunger bar slots" upon eating.
Just as a reference, when I say "hunger bar slots" I mean these:
Hopefully I helped and if your having any problems I'll do my best to help.
Thanks man, :biggrin.gif: I just have one question, I don't believe i saw it in their but will the animation follow or is this a whole new line in itself?
Yes the animation will be apart of the food, your pretty much making a copy of ItemFood so everything that file does this file will do.
Just remember when testing you have to have a depleted health bar in order to eat food, when I first made one I didn't get why I couldn't eat the food then I realized I needed to lose some of the health bar before being able to eat.