Package org.spout.api.geo.cuboid

Examples of org.spout.api.geo.cuboid.Chunk


  @Permissible ("vanilla.command.debug")
  @Filter (PlayerFilter.class)
  public void chunkLight(Player player, CommandArguments args) throws CommandException {
    args.assertCompletelyParsed();

    Chunk c = player.getChunk();
    if (c == null) {
      throw new CommandException("You are somenow in a null chunk. This is probably bad.");
    }
    LightingVerification.checkChunk(c, false);
  }
View Full Code Here


  @Permissible ("vanilla.command.debug")
  public void getBlock(CommandSource source, CommandArguments args) throws CommandException {
    Point p = args.popPoint("loc", source);
    args.assertCompletelyParsed();

    Chunk c = p.getChunk(LoadOption.NO_LOAD);
    if (c == null) {
      throw new CommandException("Chunk not loaded");
    }
    int blockState = c.getBlockFullState(p.getBlockX(), p.getBlockY(), p.getBlockZ());
    BlockMaterial m = BlockMaterial.get(blockState);
    source.sendMessage("Material at " + p.getBlockX() + ", " + p.getBlockY() + ", " + p.getBlockZ() + " is " + m.getClass().getSimpleName());
  }
View Full Code Here

        int serverCube = rm.getInverse().convertChunkY(cube);
        Point pp = new Point(c.getWorld(), x << Chunk.BLOCKS.BITS, serverCube << Chunk.BLOCKS.BITS, z << Chunk.BLOCKS.BITS);
        packetChunkData[cube] = chunkInit.getChunkData(heights, materials, pp, events);
      }

      Chunk chunk = p.getWorld().getChunkFromBlock(p, LoadOption.LOAD_ONLY);
      byte[] biomeData = new byte[Chunk.BLOCKS.AREA];
      for (int dx = x; dx < x + Chunk.BLOCKS.SIZE; ++dx) {
        for (int dz = z; dz < z + Chunk.BLOCKS.SIZE; ++dz) {
          Biome biome = chunk.getBiome(dx & Chunk.BLOCKS.MASK, 0, dz & Chunk.BLOCKS.MASK);
          if (biome instanceof VanillaBiome) {
            biomeData[(dz & Chunk.BLOCKS.MASK) << 4 | (dx & Chunk.BLOCKS.MASK)] = (byte) ((VanillaBiome) biome).getBiomeId();
          }
        }
      }
View Full Code Here

    int size = Region.CHUNKS.SIZE;
    ArrayList<Chunk> chunks = new ArrayList<Chunk>(size * size * size);
    for (int x = 0; x < size; x++) {
      for (int y = 0; y < size; y++) {
        for (int z = 0; z < size; z++) {
          Chunk c = r.getChunk(x, y, z, LoadOption.NO_LOAD);
          if (c != null) {
            chunks.add(c);
          }
        }
      }
View Full Code Here

    }
    return buffers;
  }

  private static VanillaCuboidLightBuffer getLightBuffer(World w, int cx, int cy, int cz, short id) {
    Chunk c = w.getChunk(cx, cy, cz, LoadOption.LOAD_ONLY);
    if (c == null) {
      return null;
    }
    return (VanillaCuboidLightBuffer) c.getLightBuffer(id);
  }
View Full Code Here

    }
    return buffers;
  }

  private static CuboidBlockMaterialBuffer getBlockMaterialBuffer(World w, int cx, int cy, int cz) {
    Chunk c = w.getChunk(cx, cy, cz, LoadOption.LOAD_ONLY);
    if (c == null) {
      return null;
    }
    return c.getCuboid(false);
  }
