public void sendToSpawn(Gamer gamer) {
   final Player p = gamer.getPlayer();
   Location originalSpawn = p.getWorld().getSpawnLocation();
   MainConfig main = HungergamesApi.getConfigManager().getMainConfig();
   int spawnRadius = main.getSpawnRadius();
   int spawnHeight = main.getSpawnHeight();
   if (spawns.size() > 0) {
     if (spawnItel == null || !spawnItel.hasNext()) spawnItel = spawns.keySet().iterator();
     originalSpawn = spawnItel.next();
     spawnRadius = Math.max(1, spawns.get(originalSpawn)[0]);
     spawnHeight = Math.max(1, spawns.get(originalSpawn)[1]);
   }
   Location spawn = originalSpawn.clone();
   int chances = 0;
   if (p.isInsideVehicle()) p.leaveVehicle();
   p.eject();
   while (chances < main.getTimesToCheckForValidSpawnPerPlayer()) {
     chances++;
     Location newLoc =
         new Location(
             p.getWorld(),
             spawn.getX() + returnChance(-spawnRadius, spawnRadius),
             spawn.getY() + new Random().nextInt(spawnHeight),
             spawn.getZ() + returnChance(-spawnRadius, spawnRadius));
     if (nonSolid.contains(newLoc.getBlock().getTypeId())
         && nonSolid.contains(newLoc.getBlock().getRelative(BlockFace.UP).getTypeId())) {
       while (newLoc.getBlockY() >= 1
           && nonSolid.contains(newLoc.getBlock().getRelative(BlockFace.DOWN).getTypeId())) {
         newLoc = newLoc.add(0, -1, 0);
       }
       if (newLoc.getBlockY() <= 1) continue;
       spawn = newLoc;
       break;
     }
   }
   if (spawn.equals(originalSpawn)) {
     spawn =
         new Location(
             p.getWorld(),
             spawn.getX() + returnChance(-spawnRadius, spawnRadius),
             0,
             spawn.getZ() + returnChance(-spawnRadius, spawnRadius));
     spawn.setY(spawn.getWorld().getHighestBlockYAt(spawn));
     if (gamer.isAlive() && spawn.getY() <= 1) {
       spawn.getBlock().setType(Material.GLASS);
       spawn.setY(spawn.getY() + 1);
     }
   }
   final Location destination = spawn.add(0.5, 0.1, 0.5);
   p.teleport(destination);
   Bukkit.getScheduler()
       .scheduleSyncDelayedTask(
           hg,
           new Runnable() {
             public void run() {
               p.teleport(destination);
             }
           });
 }
