Posted December 14, 201410 yr 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.
December 14, 201410 yr 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.
December 14, 201410 yr Author I assume this is wrong too? @SubscribeEvent public void onEffect(LivingUpdateEvent event){ if (event.entityLiving.isPotionActive(PupletItems.potionInstaKill)){ event.entityLiving.attackEntityFrom(DamageSource.magic, 1.0F); } } Don't tell me to learn the basics of java, I already know.
December 14, 201410 yr 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.
December 14, 201410 yr Author 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.
December 14, 201410 yr Author 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.
December 14, 201410 yr Author Well yes it was copy in paste, but if you read the question, I was asking if I should use something similar to that code. Don't tell me to learn the basics of java, I already know.
December 14, 201410 yr Author Also, I found what you described, understand what it does in vanilla, but still don't know what to do in my case Don't tell me to learn the basics of java, I already know.
December 15, 201410 yr Author 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.
December 15, 201410 yr Author /effect {player} 30 (the Id of my potion) Don't tell me to learn the basics of java, I already know.
December 17, 201410 yr Author I'm also having a hard time creating the actual potion item itself. When I try to set its creative tab, it adds all the potions to my creative tab Don't tell me to learn the basics of java, I already know.
December 18, 201410 yr Share the code you are having problems with. You seem to have two issues? 1) creating the actual potion item itself (are you having problems with the Potion class?) 2) something to do with 'adds all the potions to my creative tab'. Not sure what that means....
December 19, 201410 yr Author 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.
December 23, 201410 yr Author I think I may be missing something here, because I see no answer in getSubItems. Please point out what you are talking about Don't tell me to learn the basics of java, I already know.
December 24, 201410 yr Author So why when I use this.setCreativeTabs it adds all vanilla potions to my tab Don't tell me to learn the basics of java, I already know.
December 24, 201410 yr 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.
December 24, 201410 yr Why are you making a custom potion effect? You can just use /effect player 7 1 100 to give somebody a good strike. Or in code : entity.setDead()
December 26, 201410 yr Author You're right, what I really wanted to do was to just make it into a potion Don't tell me to learn the basics of java, I already know.
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.