Jump to content

[1.7.10] Activation of secondary effect after one potion is active.


Lord_Voldemort7

Recommended Posts

Hello

 

I am setting up a mod and I would like to have multiple vanilla effects be triggered when my custom potion activates. So far, I get no errors, it just doesn't work. My goal for this test is to take damage as I would with poison for the length that Anthrax is active. I take no damage but Anthrax is active. Eventually I'll add more than one at once, but for now I'd like to get one working to see what I did wrong.

 

EDIT: I forgot to mention that I use MC version 1.7.10 and Forge version 1.7.10-10.13.0.1180

 

Here is my EventHooks class:

 

 

 

package epidemiccraft.c;

 

 

 

import net.minecraft.entity.EntityLivingBase;

 

import net.minecraft.potion.Potion;

 

import net.minecraft.potion.PotionEffect;

 

import net.minecraft.util.DamageSource;

 

import net.minecraftforge.event.entity.living.LivingAttackEvent;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

 

 

 

public class EpidemicCraftEventHooks {

 

 

 

public class DiseaseHooks

 

{

 

@SubscribeEvent

 

public void onEntityAttack(LivingAttackEvent event)

 

{

 

if (event.source.getSourceOfDamage() != null)

 

{

 

if(event.source.getSourceOfDamage() instanceof EntityLivingBase)

 

{

 

EntityLivingBase attacker = (EntityLivingBase)event.source.getSourceOfDamage();

 

if(attacker.isPotionActive(EpidemicCraft.potionAnthraxEffect.id))

 

{

 

//empty until further notice

 

}

 

if(attacker.isPotionActive(EpidemicCraft.potionBubPlagueEffect.id))

 

{

 

//Add info here later

 

}

 

}

 

}

 

}

 

}

 

}

 

 

 

 

And here is my Anthrax Potion Class:

 

 

package epidemiccraft.c;

 

 

 

import epidemiccraft.items.ModItems;

 

import net.minecraft.client.Minecraft;

 

import net.minecraft.client.renderer.texture.ITextureObject;

 

import net.minecraft.entity.EntityLivingBase;

 

import net.minecraft.item.ItemStack;

 

import net.minecraft.potion.Potion;

 

import net.minecraft.potion.PotionEffect;

 

import net.minecraft.util.ResourceLocation;

 

 

 

public class PotionAnthraxEffect extends Potion {

 

 

 

public PotionAnthraxEffect(int par1, boolean par2, int par3){

 

 

 

super(par1, par2, par3);

 

}

 

 

 

@Override

 

public boolean isBadEffect()

 

{

 

return true;

 

}

 

 

 

public Potion setIconIndex(int par1, int par2)

 

{

 

super.setIconIndex(par1,par2);

 

return (Potion)this;

 

}

 

 

 

@Override

 

public int getStatusIconIndex()

 

{

 

ResourceLocation r = new ResourceLocation("epidemiccraft","textures/gui/inventory.png");

 

 

 

ITextureObject texture = Minecraft.getMinecraft().renderEngine.getTexture®;

 

Minecraft.getMinecraft().renderEngine.bindTexture®;

 

 

 

return super.getStatusIconIndex();

 

}

 

 

 

public void performEffect(EntityLivingBase attacker, int strength){

 

 

 

super.performEffect(attacker, strength);

 

 

 

attacker.addPotionEffect(newPotionEffect(Potion.poison.id,attacker.getActivePotionEffect(EpidemicCraft.potionAnthraxEffect).getDuration(),

1));

 

 

 

}

 

 

 

}

 

 

 

If you need anything else from me, just ask. I just joined the forums, so if I did not do something right, please correct me so I don't make the same mistake again.

 

Thanks in advance, Lord_Voldemort7

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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