Exemple #2
0
  @Override
  public CastResult cast(SpellContext context) {
    Player player = context.<Player>getPlayer();
    Block target = context.<Block>getTarget().get();
    BlockFace direction = getClickedFace(player);
    Block phased = null;

    switch (direction) {
      case NORTH:
        phased = target.getRelative(0, 0, -1);
        break;
      case SOUTH:
        phased = target.getRelative(0, 0, 1);
        break;
      case EAST:
        phased = target.getRelative(1, 0, 0);
        break;
      case WEST:
        phased = target.getRelative(-1, 0, 0);
        break;
      case UP:
        phased = target.getRelative(0, +3, 0);
        break;
      case DOWN:
        phased = target.getRelative(0, -2, 0);
        break;
      default:
        phased = target;
        break;
    }

    if (!BukkitTargetUtils.getTransparent().contains(phased.getType())) {
      player.sendMessage(ChatColor.RED + "You cannot phase through that block");
      return CastResult.FAILURE;
    } else if (BukkitTargetUtils.getTransparent()
        .contains(phased.getRelative(0, -1, 0).getType())) {
      Location loc = phased.getRelative(0, -1, 0).getLocation();
      loc.add(0.5, 0, 0.5);
      loc.setPitch(player.getLocation().getPitch());
      loc.setYaw(player.getLocation().getYaw());
      player.teleport(loc);
      return CastResult.SUCCESS;
    } else if (BukkitTargetUtils.getTransparent().contains(phased.getRelative(0, 1, 0).getType())) {
      Location loc = phased.getLocation();
      loc.add(0.5, 0, 0.5);
      loc.setPitch(player.getLocation().getPitch());
      loc.setYaw(player.getLocation().getYaw());
      player.teleport(loc);
      return CastResult.SUCCESS;
    } else {
      player.sendMessage(ChatColor.RED + "You cannot phase through that block");
      return CastResult.FAILURE;
    }
  }
  public static void removeOwnerSign(final World world, final String id) {
    final Location bottom = getPlotBottomLoc(world, id);

    final Location pillar =
        new Location(world, bottom.getX() - 1, getMap(world).RoadHeight + 1, bottom.getZ() - 1);

    final Block bsign = pillar.add(0, 0, -1).getBlock();
    final Block redlight = pillar.add(0, -1, 0).getBlock();
    bsign.setType(Material.AIR);
    redlight.setType(Material.WOOD);
  }
  /**
   * Returns the distance from the given location to the border.
   *
   * <p>If the location is inside the border, or not in the same world, this returns 0.
   *
   * @param location The location to be checked.
   * @param diameter The "diameter" of the squared wall (i.e. the size of a side of the wall).
   * @return the distance from the given location to the border.
   */
  private int getDistanceToSquaredBorder(Location location, int diameter) {
    if (!location.getWorld().equals(Bukkit.getWorlds().get(0))) { // The nether is not limited.
      return 0;
    }
    if (isInsideBorder(location, diameter)) {
      return 0;
    }

    Integer halfMapSize = (int) Math.floor(diameter / 2);
    Integer x = location.getBlockX();
    Integer z = location.getBlockZ();

    Location spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitXInf = spawn.add(-halfMapSize, 0, 0).getBlockX();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitXSup = spawn.add(halfMapSize, 0, 0).getBlockX();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitZInf = spawn.add(0, 0, -halfMapSize).getBlockZ();

    spawn = Bukkit.getWorlds().get(0).getSpawnLocation();
    Integer limitZSup = spawn.add(0, 0, halfMapSize).getBlockZ();

    if (x > limitXSup && z < limitZSup && z > limitZInf) { // East of the border
      return Math.abs(x - limitXSup);
    } else if (x < limitXInf && z < limitZSup && z > limitZInf) { // West of the border
      return Math.abs(x - limitXInf);
    } else if (z > limitZSup && x < limitXSup && x > limitXInf) { // South of the border
      return Math.abs(z - limitZSup);
    } else if (z < limitZInf && x < limitXSup && x > limitXInf) { // North of the border
      return Math.abs(z - limitZInf);
    } else if (x > limitXSup && z < limitZInf) { // N-E
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZInf));
    } else if (x > limitXSup && z > limitZSup) { // S-E
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXSup, location.getBlockY(), limitZSup));
    } else if (x < limitXInf && z > limitZSup) { // S-O
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZSup));
    } else if (x < limitXInf && z < limitZInf) { // N-O
      return (int)
          location.distance(
              new Location(location.getWorld(), limitXInf, location.getBlockY(), limitZInf));
    } else {
      return 0; // Should never happen.
    }
  }
Exemple #5
0
 @EventHandler
 public void snowballParticle(ProjectileHitEvent event) {
   if (!_balls.remove(event.getEntity())) {
     return;
   }
   Location loc = event.getEntity().getLocation().add(event.getEntity().getVelocity());
   loc.getWorld().playSound(loc, Sound.WOLF_BARK, 1.0F, 1.0F);
   ParticleLib18 portal = new ParticleLib18(ParticleLib18.ParticleType.PORTAL, 0.0D, 20, 0.0D);
   ParticleLib18 spark =
       new ParticleLib18(ParticleLib18.ParticleType.FIREWORKS_SPARK, 0.0D, 10, 0.0D);
   portal.sendToLocation(loc.add(0.0D, 1.0D, 0.0D));
   spark.sendToLocation(loc.add(0.0D, 1.0D, 0.0D));
 }
