Jump to content

[1.7.2] Trying to Insta-Kill Player with potion


yanksrock1019

Recommended Posts

I am trying to make a potion that kills a player/entity instantly. I have some code but it doesn't do anything. Any help?

 

@SubscribeEvent
public void onPotionThrow(LivingUpdateEvent event){
	if (event.entityLiving.isPotionActive(MainClass.instaKill)){

		event.entityLiving.setDead();
}

}

 

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

That code, if it ran, would kill the entity that throws any splash potion

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Is it doing what you want? No? Then yes, it's wrong. Start adding system.out () statements to see what is going on.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Still don't know what to do :/ Does it need to be similar to the affectEntity code in the Potion class

 

public void affectEntity(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase, int par3, double par4)
    {
        int j;

        if ((this.id != heal.id || par2EntityLivingBase.isEntityUndead()) && (this.id != harm.id || !par2EntityLivingBase.isEntityUndead()))
        {
            if (this.id == harm.id && !par2EntityLivingBase.isEntityUndead() || this.id == heal.id && par2EntityLivingBase.isEntityUndead())
            {
                j = (int)(par4 * (double)(6 << par3) + 0.5D);

                if (par1EntityLivingBase == null)
                {
                    par2EntityLivingBase.attackEntityFrom(DamageSource.magic, (float)j);
                }
                else
                {
                    par2EntityLivingBase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(par2EntityLivingBase, par1EntityLivingBase), (float)j);
                }
            }
        }
        else
        {
            j = (int)(par4 * (double)(4 << par3) + 0.5D);
            par2EntityLivingBase.heal((float)j);
        }
    }

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

Don't just copy paste code. You don't need an event handler, your Potion class gives you all the hooks you need:

 

isInstant

- if this returns true your potion does not apply a PotionEffect to the entity, it just acts as a one-off effect (like instant health).

 

affectEntity

- Called to apply the one-off effect if

isInstant

is true

 

isReady

- Called every tick if your potion is active on an entity (

isInstant

must be false). Arguments are

ticksLeft

and

amplifier

. If this method returns true,

performEffect

is called so it can perform the effect this tick.

 

Edit: Oh, and this:

Don't tell me to learn the basics of java, I already know.
cannot be taken seriously at all if you produce a thread like this.

What does this have to do with basic java.  Also, just because I did something wrong, doesn't mean I copy pasted something

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

Not working.  Not sure if it's because I'm applying the effect via command.  If so, how do I create the physical splash potion.  Is it just an Item

 

@Override
public boolean isInstant()
    {
        return true;
    }


public void affectEntity(EntityLivingBase entity1, EntityLivingBase entity2, int par3, double par4){

	entity2.setDead();
}

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

Sorry, here, this is the actual ItemPotion class I made for the splash potion. And what I mean by the creative tab is, I have my own creative tab, and whenever I add this to that creative tab, it adds all potions that actually exist in vanilla, to my tab

package com.puplet.items;

import com.puplet.blocks.PupletBlocks;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPotion;
import net.minecraft.item.ItemStack;

public class InstaPotion extends ItemPotion{

public InstaPotion(){


}

 public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.drink;
    }

 public static boolean isSplash(int par0)
    {
        return true;
    }


}

Don't tell me to learn the basics of java, I already know.

Link to comment
Share on other sites

because: ItemPotion#getSubItems adds all possible potions to the list.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.