Posted July 15, 201411 yr Hey, I started picking up minecraft modding recently and I wanted to get a weapon to apply a potion effect when it hits an entity, I looked around in ItemSword and found "hitEntity" So I tried the following (here is the whole class) public class ItemStoneSpear extends ItemSword{ public ItemStoneSpear(ToolMaterial p_i45356_1_) { super(p_i45356_1_); // TODO Auto-generated constructor stub } @Override public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase){ par1ItemStack.damageItem(1, par3EntityLivingBase); par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.getId(),100 , 1)); return true; } } But it doesn't work no matter what I try. So if someone could help me out i'd love it a ton
July 15, 201411 yr Hey, I started picking up minecraft modding recently and I wanted to get a weapon to apply a potion effect when it hits an entity, I looked around in ItemSword and found "hitEntity" So I tried the following (here is the whole class) public class ItemStoneSpear extends ItemSword{ public ItemStoneSpear(ToolMaterial p_i45356_1_) { super(p_i45356_1_); // TODO Auto-generated constructor stub } @Override public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase){ par1ItemStack.damageItem(1, par3EntityLivingBase); par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.poison.getId(),100 , 1)); return true; } } But it doesn't work no matter what I try. So if someone could help me out i'd love it a ton Didn't know that there is an hitEntity function(would have used an onLivingUpdateEvent). Please put some test output into the hit function and test if it is called when you hit something. Here could be your advertisement!
July 15, 201411 yr Author Didn't know that there is an hitEntity function(would have used an onLivingUpdateEvent). Please put some test output into the hit function and test if it is called when you hit something. Yeah, the hitEntity function doesn't seem to be getting called; how would I go about using onLivingUpdateEvent?
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.