Spawn Entities

You can use several functions to spawn different entities and creatures, as well as game objects—like an Ender Pearl.[32] To create new things in the world, we’ll use functions defined in our EZPlugin helper instead of writing out all the code directly. It’s not that the code is particularly complicated or hard to understand; it’s just that these couple of lines of code will always be the same, so it makes sense to use a helper function. That way you only need to use the one-line helper function call, instead of using several lines of duplicated code. Let’s take a close look at what those helper functions actually do.

Here’s the method we’ve been using to spawn cows, squid, and such:

EZPlugin/src/com/pragprog/ahmine/ez/EZPlugin.java ...

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.