Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello I'm making a 1.7.10 forge mod and I am trying to give the player 3 potion effects. It works with 2 and the code does not seem to have any errors for 3 potion effects, but only 2 show up. Any help would be great  ;D

 

 

Food Item Code:

 

package com.mystic.potatoes;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

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 ItemRainbowPotato extends ItemFood

{

private int secondpotionid;

private int secondpotionDuration;

private int secondpotionAmplifier;

private float secondpotionEffectPropability;

 

private int thirdpotionid;

private int thirdpotionDuration;

private int thirdpotionAmplifier;

private float thirdpotionEffectPropability;

 

    public ItemRainbowPotato(int hunger, float saturation,

boolean wolfFood) {

    super(hunger, saturation, wolfFood);

        setAlwaysEdible();

        setPotionEffect(Potion.moveSpeed.id, 120, 5, 1.0F);

        setSecondPotionEffect(Potion.jump.id, 120, 3, 1.0F);

        setThirdPotionEffect(Potion.damageBoost.id, 120, 3, 1.0F);

}

//second potion effect

    protected void onFoodEaten(ItemStack par1ItemStack, World par2world, EntityPlayer par3EntityPlayer)

    {

    super.onFoodEaten(par1ItemStack, par2world, par3EntityPlayer);

   

    if (!par2world.isRemote && this.secondpotionid > 0 && par2world.rand.nextFloat() < this.secondpotionDuration * 20)

    {

    par3EntityPlayer.addPotionEffect(new PotionEffect (this.secondpotionid, this.secondpotionDuration * 20, this.secondpotionAmplifier));;

    }

    }

    public ItemFood setSecondPotionEffect(int par1, int par2, int par3,float par4)

    {

    this.secondpotionid = par1;

    this.secondpotionDuration = par2;

    this.secondpotionAmplifier = par3;

    this.secondpotionEffectPropability = par4;

    return this;

    }

    public ItemFood setThirdPotionEffect(int par1, int par2, int par3,float par4)

    {

    this.thirdpotionid = par1;

    this.thirdpotionDuration = par2;

    this.thirdpotionAmplifier = par3;

    this.thirdpotionEffectPropability = par4;

    return this;

    }

}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.