Exemple #6
0
  @EventHandler
  public void preLogin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    if (!player.hasPlayedBefore()) {

      Location location = player.getWorld().getSpawnLocation();
      location.add(0.5, 0.5, 0.5);
      final Location loc = location;
      Bukkit.getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              SCB.getInstance(),
              new Runnable() {

                @Override
                public void run() {
                  System.out.println(
                      "Teleporting new player to X "
                          + loc.getX()
                          + " Y "
                          + loc.getY()
                          + " Z "
                          + loc.getZ());
                  player.teleport(loc);
                  player.sendMessage(
                      ChatColor.GREEN
                          + "You have been spawned here as you are a first time player");
                }
              },
              1l);
    }
  }
  private int spoutableWaterHeight(Location location) {

    Location loc = location.clone();
    if (loc.getBlock().getType() != Material.AIR && !BlockTools.isWaterBased(loc.getBlock())) {
      return -1;
    }
    int height = HEIGHT;
    if (Tools.isNight(loc.getWorld())) {
      height = (int) (Settings.NIGHT_FACTOR * HEIGHT) + 1;
    }
    for (int i = 0; i <= (height + 1); i++) {
      Location locToTest = loc.add(0, -1, 0);
      if (ProtectionManager.isRegionProtectedFromBending(
          this.player, BendingAbilities.WaterSpout, locToTest)) {
        return -1;
      }
      Block block = locToTest.getBlock();
      if (block.getType().equals(Material.AIR)) {
        this.height = i + 1;
        continue;
      }
      if (BlockTools.isWaterBased(block)) {
        // Valid source !
        return i + 1;
      } else {
        return -1;
        // Cannot waterspout
      }
    }
    return -2;
    // Can waterspout but too high
  }
Exemple #8
0
  @Override
  public boolean effect(Player p, Block b) {
    Location loc = b.getLocation().add(0, 1, 0);

    if (!loc.getBlock().isEmpty()) {
      return false;
    }

    for (int x = -1; x <= 1; x++) {
      for (int z = -1; z <= 1; z++) {
        Location l = loc;
        Effects.play(l.add(x, 0, z), Effect.TILE_BREAK, NUM);
      }
    }
    Zombie z = p.getWorld().spawn(loc, Zombie.class);

    for (Entity e : p.getNearbyEntities(20, 20, 20)) {
      if (e instanceof Player && !e.equals(p)) {
        z.setTarget((Player) e);
        break;
      }
    }

    return true;
  }
  private void throwIce() {
    if (!prepared) return;
    LivingEntity target =
        (LivingEntity) GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
    if (target == null) {
      destination =
          GeneralMethods.getTargetedLocation(player, range, EarthMethods.transparentToEarthbending);
    } else {
      destination = target.getEyeLocation();
    }

    location = sourceblock.getLocation();
    if (destination.distance(location) < 1) return;
    firstdestination = location.clone();
    if (destination.getY() - location.getY() > 2) {
      firstdestination.setY(destination.getY() - 1);
    } else {
      firstdestination.add(0, 2, 0);
    }
    destination = GeneralMethods.getPointOnLine(firstdestination, destination, range);
    progressing = true;
    settingup = true;
    prepared = false;

    new TempBlock(sourceblock, Material.AIR, (byte) 0);

    source = new TempBlock(sourceblock, Material.PACKED_ICE, data);
  }
Exemple #10
0
  /**
   * Set the values, all constructors uses this function
   *
   * @param loc location of the view
   * @param maxDistance how far it checks for blocks
   * @param viewHeight where the view is positioned in y-axis
   * @param checkDistance how often to check for blocks, the smaller the more precise
   */
  private void setValues(
      Location loc,
      int maxDistance,
      double viewHeight,
      double checkDistance,
      TIntHashSet transparent) {
    this.maxDistance = maxDistance;
    this.checkDistance = checkDistance;
    curDistance = 0;
    int xRotation = (int) (loc.getYaw() + 90) % 360;
    int yRotation = (int) loc.getPitch() * -1;

    double h = checkDistance * Math.cos(Math.toRadians(yRotation));

    offset =
        new Vector(
            (h * Math.cos(Math.toRadians(xRotation))),
            (checkDistance * Math.sin(Math.toRadians(yRotation))),
            (h * Math.sin(Math.toRadians(xRotation))));

    targetPosDouble = loc.add(0, viewHeight, 0).toVector();
    targetPos = targetPosDouble.toBlockVector();
    prevPos = targetPos;
    transparentBlocks = transparent;
    if (transparentBlocks == null) {
      transparentBlocks = new TIntHashSet(new int[] {0});
    }
  }
