Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to add or remove health after an entity has been created?

For example, I'd like to have a mob regenerate "hearts" when some event happens.

share|improve this question
Why the -1? Modding is on-topic and this is a good question. – Anko Feb 23 '13 at 3:20
up vote 7 down vote accepted

There are two ways. Using MCP obfuscation mappings, the first and proper way to do so is with:

EntityLiving.attackEntityFrom(DamageSource, damageDealt);

You need to specify where the damage came from in the first parameter though, so the simpler one is to simply use:


Use this with getHealth so you can do stuff like entity.setEntityHealth(entity.getHealth() - 1);

share|improve this answer

Use this JSON Code:


, use

/entitydata @e[type=MOBNAME] JSON

or use

/summon MOBNAME ~ ~ ~ JSON

to summon the mob or change the mobs health. Change the two 0's in the JSON code to whatever health you want that mobs health to be, but the format is set in half hearts, so you may want to double the number (So 100 full hearts would be 200 as the number in the JSON). This is completely vanilla, and uses no external resources.

share|improve this answer

Use MCedit to give mobs more/less heath. Or you could give it something like 5 seconds before it gets a regeneration effect. If you havn't got MCEdit look it up on youtube and download it :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.