Пример #1
0
  private void playOutExplosion(GlowPlayer player, Iterable<BlockVector> blocks) {
    Collection<ExplosionMessage.Record> records = new ArrayList<>();

    Location clientLoc = location.clone();
    clientLoc.setX((int) clientLoc.getX());
    clientLoc.setY((int) clientLoc.getY());
    clientLoc.setZ((int) clientLoc.getZ());

    for (BlockVector block : blocks) {
      byte x = (byte) (block.getBlockX() - clientLoc.getBlockX());
      byte y = (byte) (block.getBlockY() - clientLoc.getBlockY());
      byte z = (byte) (block.getBlockZ() - clientLoc.getBlockZ());
      records.add(new ExplosionMessage.Record(x, y, z));
    }

    Vector velocity = player.getVelocity();
    ExplosionMessage message =
        new ExplosionMessage(
            (float) location.getX(),
            (float) location.getY(),
            (float) location.getZ(),
            5,
            (float) velocity.getX(),
            (float) velocity.getY(),
            (float) velocity.getZ(),
            records);

    player.getSession().send(message);
  }
Пример #2
0
 public void setProperty(final String path, final Location loc) {
   set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
   set((path == null ? "" : path + ".") + "x", loc.getX());
   set((path == null ? "" : path + ".") + "y", loc.getY());
   set((path == null ? "" : path + ".") + "z", loc.getZ());
   set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
   set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
 }
Пример #3
0
  /**
   * Checks if the location is near a block in the list on the same layer.
   *
   * @param location the location
   * @param blocks the collection of blocks to search
   * @param radius the radius to search
   * @return boolean
   */
  public static boolean isLocationNearBlock(
      Location location, Collection<Integer> blocks, int radius) {
    World world = location.getWorld();
    int x = (int) location.getX(), y = (int) location.getY(), z = (int) location.getZ();

    for (int ox = radius; ox > -radius; ox--)
      for (int oz = radius; oz > -radius; oz--)
        if (blocks.contains(world.getBlockAt(x + ox, y, z + oz).getTypeId())) return false;
    return true;
  }