View Full Code Here

    return new IntVector3Array(xArray, yArray, zArray, count);
  }

  private int getBoundary(Chunk[] chunks, int count, int[] xArray, int[] yArray, int[] zArray, int startChunk, int endChunk) {

    Chunk first = chunks[startChunk];

    // Note: X and Z are sorted low to high and Y is sorted high to low

    int baseX = first.getX();
    int baseY = first.getY();
    int baseZ = first.getZ();

    int topX = first.getX();
    int topY = first.getY();
    int topZ = first.getZ();

    for (int i = startChunk + 1; i < endChunk; i++) {
      Chunk c = chunks[i];
      if (c.getX() < baseX) {
        baseX = c.getX();
      }
      if (c.getY() < baseY) {
        baseY = c.getY();
      }
      if (c.getZ() < baseZ) {
        baseZ = c.getZ();
      }
      if (c.getX() > topX) {
        topX = c.getX();
      }
      if (c.getY() > topY) {
        topY = c.getY();
      }
      if (c.getZ() > topZ) {
        topZ = c.getZ();
      }
    }

    topX++;
    topY++;
    topZ++;

    int sizeX = topX - baseX;
    int sizeY = topY - baseY;
    int sizeZ = topZ - baseZ;

    int volume = sizeX * sizeY * sizeZ;

    boolean fullCuboid = volume == endChunk - startChunk;

    Chunk[][][] cuboid = new Chunk[sizeX][sizeY][sizeZ];

    for (int i = startChunk; i < endChunk; i++) {
      Chunk c = chunks[i];
      int cx = c.getX() - baseX;
      int cy = c.getY() - baseY;
      int cz = c.getZ() - baseZ;

      if (cuboid[cx][cy][cz] == null) {
        cuboid[cx][cy][cz] = c;
      } else {
        throw new IllegalStateException("Chunks appears twice in list, " + cx + ", " + cy + ", " + cz);
      }
    }

    int baseBlockX = baseX << Chunk.BLOCKS.BITS;
    int baseBlockY = baseY << Chunk.BLOCKS.BITS;
    int baseBlockZ = baseZ << Chunk.BLOCKS.BITS;

    int topBlockX = topX << Chunk.BLOCKS.BITS;
    int topBlockY = topY << Chunk.BLOCKS.BITS;
    int topBlockZ = topZ << Chunk.BLOCKS.BITS;

    if (fullCuboid) {
      for (int x = baseBlockX; x < topBlockX; x++) {
        for (int y = baseBlockY; y < topBlockY; y++) {
          xArray[count] = x;
          yArray[count] = y;
          zArray[count] = baseBlockZ;
          count++;
          xArray[count] = x;
          yArray[count] = y;
          zArray[count] = topBlockZ - 1;
          count++;
        }
      }

      for (int x = baseBlockX; x < topBlockX; x++) {
        for (int z = baseBlockZ; z < topBlockZ; z++) {
          xArray[count] = x;
          yArray[count] = baseBlockY;
          zArray[count] = z;
          count++;
          xArray[count] = x;
          yArray[count] = topBlockY - 1;
          zArray[count] = z;
          count++;
        }
      }

      for (int z = baseBlockZ; z < topBlockZ; z++) {
        for (int y = baseBlockY; y < topBlockY; y++) {
          xArray[count] = baseBlockX;
          yArray[count] = y;
          zArray[count] = z;
          count++;
          xArray[count] = topBlockX - 1;
          yArray[count] = y;
          zArray[count] = z;
          count++;
        }
      }
    } else {
      int size = Chunk.BLOCKS.SIZE;
      for (int x = 0; x < sizeX; x++) {
        int wX = (baseX + x) << Chunk.BLOCKS.BITS;
        for (int z = 0; z < sizeZ; z++) {
          int wZ = (baseZ + z) << Chunk.BLOCKS.BITS;
          for (int y = sizeY - 1; y >= 0; y--) {
            Chunk c = cuboid[x][y][z];

            if (c == null) {
              continue;
            }

View Full Code Here

   *
   * @param middle chunk
   * @return list of chunks in the column
   */
  public static List<Chunk> getChunkColumn(Chunk middle) {
    Chunk top = middle;
    Chunk tmp;
    while (true) {
      tmp = top.getRelative(BlockFace.TOP, LoadOption.NO_LOAD);
      if (tmp != null && tmp.isLoaded()) {
        top = tmp;
      } else {
        break;
      }
    }
View Full Code Here

TOP

Related Classes of org.spout.api.geo.cuboid.Chunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.