Exemple #11
0
  private boolean moveEarth() {
    progress++;
    Block affectedblock = location.clone().add(direction).getBlock();
    location = location.add(direction);
    if (GeneralMethods.isRegionProtectedFromBuild(player, "IceSpike", location)) return false;
    for (Entity en : GeneralMethods.getEntitiesAroundPoint(location, 1.4)) {
      if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) {
        LivingEntity le = (LivingEntity) en;
        affect(le);
        // le.setVelocity(thrown);
        // le.damage(damage);
        // damaged.add(le);
        // Methods.verbose(damage + " Hp:" + le.getHealth());
      }
    }
    affectedblock.setType(Material.ICE);
    WaterMethods.playIcebendingSound(block.getLocation());
    loadAffectedBlocks();

    if (location.distance(origin) >= height) {
      return false;
    }

    return true;
  }
 @EventHandler(priority = EventPriority.LOWEST)
 public void PlayerEvent(PlayerBucketEmptyEvent e) {
   if (!plugin.isProtected()) return;
   Location check = e.getPlayer().getTargetBlock(null, 100).getLocation();
   check.add(0, 1, 0);
   if (plugin.checkBoxLarge(check)) e.setCancelled(true);
 }
Exemple #13
0
  private void calculateRay(int ox, int oy, int oz, Collection<BlockVector> result) {
    double x = ox / 7.5 - 1;
    double y = oy / 7.5 - 1;
    double z = oz / 7.5 - 1;
    Vector direction = new Vector(x, y, z);
    direction.normalize();
    direction.multiply(0.3f); // 0.3 blocks away with each step

    Location current = location.clone();

    float currentPower = calculateStartPower();

    while (currentPower > 0) {
      GlowBlock block = world.getBlockAt(current);

      if (block.getType() != Material.AIR) {
        double blastDurability = getBlastDurability(block) / 5d;
        blastDurability += 0.3F;
        blastDurability *= 0.3F;
        currentPower -= blastDurability;

        if (currentPower > 0) {
          result.add(new BlockVector(block.getX(), block.getY(), block.getZ()));
        }
      }

      current.add(direction);
      currentPower -= 0.225f;
    }
  }
Exemple #14
0
 @Override
 public void run() {
   for (Player player : activePlayers.toArray(new Player[0])) {
     Location l = player.getLocation();
     l.add(0, 5, 0);
     player.getWorld().strikeLightningEffect(l);
   }
 }
Exemple #15
0
  public UpgradeTask(Player player, Weapon weapon) {
    this.player = player;
    this.zplayer = new ZPlayer(player);
    this.weapon = weapon;

    this.item = Utils.getWorld().dropItem(loc.add(0.5, 3, 0.5), weapon.getItemStack());
    this.item.setVelocity(new Vector(0.0D, 0.1D, 0.0D));
    this.item.setPickupDelay(1000);
  }
