O'Reilly logo

Learn to Program with Minecraft Plugins, 2nd Edition by Andy Hunt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Knit It All Together

We need to add a few things from our list of materials and take care of a couple of problems.

First off, we need to fix the dying cows, so let’s add an event handler to listen for DamageHook, and cancel the event if its cause is DamageType.FALL. Ah, if we cancel the damage event, we don’t need to bump up the cow’s health.

When testing the spawn function and the jump, we used ourselves as the target. We need to do a little better than that, so we’ll have to add a getClosestPlayer() function to find the closest player to any given cow.

And as we saw earlier, we need to pick an event to use to spawn these creeper cows. There are probably a couple of ways to do that. You don’t want to spawn cows all over the world; it ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required