use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.
the class TeleportCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Player target;
if (src instanceof Player) {
target = (Player) src;
} else {
src.sendMessage(Text.of(TextColors.RED, "You are not a player and teleporting other players is not currently supported!"));
return CommandResult.empty();
}
Optional<Vector3d> dest = args.getOne("dest");
Vector3d rotation = new Vector3d(0, 0, 0);
World targetExtent = target.getWorld();
String destStr;
if (dest.isPresent()) {
if (!src.hasPermission("skree.teleport.teleport.coord")) {
src.sendMessage(Text.of(TextColors.RED, "You do not have permission to teleport by coordinates here."));
return CommandResult.empty();
}
destStr = dest.get().toString();
} else {
if (!src.hasPermission("skree.teleport.teleport.player")) {
src.sendMessage(Text.of(TextColors.RED, "You do not have permission to teleport to players here."));
return CommandResult.empty();
}
Player player = args.<Player>getOne("dest-player").get();
targetExtent = player.getWorld();
rotation = player.getRotation();
dest = Optional.of(player.getLocation().getPosition());
destStr = player.getName();
}
Optional<Location<World>> optSafeDest = SafeTeleportHelper.getSafeDest(target, new Location<>(targetExtent, dest.get()));
if (optSafeDest.isPresent()) {
if (!WorldEntryPermissionCheck.checkDestination(target, optSafeDest.get().getExtent())) {
src.sendMessage(Text.of(TextColors.RED, "You do not have permission to access worlds of this type."));
return CommandResult.empty();
}
target.setLocationAndRotation(optSafeDest.get(), rotation);
src.sendMessage(Text.of(TextColors.YELLOW, "Teleported to " + destStr + '.'));
} else {
src.sendMessage(Text.of(TextColors.RED, "The requested destination is unsafe."));
}
return CommandResult.success();
}
use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.
the class CursedMineInstance method ghost.
public void ghost(final Player player, BlockType blockID) {
if (Probability.getChance(player.getLocation().getBlockY())) {
if (Probability.getChance(2)) {
switch(Probability.getRandom(6)) {
case 1:
player.sendMessage(Text.of(TextColors.YELLOW, "Caspher the friendly ghost drops some bread."));
new ItemDropper(player.getLocation()).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.BREAD, Probability.getRandom(16))), SpawnTypes.DROPPED_ITEM);
break;
case 2:
player.sendMessage(Text.of(TextColors.YELLOW, "COOKIE gives you a cookie."));
new ItemDropper(player.getLocation()).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.COOKIE)), SpawnTypes.DROPPED_ITEM);
break;
case 3:
player.sendMessage(Text.of(TextColors.YELLOW, "Caspher the friendly ghost appears."));
List<ItemStack> caspherLoot = new ArrayList<>();
for (int i = 0; i < 8; i++) {
caspherLoot.add(newItemStack(ItemTypes.IRON_INGOT, Probability.getRandom(64)));
caspherLoot.add(newItemStack(ItemTypes.GOLD_INGOT, Probability.getRandom(64)));
caspherLoot.add(newItemStack(ItemTypes.DIAMOND, Probability.getRandom(64)));
}
new ItemDropper(player.getLocation()).dropStacks(caspherLoot, SpawnTypes.DROPPED_ITEM);
break;
case 4:
player.sendMessage(Text.of(TextColors.YELLOW, "John gives you a new jacket."));
new ItemDropper(player.getLocation()).dropStacks(Lists.newArrayList(newItemStack(ItemTypes.LEATHER_CHESTPLATE)), SpawnTypes.DROPPED_ITEM);
break;
case 5:
player.sendMessage(Text.of(TextColors.YELLOW, "Tim teleports items to you."));
getContained(Item.class).forEach(i -> i.setLocation(player.getLocation()));
// Add in some extra drops just in case the loot wasn't very juicy
List<ItemStack> teleportLootExtras = Lists.newArrayList(newItemStack(ItemTypes.IRON_INGOT, Probability.getRandom(64)), newItemStack(ItemTypes.GOLD_INGOT, Probability.getRandom(64)), newItemStack(ItemTypes.DIAMOND, Probability.getRandom(64)));
new ItemDropper(player.getLocation()).dropStacks(teleportLootExtras, SpawnTypes.DROPPED_ITEM);
break;
case 6:
player.sendMessage(Text.of(TextColors.YELLOW, "Dan gives you a sparkling touch."));
ItemType sparkingType;
switch(Probability.getRandom(3)) {
case 1:
sparkingType = ItemTypes.IRON_INGOT;
break;
case 2:
sparkingType = ItemTypes.GOLD_INGOT;
break;
case 3:
sparkingType = ItemTypes.DIAMOND;
break;
default:
sparkingType = ItemTypes.REDSTONE;
break;
}
TimedRunnable inventoryFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new InventoryCurse(sparkingType, 64).accept(player);
return true;
}
@Override
public void end() {
}
}, 10);
inventoryFX.setTask(Task.builder().execute(inventoryFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(inventoryFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
break;
default:
break;
}
} else {
switch(Probability.getRandom(11)) {
case 1:
if (Probability.getChance(4)) {
if (blockID == BlockTypes.DIAMOND_ORE) {
hitList.addPlayer(player);
player.sendMessage(Text.of(TextColors.RED, "You ignite fumes in the air!"));
EditSession ess = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new WorldResolver(getRegion().getExtent()).getWorldEditWorld(), -1);
try {
Vector3d pos = player.getLocation().getPosition();
ess.fillXZ(new Vector(pos.getX(), pos.getY(), pos.getZ()), WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.FIRE), 20, 20, true);
} catch (MaxChangedBlocksException ignored) {
}
for (int i = Probability.getRandom(24) + 20; i > 0; --i) {
final boolean untele = i == 11;
Task.builder().execute(() -> {
if (untele) {
recordSystem.revertByPlayer(player.getUniqueId());
hitList.remPlayer(player);
}
if (!contains(player))
return;
Vector3i pos = new PositionRandomizer(3).createPosition3i(player.getLocation().getPosition());
player.getLocation().getExtent().triggerExplosion(Explosion.builder().radius(3).location(player.getLocation().setPosition(pos.toDouble().add(.5, .5, .5))).shouldDamageEntities(true).canCauseFire(true).build(), Cause.source(SkreePlugin.container()).build());
}).delayTicks(12 * i).submit(SkreePlugin.inst());
}
} else {
hitList.addPlayer(player);
// player.chat("Who's a good ghost?!?!");
Task.builder().execute(() -> {
// player.chat("Don't hurt me!!!");
Task.builder().execute(() -> {
// player.chat("Nooooooooooo!!!");
TimedRunnable cannonFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new CannonCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 120);
cannonFX.setTask(Task.builder().execute(cannonFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(cannonFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
}).delay(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}).delay(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}
break;
}
case 2:
player.sendMessage(Text.of(TextColors.RED, "Dave attaches to your soul..."));
for (int i = 20; i > 0; --i) {
Task.builder().execute(() -> {
if (!contains(player))
return;
player.offer(Keys.HEALTH, Probability.getRandom(Probability.getRandom(player.get(Keys.MAX_HEALTH).get())) - 1);
}).delayTicks(12 * i).submit(SkreePlugin.inst());
}
break;
case 3:
player.sendMessage(Text.of(TextColors.RED, "George plays with fire, sadly too close to you."));
TimedRunnable fireFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new FireCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 90);
fireFX.setTask(Task.builder().execute(fireFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(fireFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
break;
case 4:
player.sendMessage(Text.of(TextColors.RED, "Simon says pick up sticks."));
List<ItemStack> sticks = new ArrayList<>();
for (int i = 0; i < tf(player).inventory.mainInventory.length * 1.5; i++) {
sticks.add(newItemStack(ItemTypes.STICK, 64));
}
new ItemDropper(player.getLocation()).dropStacks(sticks, SpawnTypes.DROPPED_ITEM);
break;
case 5:
player.sendMessage(Text.of(TextColors.RED, "Ben dumps out your backpack."));
TimedRunnable butterFingerFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new ButterFingersCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 20);
butterFingerFX.setTask(Task.builder().execute(butterFingerFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(butterFingerFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
break;
case 6:
player.sendMessage(Text.of(TextColors.RED, "Merlin attacks with a mighty rage!"));
TimedRunnable merlinFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new MerlinCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 40);
merlinFX.setTask(Task.builder().execute(merlinFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(merlinFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
break;
case 7:
player.sendMessage(Text.of(TextColors.RED, "Dave tells everyone that your mining!"));
MessageChannel.TO_PLAYERS.send(Text.of(TextColors.GOLD, player.getName() + " is mining in the cursed mine!!!"));
break;
case 8:
player.sendMessage(Text.of(TextColors.RED, "Dave likes your food."));
hitList.addPlayer(player);
TimedRunnable starvationFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new StarvationCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 40);
starvationFX.setTask(Task.builder().execute(starvationFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(starvationFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
break;
case 9:
player.sendMessage(Text.of(TextColors.RED, "Hallow declares war on YOU!"));
for (int i = 0; i < Probability.getRangedRandom(10, 30); i++) {
Blaze blaze = (Blaze) getRegion().getExtent().createEntity(EntityTypes.BLAZE, player.getLocation().getPosition());
blaze.setTarget(player);
getRegion().getExtent().spawnEntity(blaze, Cause.source(SpawnCause.builder().type(SpawnTypes.BLOCK_SPAWNING).build()).build());
}
break;
case 10:
player.sendMessage(Text.of(TextColors.RED, "A legion of hell hounds appears!"));
for (int i = 0; i < Probability.getRangedRandom(10, 30); i++) {
Wolf wolf = (Wolf) getRegion().getExtent().createEntity(EntityTypes.WOLF, player.getLocation().getPosition());
wolf.setTarget(player);
getRegion().getExtent().spawnEntity(wolf, Cause.source(SpawnCause.builder().type(SpawnTypes.BLOCK_SPAWNING).build()).build());
}
break;
case 11:
if (blockID == BlockTypes.EMERALD_ORE) {
player.sendMessage(Text.of(TextColors.RED, "Dave got a chemistry set!"));
hitList.addPlayer(player);
TimedRunnable deadlyPotionFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new DeadlyPotionCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 2 * 60 * 30);
deadlyPotionFX.setTask(Task.builder().execute(deadlyPotionFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(deadlyPotionFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
} else {
player.sendMessage(Text.of(TextColors.RED, "Dave says hi, that's not good."));
hitList.addPlayer(player);
TimedRunnable attackOfDaveFX = new TimedRunnable<>(new IntegratedRunnable() {
@Override
public boolean run(int times) {
new AttackOfDaveCurse().accept(player);
return true;
}
@Override
public void end() {
}
}, 2 * 60 * 30);
attackOfDaveFX.setTask(Task.builder().execute(attackOfDaveFX).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst()));
activeTask.merge(player, Lists.newArrayList(attackOfDaveFX.getTask()), (a, b) -> {
a.addAll(b);
return a;
});
}
break;
default:
break;
}
}
}
}
use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.
the class WildernessWorldWrapper method onBlockPlace.
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Named(NamedCause.SOURCE) Player player) {
for (Transaction<BlockSnapshot> block : event.getTransactions()) {
Optional<Location<World>> optLoc = block.getFinal().getLocation();
if (!optLoc.isPresent() || !isApplicable(optLoc.get())) {
continue;
}
Location<World> loc = optLoc.get();
BlockState finalState = block.getFinal().getState();
if (config.getDropAmplificationConfig().amplifies(finalState)) {
// Allow creative mode players to still place blocks
if (player.getGameModeData().type().get().equals(GameModes.CREATIVE)) {
continue;
}
BlockType originalType = block.getOriginal().getState().getType();
if (ore().contains(originalType)) {
continue;
}
try {
Vector3d origin = loc.getPosition();
World world = loc.getExtent();
for (int i = 0; i < 40; ++i) {
ParticleEffect effect = ParticleEffect.builder().type(ParticleTypes.MAGIC_CRITICAL_HIT).velocity(new Vector3d(Probability.getRangedRandom(-1, 1), Probability.getRangedRandom(-.7, .7), Probability.getRangedRandom(-1, 1))).quantity(1).build();
world.spawnParticles(effect, origin.add(.5, .5, .5));
}
} catch (Exception ex) {
player.sendMessage(/* ChatTypes.SYSTEM, */
Text.of(TextColors.RED, "You find yourself unable to place that block."));
}
block.setValid(false);
}
}
}
use of com.flowpowered.math.vector.Vector3d 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 com.flowpowered.math.vector.Vector3d in project Skree by Skelril.
the class PatientXManager method setupBossManager.
private void setupBossManager() {
Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Zombie.class));
List<Instruction<BindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> bindProcessor = bossManager.getBindProcessor();
bindProcessor.add((condition, boss) -> {
Optional<Zombie> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Zombie bossEnt = optBossEnt.get();
bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Patient X"));
setMaxHealth(bossEnt, config.bossHealth, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
Optional<Zombie> optBoss = boss.getTargetEntity();
if (optBoss.isPresent()) {
optBoss.get().offer(Keys.PERSISTS, true);
}
return Optional.empty();
});
bindProcessor.add((condition, boss) -> {
boss.getDetail().getZone().getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.GOLD, "Ice to meet you again!"));
return Optional.empty();
});
List<Instruction<UnbindCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> unbindProcessor = bossManager.getUnbindProcessor();
unbindProcessor.add((condition, boss) -> {
PatientXInstance inst = boss.getDetail().getZone();
Location<World> target = inst.getCenter();
for (Player player : inst.getPlayers(PlayerClassifier.PARTICIPANT)) {
player.setLocation(target);
boolean useX = Probability.getChance(2);
int accel = Probability.getChance(2) ? 1 : -1;
Vector3d v = new Vector3d(useX ? accel : 0, 0, !useX ? accel : 0);
player.setVelocity(v);
}
inst.freezeBlocks(100, false);
// Reset respawn mechanics
inst.bossDied();
return Optional.empty();
});
List<Instruction<DamageCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damageProcessor = bossManager.getDamageProcessor();
damageProcessor.add((condition, boss) -> {
PatientXInstance inst = boss.getDetail().getZone();
DamageEntityEvent event = condition.getEvent();
// Nullify all modifiers
for (Tuple<DamageModifier, Function<? super Double, Double>> modifier : event.getModifiers()) {
event.setDamage(modifier.getFirst(), (a) -> a);
}
event.setBaseDamage(inst.getDifficulty() * config.baseBossHit);
return Optional.empty();
});
List<Instruction<DamagedCondition, Boss<Zombie, ZoneBossDetail<PatientXInstance>>>> damagedProcessor = bossManager.getDamagedProcessor();
damagedProcessor.add((condition, boss) -> {
DamageEntityEvent event = condition.getEvent();
Optional<DamageSource> optDamageSource = condition.getDamageSource();
if (optDamageSource.isPresent() && blockedDamage.contains(optDamageSource.get().getType())) {
event.setCancelled(true);
return Optional.empty();
}
return Optional.of((damagedCondition, zombieZoneBossDetailBoss) -> {
PatientXInstance inst = boss.getDetail().getZone();
if (optDamageSource.isPresent() && optDamageSource.get() instanceof EntityDamageSource) {
if (optDamageSource.get() instanceof IndirectEntityDamageSource) {
Task.builder().execute(() -> {
VelocityEntitySpawner.sendRadial(EntityTypes.SNOWBALL, inst.getBoss().get(), Cause.source(SpawnCause.builder().type(SpawnTypes.PROJECTILE).build()).build());
}).delayTicks(1).submit(SkreePlugin.inst());
} else {
Entity srcEntity = ((EntityDamageSource) optDamageSource.get()).getSource();
if (srcEntity instanceof Player) {
Optional<ItemStack> optHeld = ((Player) srcEntity).getItemInHand(HandTypes.MAIN_HAND);
if (optHeld.isPresent() && optHeld.get().getItem() == ItemTypes.BLAZE_ROD) {
inst.modifyDifficulty(2);
}
}
}
}
inst.modifyDifficulty(.5);
inst.teleportRandom(true);
return Optional.empty();
});
});
}
Aggregations