Exemple #16
0
 public boolean revertblocks() {
   Vector direction = new Vector(0, -1, 0);
   location
       .getBlock()
       .setType(Material.AIR); // .clone().add(direction).getBlock().setType(Material.AIR);
   location.add(direction);
   if (blockIsBase(location.getBlock())) return false;
   return true;
 }
  public static void setOwnerSign(final World world, final AthionPlot plot) {
    final Location pillar =
        new Location(
            world,
            bottomX(plot.id, world) - 1,
            getMap(world).RoadHeight + 1,
            bottomZ(plot.id, world) - 1);

    final Block bsign = pillar.add(0, 0, -1).getBlock();
    final Block redlight = pillar.add(0, -1, 0).getBlock();
    final Block redtorch = pillar.add(0, -2, 0).getBlock();
    bsign.setType(Material.AIR);
    redlight.setType(Material.REDSTONE_LAMP_ON);
    redtorch.setType(Material.REDSTONE_TORCH_ON);
    ;
    bsign.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);

    final String id =
        getPlotID(new Location(world, bottomX(plot.id, world), 0, bottomZ(plot.id, world)));

    final Sign sign = (Sign) bsign.getState();
    if (("Plot: " + ChatColor.DARK_GRAY + id).length() > 16) {
      sign.setLine(0, ("Plot: " + ChatColor.DARK_GRAY + id).substring(0, 16));
      if (("Plot: " + ChatColor.DARK_GRAY + id).length() > 32) {
        sign.setLine(1, ("Plot: " + ChatColor.DARK_GRAY + id).substring(16, 32));
      } else {
        sign.setLine(1, ("Plot: " + ChatColor.DARK_GRAY + id).substring(16));
      }
    } else {
      sign.setLine(0, "Plot: " + ChatColor.DARK_GRAY + id);
    }
    if (("By: " + ChatColor.DARK_GRAY + plot.owner).length() > 16) {
      sign.setLine(2, ("By: " + ChatColor.DARK_GRAY + plot.owner).substring(0, 16));
      if (("By: " + ChatColor.DARK_GRAY + plot.owner).length() > 32) {
        sign.setLine(3, ("By: " + ChatColor.DARK_GRAY + plot.owner).substring(16, 32));
      } else {
        sign.setLine(3, ("By: " + ChatColor.DARK_GRAY + plot.owner).substring(16));
      }
    } else {
      sign.setLine(2, "By: " + ChatColor.DARK_GRAY + plot.owner);
      sign.setLine(3, "");
    }
    sign.update(true);
  }
Exemple #18
0
  /**
   * Checks if the given location is inside the given squared border.
   *
   * @param location The location to be checked.
   * @param diameter The "diameter" of the squared wall (i.e. the size of a side of the wall).
   * @return true if the location is inside the border.
   */
  private boolean isInsideSquaredBorder(Location location, int diameter) {
    Integer halfMapSize = (int) Math.floor(diameter / 2);
    Integer x = location.getBlockX();
    Integer z = location.getBlockZ();

    Location spawn = location.getWorld().getSpawnLocation();
    Integer limitXInf = spawn.add(-halfMapSize, 0, 0).getBlockX();

    spawn = location.getWorld().getSpawnLocation();
    Integer limitXSup = spawn.add(halfMapSize, 0, 0).getBlockX();

    spawn = location.getWorld().getSpawnLocation();
    Integer limitZInf = spawn.add(0, 0, -halfMapSize).getBlockZ();

    spawn = location.getWorld().getSpawnLocation();
    Integer limitZSup = spawn.add(0, 0, halfMapSize).getBlockZ();

    return !(x < limitXInf || x > limitXSup || z < limitZInf || z > limitZSup);
  }
  private static Location getCloserBlock(Location source, Location blockA, Location blockB) {
    // If B wasn't given, return a.
    if (blockB == null) {
      return blockA;
    }
    // Center our calculations
    blockA.add(.5, 0, .5);
    blockB.add(.5, 0, .5);

    // Retrieve the distance to the normalized blocks
    double testA = source.distance(blockA);
    double testB = source.distance(blockB);

    // Compare and return
    if (testA <= testB) {
      return blockA;
    }
    return blockB;
  }
 private PersistableLocation initH8Corner(Location a1) {
   Location h8 = new Location(a1.getWorld(), a1.getBlockX(), a1.getBlockY(), a1.getBlockZ());
   int size = boardStyle.getSquareSize();
   switch (rotation) {
     case NORTH:
       h8.add(-size * 8 + 1, 0, -size * 8 + 1);
       break;
     case EAST:
       h8.add(size * 8 - 1, 0, -size * 8 + 1);
       break;
     case SOUTH:
       h8.add(size * 8 - 1, 0, size * 8 - 1);
       break;
     case WEST:
       h8.add(-size * 8 + 1, 0, size * 8 - 1);
       break;
   }
   return new PersistableLocation(h8);
 }
 @Override
 public void onRun() {
   Location location = getLocation();
   for (int i = 0; i < particles; i++) {
     Vector vector = RandomUtils.getRandomVector().multiply(radius);
     if (!sphere) vector.setY(Math.abs(vector.getY()));
     location.add(vector);
     particle.display(location, visibleRange);
     location.subtract(vector);
   }
 }
  @Override
  public SkillResult use(Hero hero, String[] args) {

    targets.clear();

    Location nxt = hero.getPlayer().getLocation();
    nxt = nxt.add(0, 1.4, 0);
    wave(this, hero, nxt, 0, hero.getPlayer().getLocation().getDirection());

    return SkillResult.NORMAL;
  }
 private PersistableLocation initA1Corner(Location origin, BoardRotation rotation) {
   Location a1 =
       new Location(origin.getWorld(), origin.getBlockX(), origin.getBlockY(), origin.getBlockZ());
   int offset = boardStyle.getSquareSize() / 2;
   switch (rotation) {
     case NORTH:
       a1.add(offset, 0, offset);
       break;
     case EAST:
       a1.add(-offset, 0, offset);
       break;
     case SOUTH:
       a1.add(-offset, 0, -offset);
       break;
     case WEST:
       a1.add(offset, 0, -offset);
       break;
   }
   return new PersistableLocation(a1);
 }
