use of org.spongepowered.api.entity.weather.Lightning in project Skree by Skelril.
the class ZoneMasterOrb method createLightningStrike.
private void createLightningStrike(Player player) {
Location<World> loc = player.getLocation();
Lightning lightning = (Lightning) loc.getExtent().createEntity(EntityTypes.LIGHTNING, loc.getPosition());
lightning.setEffect(true);
loc.getExtent().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.entity.weather.Lightning in project Skree by Skelril.
the class ThorAttack method apply.
@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
Living bossEnt = zombieCatacombsBossDetailBoss.getTargetEntity().get();
Entity toHit = damageCondition.getAttacked();
toHit.setVelocity(EntityDirectionUtil.getFacingVector(bossEnt).mul(2));
Task.builder().execute(() -> {
Location<World> targetLoc = toHit.getLocation();
Task.builder().execute(() -> {
Lightning lightning = (Lightning) toHit.getWorld().createEntity(EntityTypes.LIGHTNING, targetLoc.getPosition());
toHit.getWorld().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}).delay(750, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
}).delay(1500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
return Optional.empty();
}
use of org.spongepowered.api.entity.weather.Lightning in project modules-extra by CubeEngine.
the class PlayerCommands method lightning.
@Command(alias = "strike", desc = "Throws a lightning bolt at a player or where you're looking")
public void lightning(CommandSource context, @Optional Integer damage, @Named({ "player", "p" }) Player player, @Named({ "fireticks", "f" }) Integer seconds, @Flag boolean unsafe) {
damage = damage == null ? -1 : damage;
if (damage != -1 && !context.hasPermission(module.perms().COMMAND_LIGHTNING_PLAYER_DAMAGE.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to specify the damage!");
return;
}
if ((damage != -1 && damage < 0) || damage > 20) {
i18n.send(context, NEGATIVE, "The damage value has to be a number from 1 to 20");
return;
}
if (unsafe && !context.hasPermission(module.perms().COMMAND_LIGHTNING_UNSAFE.getId())) {
i18n.send(context, NEGATIVE, "You are not allowed to use the unsafe flag");
return;
}
Location<World> location;
if (player != null) {
location = player.getLocation();
player.offer(Keys.FIRE_TICKS, 20 * (seconds == null ? 0 : seconds));
if (damage != -1) {
// TODO better source
player.damage(damage, DamageSource.builder().type(DamageTypes.CONTACT).build());
}
} else {
if (!(context instanceof Player)) {
i18n.send(context, NEGATIVE, "This command can only be used by a player!");
return;
}
java.util.Optional<BlockRayHit<World>> end = BlockRay.from(((Player) context)).distanceLimit(module.getConfig().command.lightning.distance).stopFilter(BlockRay.onlyAirFilter()).build().end();
if (end.isPresent()) {
location = end.get().getLocation();
} else {
throw new IllegalStateException();
}
}
Entity entity = location.getExtent().createEntity(EntityTypes.LIGHTNING, location.getPosition());
if (!unsafe) {
((Lightning) entity).setEffect(true);
}
Sponge.getCauseStackManager().pushCause(context);
location.getExtent().spawnEntity(entity);
}
use of org.spongepowered.api.entity.weather.Lightning in project Skree by Skelril.
the class BuildWorldWrapper method onEntitySpawn.
@Listener
public void onEntitySpawn(SpawnEntityEvent event) {
List<Entity> entities = event.getEntities();
Optional<BlockSpawnCause> optBlockCause = event.getCause().first(BlockSpawnCause.class);
for (Entity entity : entities) {
if (!isApplicable(entity)) {
continue;
}
if (entity instanceof Lightning) {
((Lightning) entity).setEffect(true);
continue;
}
if (entity instanceof Egg && optBlockCause.isPresent()) {
new ItemDropper(entity.getLocation()).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.EGG)), SpawnTypes.DISPENSE);
event.setCancelled(true);
return;
}
if (entity instanceof Monster || (entity instanceof SkeletonHorse)) {
event.setCancelled(true);
return;
}
}
}
use of org.spongepowered.api.entity.weather.Lightning in project Skree by Skelril.
the class LightningStrike method run.
@Override
public void run(Living owner, Location<World> target) {
Lightning lightning = (Lightning) target.createEntity(EntityTypes.LIGHTNING);
target.spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
Aggregations