Hey guys working on my first ever mod, wanted to make a food with more than just 1 effect. not alot of info out there on it at all, and i searched pretty hard for it i base that it can be done on vanilla enchanted golden apples.
like everyone else i have seen ask about it, i too tried the:
duplicating again with what ever effect i hoped it would add it always picks the last one and ignores the previous. in this case uses blindness, ignores confusion. again, i can make food with 1 effect just fine, but not add a second effect.
would any of you who have managed a second effect be willing to shed some light on the way you did it, even maybe some "generic" src code we could study n' learn from if your generous:D SOLVED! Thanks to Steakhead! *cheer* Thanks to any who take their time to read!
basically, make a separate class and extend ItemFood. just copy the golden apple class and change the effects/names. The class would look something like this:
package your package;
public class ItemYourFoodHere extends ItemFood
{
public ItemYourFoodHere(int par1, int par2, float par3, boolean par4)
{
super(par1, par2, par3, par4);
}
protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer
{
if (!par2World.isRemote)
{
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
}
}
else
{
super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
}
}
made the class imported files, changed names, no errors on the page, and it all launches fine, but its only taking on the foods hunger, sat etc characteristics. do i need 2 treat the part in the main mod class different?
made the class imported files, changed names, no errors on the page, and it all launches fine, but its only taking on the foods hunger, sat etc characteristics. do i need 2 treat the part in the main mod class different?
SIR YOU ROCK!!!! it worked great! you have no idea how helpful you have been thank you sooo much haha -
that moment you see all three effects *huge smile* XD
SIR YOU ROCK!!!! it worked great! you have no idea how helpful you have been thank you sooo much haha -
that moment you see all three effects *huge smile* XD
you kinda helped me too, thanks i used the info you gave and combined it with a 1.10 food modding tutorial. but i have a question now that i set this up what do i do next, i created the class and what to add the effect to a food item i made
Hey guys working on my first ever mod, wanted to make a food with more than just 1 effect.
not alot of info out there on it at all, and i searched pretty hard for it
i base that it can be done on vanilla enchanted golden apples.
like everyone else i have seen ask about it, i too tried the:
.setPotionEffect(Potion.confusion.id, 60, 0, 1.0f).setPotionEffect(Potion.blindness.id, 30, 0, 0.5f)
duplicating again with what ever effect i hoped it would add
it always picks the last one and ignores the previous. in this case uses blindness, ignores confusion.
again, i can make food with 1 effect just fine, but not add a second effect.
would any of you who have managed a second effect be willing to shed some light on the
way you did it, even maybe some "generic" src code we could study n' learn from if your generous:D
SOLVED! Thanks to Steakhead! *cheer*
Thanks to any who take their time to read!
cheers
did you get it to work?
atm its:
do i need 2 add anythin about potion in here as well?
EDIT: changed to what im trying to do, confusion, hunger, regen
oh, woops. delete the if statment that asks about the item damage and move the potion effects to the outside.
it should look like this:
np
that moment you see all three effects *huge smile* XD
haha i owe you one!
fantastic!
you kinda helped me too, thanks i used the info you gave and combined it with a 1.10 food modding tutorial. but i have a question now that i set this up what do i do next, i created the class and what to add the effect to a food item i made
package mysticMyles.GoodDrinks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class Food extends ItemFood {
public Food(int p_i45340_1_, boolean p_i45340_2_) {
super(p_i45340_1_, p_i45340_2_);
}
public Food(int p_i45339_1_, float p_i45339_2_, boolean p_i45339_3_) {
super(p_i45339_1_, p_i45339_2_, p_i45339_3_);
} public Food(int par1, int par2, float par3, boolean par4)
{
super(par1, par2, par4);
}
protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (!par2World.isRemote)
{
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 600, 0));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
}
else
{
super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
}
}
}