Jump to content

Recommended Posts

Posted

I am currently working on an item that will poison an entity on hit and I'm not sure why everything I have tried has not worked. I am using this code at the moment, but it does not work:

public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) {

par2EntityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 200, 1));

return true;

 

Thanks for Any Help or Suggestions

Posted

From what I remember I don't think (hitEntity) is a valid method in whatever item you are using.

 

Try putting @Override on the method - to ensure that method exists (and works).

 

It is, but the OP got the wrong method signature!

 

@OP: the two EntityLiving parameters should be EntityLivingBase parameters.

hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)

And as coolboy4531 suggested, always add @Override above methods you intend to override to avoid errors.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.