Hi,
I tried to spawn some creeper. But they doesnt move and doesnt do anything. Why are they stupid?
Thanks for helping me.
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (src instanceof Player) {
Location<World> location = ((Player) src).getLocation();
World world = location.getExtent();
Entity creeper = world.createEntity(EntityTypes.CREEPER, location.getPosition());
creeper.offer(Keys.DISPLAY_NAME, Text.of("Creepy Creeper"));
creeper.offer(Keys.ANGRY, true);
try (CauseStackManager.StackFrame frame = Sponge.getCauseStackManager().pushCauseFrame()) {
frame.addContext(EventContextKeys.SPAWN_TYPE, SpawnTypes.PLUGIN);
world.spawnEntity(creeper);
world.playSound(SoundTypes.ENTITY_GHAST_SCREAM, location.getPosition(), 100);
}
}
return CommandResult.success();
}