Posted October 26, 201212 yr 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.
October 27, 201212 yr 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.