Skip to content

FAQ: How do I give Entities more health?

1cec0ld edited this page Oct 5, 2012 · 5 revisions

Since Bukkit recently started enforcing a maximum health on all entities, it's now tricky to give them more health. Fortunately ModDamage can simulate this pretty easily, however you have to be careful with {entity}effect.hurt and heal because they won't work the same. Example:

Damage:
    # Your damage routines here
    
    # Leave this bit at the very bottom of Damage. It will catch the damage dealt and apply it to their health tag
    - 'if target.istagged.health':
        - 'tag.target.health': '-damage'
        - '1' # this can't be zero or the mob wouldn't play its hurt animation
        - 'set.target_health': 'target_maxhealth' # don't let it die prematurely
        - 'if target_tagvalue_health <= 0':
            - 'set.target_health': '1' # kill them with the next hit
Spawn:
    - 'switch.entity.type':
        - 'Spider': '1000' # Spiders are hard to kill
    
    # Leave this bit at the very bottom of Spawn. It will catch health values greater than an entity's maximum
    # and convert them to a health tag
    - 'if entity_health > entity_maxhealth':
        - 'tag.entity.health': 'entity_health' # set the health tag to be what the health would normally be set to
        - 'entity_maxhealth' # set their health to normal
Clone this wiki locally