use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class WanderingMobManager method summon.
public boolean summon(String wandererType, int level, Location<World> location) {
WanderingBoss<? extends Entity> wanderer = wanderers.get(wandererType);
if (wanderer == null) {
return false;
}
Entity entity = wanderer.createEntity(location);
boolean spawned = location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
if (!spawned) {
return false;
}
return wanderer.apply(entity, new WildernessBossDetail(level));
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class CursedMineListener method onItemDrop.
@Listener
public void onItemDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) BlockSpawnCause spawnCause, @Named(NamedCause.NOTIFIER) Player player) {
if (!Probability.getChance(4)) {
return;
}
BlockSnapshot blockSnapshot = spawnCause.getBlockSnapshot();
Optional<Location<World>> optLocation = blockSnapshot.getLocation();
if (!optLocation.isPresent()) {
return;
}
Location<World> loc = optLocation.get();
Optional<CursedMineInstance> optInst = manager.getApplicableZone(loc);
if (!optInst.isPresent()) {
return;
}
CursedMineInstance inst = optInst.get();
if (!inst.hasrecordForPlayerAt(player, loc)) {
return;
}
List<ItemStackSnapshot> itemStacks = new ArrayList<>();
Iterator<Entity> entityIterator = event.getEntities().iterator();
while (entityIterator.hasNext()) {
Entity entity = entityIterator.next();
if (entity instanceof Item) {
ItemStackSnapshot snapshot = ((Item) entity).item().get();
itemStacks.add(snapshot);
entityIterator.remove();
}
}
int times = 1;
Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
if (optService.isPresent()) {
ModifierService service = optService.get();
if (service.isActive(Modifiers.DOUBLE_CURSED_ORES)) {
times *= 2;
}
}
for (ItemStackSnapshot stackSnapshot : itemStacks) {
int quantity = Math.min(stackSnapshot.getCount() * Probability.getRangedRandom(4, 8), stackSnapshot.getType().getMaxStackQuantity());
for (int i = 0; i < times; ++i) {
ItemStack stack = stackSnapshot.createStack();
stack.setQuantity(quantity);
player.getInventory().offer(stack);
}
}
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class CannonCurse method accept.
@Override
public void accept(Player player) {
Entity entity = player.getWorld().createEntity(EntityTypes.FIREBALL, player.getLocation().getPosition());
player.getWorld().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class DeadlyPotionCurse method throwSlashPotion.
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] { PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS };
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(random.nextDouble() * .5 - .25, random.nextDouble() * .4 + .1, random.nextDouble() * .5 - .25));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.entity.Entity in project Skree by Skelril.
the class MainWorldWrapper method run.
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder().duration(3 * 20).amplifier(5).particles(false).potionType(PotionEffectTypes.SPEED).build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
Aggregations