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

Hey, I've recently been attempting to mod minecraft. I added this "Item" that I want to give you 2 potion effects. Currently, I have it adding ".setPotionEffect(Potion.jump.id, 60, 100, 1F)", I would also like it to add ".setPotionEffect(Potion.moveSpeed.id, 60, 100, 1F)". I would like to know if anyone can help me with this. PM me or respond.

  • Author

I figured it out after some experimentation. First, I copied ItemFood, and edited my own copy of it: First, I took this:

    
private int potionId;
private int potionDuration;
private int potionAmplifier;
private float potionEffectProbability;

and turned it into this, as I wanted 3 effects:

private int potionId;
private int potionId2;
private int potionId3;
private int potionDuration;
private int potionDuration2;
private int potionDuration3;
private int potionAmplifier;
private int potionAmplifier2;
private int potionAmplifier3;
private float potionEffectProbability;
private float potionEffectProbability2;
private float potionEffectProbability3;

Then, I took

public NewPotion setPotionEffect(int par1, int par2, int par3, float par4)
    {
        this.potionId = par1;
        this.potionDuration = par2;
        this.potionAmplifier = par3;
        this.potionEffectProbability = par4;
        return this;
    }

and copied/pasted it right under the old one, then edited the new one, note that I changed the name from setPotionEffect to setPotionEffect2, and it uses the new vars, to look like this.

    public NewPotion setPotionEffect2(int par1, int par2, int par3, float par4)
    {
        this.potionId2 = par1;
        this.potionDuration2 = par2;
        this.potionAmplifier2 = par3;
        this.potionEffectProbability2 = par4;
        return this;
    }

Then, I Finally took the code that puts the effects on you, and made it put on the new Effects as well.

The original code looks like this:

    protected void func_77849_c(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability)
        {
            par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
        }
    }

After editing, It should look like this:

    protected void func_77849_c(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability)
        {
            par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier));
            par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId2, this.potionDuration2 * 20, this.potionAmplifier2));
        }
    }

Now, instead of just using:

.setPotionEffect(Potion.jump.id, 60, 2, 1F)

You can now use

.setPotionEffect2(Potion.moveSpeed.id, 60, 2, 1F)

And you want to use this code to get your sprites.

    public String getTextureFile()
    {
    	return "/sprites/yoursprites.png";
    }

Remember to use this code to add your new potions/food with multiple effects in-game:

TriplePotion = new NewPotion

And put all the things that you would normally put there.

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.