crwdns142035:0crwdne142035:0

crwdns157306:0:javadoc:crwdnd157306:0:javadoc:crwdnd157306:0:javadoc:crwdne157306:0

crwdns142041:0crwdne142041:0

import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.living.monster.Creeper;
import org.spongepowered.api.entity.EntityTypes;
import org.spongepowered.api.event.CauseStackManager.StackFrame;
import org.spongepowered.api.event.EventContextKeys;
import org.spongepowered.api.event.cause.entity.SpawnTypes;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.api.world.server.ServerWorld;

public void spawnEntity(ServerLocation spawnLocation) {
    ServerWorld world = spawnLocation.world();

    Creeper creeper = world.createEntity(EntityTypes.CREEPER, spawnLocation.position());

    // We need to push a new cause StackFrame to the stack so we can add our own causes
    // In previous versions of the API you had to submit a Cause parameter
    // that would often not contain the real root cause
    // By default the current plugin's PluginContainer is already pushed to the stack.
    try (StackFrame frame = Sponge.server().causeStackManager().pushCauseFrame()) {
        frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN);
        world.spawnEntity(creeper);
    }
}

crwdns157308:0:javadoc:crwdne157308:0

Note

crwdns157310:0:javadoc:crwdnd157310:0:javadoc:crwdnd157310:0:doc:crwdne157310:0

crwdns142045:0:javadoc:crwdnd142045:0:javadoc:crwdnd142045:0:javadoc:crwdne142045:0