EntityEvents.hurt('takesapillage:legioner', event => {
    const player = event.source.player
    const mob = event.entity

    if (!player) return

    // Don't trigger if already charging
    if (mob.potionEffects.isActive('minecraft:slowness')) return

    mob.potionEffects.add('minecraft:slowness', 40, 0, false, true)

    mob.server.scheduleInTicks(34, t => {
        if (!mob.isAlive()) return
        if (!mob.potionEffects.isActive('minecraft:slowness')) return

        mob.server.runCommandSilent(
            `particle minecells:charge ${mob.x} ${mob.y + 2} ${mob.z} 0 0 0 0.1 100 normal`
        )
        mob.server.runCommandSilent(
            `playsound minecells:shieldbearer.charge master @a ${mob.x} ${mob.y} ${mob.z} 1 1`
        )
    })

    mob.server.scheduleInTicks(40, t => {
        if (!mob.isAlive()) return

        mob.potionEffects.add('minecraft:speed', 25, 3, false, true)
    })
})