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 ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.