crwdns142035:0crwdne142035:0

Warning

crwdns142037:0crwdne142037:0

crwdns142039:0:javadoc:crwdnd142039:0:javadoc:crwdnd142039:0:javadoc:crwdnd142039:0:javadoc:crwdne142039:0

crwdns142041:0crwdne142041:0

import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.EntityTypes;
import org.spongepowered.api.event.CauseStackManager.StackFrame;
import org.spongepowered.api.event.cause.entity.spawn.SpawnTypes;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

import java.util.Optional;

public void spawnEntity(Location<World> spawnLocation) {
    World world = spawnLocation.getExtent();

    Entity creeper = world.createEntity(EntityTypes.CREEPER, spawnLocation.getPosition());

    // 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.getCauseStackManager().pushCauseFrame()) {
        frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN);
        world.spawnEntity(creeper);
    }
}

crwdns142043:0:javadoc:crwdne142043:0

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