Skip to content

Spawning an entity

After you have injected your entity, you will likely want to spawn it in the world. You can use the /summon command (e.g. /summon my_plugin:capybara), but you may also want to do this programmatically using the Bestium API.

To spawn an entity with the API, use:

Bestium.getEntityManager().spawn(Location, Class, EntitySpawnReason, CreatureSpawnEvent.SpawnReason, [Consumer])

This method requires four parameters:

The position where the entity should be spawned.

Location(world, 0.0, 64.0, 0.0)

The class of the injected entity you want to spawn.

Capybara::class.java

The (NMS) reason for spawning the entity, stored in the entity data.

For example, when spawning via a command:

EntitySpawnReason.COMMAND

The (Bukkit) spawn reason, used for Bukkit events.

For example, when spawning via a command:

CreatureSpawnEvent.SpawnReason.COMMAND

A function that allows you to modify the entity just before it is spawned.
This is useful if you want to customize the entity, right after creation.