HyperScript
Docs

← All of the Docs The world

Mobs of your own

expressiontype: <creature>since 1.7.28

What kind of creature it is: zombie, skeleton, iron golem. A zombie if left out

mob "Guard Dog":
    type: wolf
    health: 40

command /dog:
    players only: true
    trigger:
        spawn mob "Guard Dog" at player's location
Try it
expressionname: <text>since 1.7.28

The name shown above it; the block's own name if left out, and name: none for no name

mob "elite":
    type: zombie
    name: "&c&lElite Zombie"
    health: 60
Try it
expressionhealth: <n>since 1.7.28

Its health, in half hearts, up to 2048

mob "Tank":
    type: iron golem
    health: 400
Try it
expressiondamage: <n>since 1.7.28

How hard it hits, for a creature that attacks

mob "Brute":
    type: zombie
    damage: 12
Try it
expressionspeed: <n>since 1.7.28

How fast it is, as a multiple of what such a creature usually is: 1.5 is half as fast again

mob "Runner":
    type: zombie
    speed: 1.6
    baby: true
Try it
expressionholding: <item>since 1.7.28

What it has in its hand

mob "Knight":
    type: zombie
    holding: diamond sword
Try it
expressionwearing: <item>, <item>since 1.7.28

Its armour; each piece goes where it belongs

mob "Knight":
    type: zombie
    wearing: diamond helmet, diamond chestplate
Try it
expressiondrops: <item>, <item>since 1.7.28

What it leaves when it dies, in place of what such a creature usually drops. drops: nothing for nothing

mob "Treasure Zombie":
    type: zombie
    drops: 5 diamond, 1 golden apple
Try it
expressionexperience: <n>since 1.7.28

The experience it leaves

mob "Sage":
    type: villager
    experience: 200
    drops: nothing
Try it
expressionglowing: true / silent: true / baby: truesince 1.7.28

As it says

mob "Marked One":
    type: zombie
    glowing: true
    silent: true
Try it
eventon spawn:since 1.7.28

Runs when one is spawned. player is whoever's script spawned it, if anybody

mob "Herald":
    type: zombie
    on spawn:
        broadcast "&cA herald has appeared!"
Try it
eventon death:since 1.7.28

Runs when one dies. player is who killed it; there is none if nobody did

mob "Bounty":
    type: zombie
    health: 80
    on death:
        if player is set:
            add 100 to {%player%.coins}
            send "&a+100 coins for the bounty."
Try it
eventon hit:since 1.7.17

Runs when it hurts a player, who is player

enchantment lightning:
    on hit:
        if chance of 20%:
            strike lightning at victim
Try it

What this event gives a script

PlaceholderShort formTypeMeaning
%event.attacker%attackertextWho dealt the damage: a player's name or a mob type such as zombie. For an arrow or other projectile this is whoever shot it. Unset for damage with no attacker, such as falling
%event.victim%victimtextWho was hurt: a player's name or a mob type
%event.damage%damagenumberDamage actually taken, after armour and effects; 2 is one heart
%event.cause%causetextWhy: FALL, FIRE, ENTITY_ATTACK, PROJECTILE, DROWNING, VOID and so on
%event.entity%entitytextThe victim's entity type, e.g. player or zombie
%event.location%locationWhere the victim is
x of event's locationnumberThe x of %event.location%, as a number
y of event's locationnumberThe y of %event.location%, as a number: how high it is
z of event's locationnumberThe z of %event.location%, as a number
  • Can be cancelled: Yes
  • player is: The victim if a player was hurt; otherwise the attacker if a player dealt the damage; otherwise nobody

More about on entity damage:, with a box to try it in

eventon hurt:since 1.7.17

Runs when a player hurts it; player is that player

enchantment dodge:
    on hurt:
        if chance of 10%:
            cancel event
            send "&7Dodged!"
Try it
effectspawn mob <name> at <location>since 1.7.28

Make one of a described mob there. last summoned entity is the creature

command /boss:
    permission: op
    players only: true
    trigger:
        spawn mob "Frost Giant" at player's location
        set {_giant} to last summoned entity
        make {_giant} target player
Try it
expressionmob name of <entity>since 1.7.28

Which mob block a creature was made from, as its name; unset for any other creature

command /summongiant:
    permission: op
    players only: true
    trigger:
        spawn mob "Frost Giant" at player's location
        set {_made} to last summoned entity
        send "&7That is a &f" + mob name of {_made}
Try it
Guide and examples

A mob block describes a creature once: what it is, how strong, what it carries and drops, and what happens when it dies. spawn mob then makes one wherever you like.

mob "&bFrost Giant":
    type: zombie
    health: 100
    damage: 8
    holding: diamond axe
    wearing: diamond helmet, diamond chestplate
    drops: 3 diamond, 1 ice
    experience: 50
    on death:
        broadcast "&bThe Frost Giant has fallen to %player.name%!"
    on hit:
        apply slowness 2 to player for 3 seconds

command /giant:
    permission: "mobs.spawn"
    players only: true
    trigger:
        spawn mob "Frost Giant" at player's location
Inside the blockMeaning
type: <creature>What kind of creature it is: zombie, skeleton, iron golem. A zombie if left out
name: <text>The name shown above it; the block's own name if left out, and name: none for no name
health: <n>Its health, in half hearts, up to 2048
damage: <n>How hard it hits, for a creature that attacks
speed: <n>How fast it is, as a multiple of what such a creature usually is: 1.5 is half as fast again
holding: <item>What it has in its hand
wearing: <item>, <item>Its armour; each piece goes where it belongs
drops: <item>, <item>What it leaves when it dies, in place of what such a creature usually drops. drops: nothing for nothing
experience: <n>The experience it leaves
glowing: true / silent: true / baby: trueAs it says
on spawn:Runs when one is spawned. player is whoever's script spawned it, if anybody
on death:Runs when one dies. player is who killed it; there is none if nobody did
on hit:Runs when it hurts a player, who is player
on hurt:Runs when a player hurts it; player is that player
SyntaxMeaning
spawn mob <name> at <location>Make one of a described mob there. last summoned entity is the creature
mob name of <entity>Which mob block a creature was made from, as its name; unset for any other creature
  • Inside the four blocks {_mob} is the creature and {_name} its mob's name; in on hit: and on hurt: {_damage} is how much damage was done. cancel event in those two stops the damage.
  • A mob is known by its name without colours, whatever capitals it is written with: the block above is spawned as "Frost Giant" or "frost giant".
  • A creature remembers which mob it is. After a restart or a reload its blocks still run, as long as a script still has a mob block of that name.
  • The block's lines are worked out when one is spawned, so health: {boss.health} takes the saved variable as it is then. Local variables cannot be used in them.
  • For creatures with skills, phases and models of their own, the MythicMobs plugin and the HyperMobs addon go further.