Exemple #24
0
  public static Location getRandomPlayerLocation(Player player, int randomMaxLen) {
    Location ret = getRandomPlayerLocation(player);

    int dx = getRandomDelta(randomMaxLen);
    int dy = getRandomDelta(randomMaxLen);
    int dz = getRandomDelta(randomMaxLen);

    ret.add(dx, dy, dz);

    return ret;
  }
Exemple #25
0
 public static Block GetLowestBlock(Location Loc) {
   Location loc = Loc.clone();
   Block Use = loc.getWorld().getBlockAt(loc);
   if (isBlockSolid(Use) || Use.isLiquid()) {
     return Use;
   } else {
     while (!isBlockSolid(Use) && !Use.isLiquid() && loc.getBlockY() > 0) {
       Use = loc.getWorld().getBlockAt(loc.add(0, -1, 0));
     }
     return loc.getWorld().getBlockAt(loc);
   }
 }
  private boolean moveEarth() {
    Block block = location.getBlock();
    location = location.add(direction);
    EarthMethods.moveEarth(player, block, direction, distance);
    loadAffectedBlocks();

    if (location.distance(origin) >= distance) {
      return false;
    }

    return true;
  }
Exemple #27
0
  @EventHandler
  public void LocationUpdater(UpdateEvent event) {
    if (event.getType() == UpdateType.TICK) {
      for (Player p : EffectManager.effect3.keySet()) {
        if (EffectManager.getEffect(p) == EffectManager.EffectType.HourGlass) {
          if (p.isValid()) {
            if (ExtraManager.isMoving(p)) {
              Location location = p.getLocation();

              Vector vector = new Vector();

              for (int i = 0; i < this.particlesPerIteration; i++) {
                this.step += 1;

                float t = 3.141593F / this.particles * this.step;
                float r =
                    MathUtils.sin(t * 2.718282F * this.particlesPerIteration / this.particles)
                        * this.size;
                float s = r * 3.141593F * t;

                vector.setX(this.xFactor * r * -MathUtils.cos(s));
                vector.setZ(this.zFactor * r * -MathUtils.sin(s));
                vector.setY(this.yFactor * r + this.yOffset + 2.0F);

                UtilVector.rotateVector(vector, this.xRotation, this.yRotation, this.zRotation);
                ParticleLib18 ench =
                    new ParticleLib18(
                        com.lightcraftmc.particles18.ParticleLib18.ParticleType.ENCHANTMENT_TABLE,
                        0.0D,
                        1,
                        0.0D);
                ench.sendToLocation(location.add(vector));

                location.subtract(vector);
              }

            } else if (!p.isInsideVehicle()) {
              ParticleLib18 ench2 =
                  new ParticleLib18(
                      com.lightcraftmc.particles18.ParticleLib18.ParticleType.ENCHANTMENT_TABLE,
                      0.1000000014901161D,
                      4,
                      0.300000011920929D);
              ench2.sendToLocation(p.getLocation().add(0.0D, 1.0D, 0.0D));
            }
          }
        }
      }
    }
  }
  private void spinScooter() {
    Location origin = player.getLocation().clone();
    origin.add(0, -radius, 0);

    for (int i = 0; i < 5; i++) {
      double x = Math.cos(Math.toRadians(angles.get(i))) * radius;
      double y = ((double) i) / 2 * radius - radius;
      double z = Math.sin(Math.toRadians(angles.get(i))) * radius;
      playAirbendingParticles(origin.clone().add(x, y, z), 7);
    }
    for (int i = 0; i < 5; i++) {
      angles.set(i, angles.get(i) + 10);
    }
  }
