Jump to content

[1.7.10] Force a mob to drop its drops


Silly511

Recommended Posts

I am making a sword that will kill anything, but I've run into a problem. I am using

EntityLivingBase#setHealth()

to set the mob's health to zero. However when I use

setHealth()

zero the mob does not drop any drops. I am guessing that this is because

setHealth()

bypasses all hurt and death events. But the reason I'm using

setHealth()

zero is because I want to bypass all hurt and death events, so that other mods can't cancel the death event to bypass my sword. So is there a way to trigger the death and hurt events without having them cancelable? Heres my current code:

 

@Override
public boolean onLeftClickEntity(ItemStack item, EntityPlayer player, Entity entity) {
	if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode)
		return false;

	if (entity instanceof EntityLivingBase) {
		EntityLivingBase mob = (EntityLivingBase) entity;
		EntityHelper.knockbackEntity(player, mob);



		mob.setHealth(0);
	}
	return true;
}

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.