Avenging the death of his gelatinous brethren, eh?
If you have asked me of the origination of unease, then I shall explain it to you in accordance with my understanding: Whatever various forms of unease there are in the world, They originate founded in encumbering accumulation. (Pārāyanavagga)
Exalted in mind, just open and clearly aware, the recluse trained in the ways of the sages: One who is such, calmed and ever mindful, He has no sorrows! -- Udana IV, 7
I get the impression that he/she had been observing for a while beforehand, from a distance, "ok...so the humans go in via that door, and come out again with sweet-smelling goods on them...ah, I see - you open the door from that side...right." The bear seemed quite familiar with the correct operation of that door.