Exemple #29
0
  public void onRun() {
    Location location = getLocation();
    // Lines
    int mL = RandomUtils.random.nextInt(maxLines - 2) + 2;
    for (int m = 0; m < mL * 2; m++) {
      double x = RandomUtils.random.nextInt(max - max * (-1)) + max * (-1);
      double y = RandomUtils.random.nextInt(max - max * (-1)) + max * (-1);
      double z = RandomUtils.random.nextInt(max - max * (-1)) + max * (-1);
      if (direction == Direction.DOWN) y = RandomUtils.random.nextInt(max * 2 - max) + max;
      else if (direction == Direction.UP)
        y = RandomUtils.random.nextInt(max * (-1) - max * (-2)) + max * (-2);
      Location target = location.clone().subtract(x, y, z);
      if (target == null) {
        cancel();
        return;
      }
      Vector link = target.toVector().subtract(location.toVector());
      float length = (float) link.length();
      link.normalize();

      float ratio = length / lineParticles;
      Vector v = link.multiply(ratio);
      Location loc = location.clone().subtract(v);
      for (int i = 0; i < lineParticles; i++) {
        loc.add(v);
        display(lineParticle, loc, lineColor);
      }
    }

    // Sphere
    for (int i = 0; i < sphereParticles; i++) {
      Vector vector = RandomUtils.getRandomVector().multiply(sphereRadius);
      location.add(vector);
      display(sphereParticle, location, sphereColor);
      location.subtract(vector);
    }
  }
Exemple #30
0
  public static void smartLogFallables(Consumer consumer, String playerName, Block origin) {

    WorldConfig wcfg = getWorldConfig(origin.getWorld());
    if (wcfg == null) return;

    // Handle falling blocks
    Block checkBlock = origin.getRelative(BlockFace.UP);
    int up = 0;
    final int highestBlock = checkBlock.getWorld().getHighestBlockYAt(checkBlock.getLocation());
    while (BukkitUtils.getRelativeTopFallables().contains(checkBlock.getType())) {

      // Record this block as falling
      consumer.queueBlockBreak(playerName, checkBlock.getState());

      // Guess where the block is going (This could be thrown of by explosions, but it is better
      // than nothing)
      Location loc = origin.getLocation();
      int x = loc.getBlockX();
      int y = loc.getBlockY();
      int z = loc.getBlockZ();
      while (y > 0 && BukkitUtils.canFall(loc.getWorld(), x, (y - 1), z)) {
        y--;
      }
      // If y is 0 then the sand block fell out of the world :(
      if (y != 0) {
        Location finalLoc = new Location(loc.getWorld(), x, y, z);
        // Run this check to avoid false positives
        if (!BukkitUtils.getFallingEntityKillers().contains(finalLoc.getBlock().getType())) {
          finalLoc.add(0, up, 0); // Add this here after checking for block breakers
          if (finalLoc.getBlock().getType() == Material.AIR
              || BukkitUtils.getRelativeTopFallables().contains(finalLoc.getBlock().getType())) {
            consumer.queueBlockPlace(
                playerName, finalLoc, checkBlock.getTypeId(), checkBlock.getData());
          } else {
            consumer.queueBlockReplace(
                playerName,
                finalLoc,
                finalLoc.getBlock().getTypeId(),
                finalLoc.getBlock().getData(),
                checkBlock.getTypeId(),
                checkBlock.getData());
          }
          up++;
        }
      }
      if (checkBlock.getY() >= highestBlock) break;
      checkBlock = checkBlock.getRelative(BlockFace.UP);
    }
  }