yanksrock1019 Posted December 14, 2014 Share Posted December 14, 2014 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(); } } Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
Draco18s Posted December 14, 2014 Share Posted December 14, 2014 That code, if it ran, would kill the entity that throws any splash potion Quote 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 More sharing options...
yanksrock1019 Posted December 14, 2014 Author Share Posted December 14, 2014 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); } } Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
Draco18s Posted December 14, 2014 Share Posted December 14, 2014 Is it doing what you want? No? Then yes, it's wrong. Start adding system.out () statements to see what is going on. Quote 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 More sharing options...
yanksrock1019 Posted December 14, 2014 Author Share Posted December 14, 2014 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); } } Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 14, 2014 Author Share Posted December 14, 2014 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 Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 14, 2014 Author Share Posted December 14, 2014 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. Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 14, 2014 Author Share Posted December 14, 2014 Also, I found what you described, understand what it does in vanilla, but still don't know what to do in my case Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 15, 2014 Author Share Posted December 15, 2014 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(); } Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 15, 2014 Author Share Posted December 15, 2014 /effect {player} 30 (the Id of my potion) Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 15, 2014 Author Share Posted December 15, 2014 *bump* Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 17, 2014 Author Share Posted December 17, 2014 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 Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 18, 2014 Author Share Posted December 18, 2014 *bump* Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
Purplicious_Cow Posted December 18, 2014 Share Posted December 18, 2014 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.... Quote Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 19, 2014 Author Share Posted December 19, 2014 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; } } Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 23, 2014 Author Share Posted December 23, 2014 I think I may be missing something here, because I see no answer in getSubItems. Please point out what you are talking about Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 24, 2014 Author Share Posted December 24, 2014 So why when I use this.setCreativeTabs it adds all vanilla potions to my tab Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
Draco18s Posted December 24, 2014 Share Posted December 24, 2014 because: ItemPotion#getSubItems adds all possible potions to the list. Quote 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 More sharing options...
knokko Posted December 24, 2014 Share Posted December 24, 2014 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() Quote Link to comment Share on other sites More sharing options...
yanksrock1019 Posted December 26, 2014 Author Share Posted December 26, 2014 You're right, what I really wanted to do was to just make it into a potion Quote Don't tell me to learn the basics of java, I already know. Link to comment Share on other sites More sharing options...
knokko Posted December 26, 2014 Share Posted December 26, 2014 As potioneffect, you can use new PotionEffect(7, 1, 100); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.