Spawning entities with causes

With the new changes to the API spawnEntity(Entity entity) has changed to spawnEntity(Entity entity, Cause cause). The docs/cookbook appear out of date with this change, so my question is what is the proper way to generate a cause for this method? For instance, when trying to spawn an entity with a command.

Thanks!

To define a Cause you use the Cause.of(...) method. If there is no applicable cause, use Cause.empty()

In your example, the cause could be the CommandSource that sent the command (Player, Server, Rcon…). you just add the list of objects to the parameter of Cause.of(...)

Ah, I see. Thank you!