# How do I modify the health of an entity after it has been created?

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.

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:

EntityLiving.setEntityHealth(health);


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

Use this JSON Code:

{HealF:0,Attributes:[{Name:"generic.maxHealth",Base:0}]}


, 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.

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 :)