Package net.lightstone.model

Examples of net.lightstone.model.Chunk$Key


    validateQuery(query);
    validateSplitSize(numSplits);

    List<Query> splits = new ArrayList<Query>(numSplits);
    List<Key> scatterKeys = getScatterKeys(numSplits, query, datastore);
    Key lastKey = null;
    for (Key nextKey : getSplitKey(scatterKeys, numSplits)) {
      splits.add(createSplit(lastKey, nextKey, query));
      lastKey = nextKey;
    }
    splits.add(createSplit(lastKey, null, query));
View Full Code Here


    if (!region.hasChunk(regionX, regionZ)) {
      return null;
    }

    DataInputStream in = region.getChunkDataInputStream(regionX, regionZ);
    Chunk chunk = new Chunk(x, z);

    NBTInputStream nbt = new NBTInputStream(in, false);
    CompoundTag tag = (CompoundTag) nbt.readTag();
    Map<String, Tag> levelTags = ((CompoundTag) tag.getValue().get("Level")).getValue();

    byte[] tileData = ((ByteArrayTag) levelTags.get("Blocks")).getValue();
    chunk.setTypes(tileData);

    byte[] skyLightData = ((ByteArrayTag) levelTags.get("SkyLight")).getValue();
    byte[] blockLightData = ((ByteArrayTag) levelTags.get("BlockLight")).getValue();
    byte[] metaData = ((ByteArrayTag) levelTags.get("Data")).getValue();

    for (int cx = 0; cx < Chunk.WIDTH; cx++) {
      for (int cz = 0; cz < Chunk.HEIGHT; cz++) {
        for (int cy = 0; cy < Chunk.DEPTH; cy++) {
          boolean mostSignificantNibble = ((cx * Chunk.HEIGHT + cz) * Chunk.DEPTH + cy) % 2 == 1;
          int offset = ((cx * Chunk.HEIGHT + cz) * Chunk.DEPTH + cy) / 2;

          int skyLight, blockLight, meta;
          if (mostSignificantNibble) {
            skyLight = (skyLightData[offset] & 0xF0) >> 4;
            blockLight = (blockLightData[offset] & 0xF0) >> 4;
            meta = (metaData[offset] & 0xF0) >> 4;
          } else {
            skyLight = skyLightData[offset] & 0x0F;
            blockLight = blockLightData[offset] & 0x0F;
            meta = metaData[offset] & 0x0F;
          }

          chunk.setSkyLight(cx, cz, cy, skyLight);
          chunk.setBlockLight(cx, cz, cy, blockLight);
          chunk.setMetaData(cx, cz, cy, meta);
        }
      }
    }
    nbt.close();
    return chunk;
View Full Code Here

  private Random random = new Random();

  @Override
  public Chunk generate(int chunkX, int chunkZ) {
    Chunk chunk = super.generate(chunkX, chunkZ);

    int numTrees = random.nextInt(MAX_TREES + 1);
    for (int i = 0; i < numTrees; i++) {
      int x = random.nextInt(Chunk.WIDTH - (TREE_CANOPY_WIDTH * 2) + TREE_CANOPY_WIDTH);
      int z = random.nextInt(Chunk.HEIGHT- (TREE_CANOPY_WIDTH * 2) + TREE_CANOPY_WIDTH);
View Full Code Here

      int chunkZ = z / Chunk.HEIGHT + ((z < 0 && z % Chunk.HEIGHT != 0) ? -1 : 0);

      int localX = (x - chunkX * Chunk.WIDTH) % Chunk.WIDTH;
      int localZ = (z - chunkZ * Chunk.HEIGHT) % Chunk.HEIGHT;

      Chunk chunk = world.getChunks().getChunk(chunkX, chunkZ);
      int oldType = chunk.getType(localX, localZ, y);
      chunk.setType(localX, localZ, y, Blocks.TYPE_AIR);

      // TODO this should also be somewhere else as well... perhaps in the chunk.setType() method itself?
      BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, 0, 0);
      SoundEffectMessage soundMsg = new SoundEffectMessage(SoundEffectMessage.DIG_SOUND, x, y, z, oldType);
      for (Player p: world.getPlayers()) {
View Full Code Here

*/
public class FlatGrassWorldGenerator implements WorldGenerator {

  @Override
  public Chunk generate(int chunkX, int chunkZ) {
    Chunk chunk = new Chunk(chunkX, chunkZ);
    for (int x = 0; x < Chunk.WIDTH; x++) {
      for (int z = 0; z < Chunk.HEIGHT; z++) {
        for (int y = 0; y < Chunk.DEPTH; y++) {
          int id = 0;
          if (y == 60)
            id = 2;
          else if (y >= 55 && y < 60)
            id = 3;
          else if (y == 0)
            id = 7; //Bedrock
          else if (y < 55)
            id = 1;

          chunk.setType(x, z, y, id);
          chunk.setMetaData(x, z, y, 0);
          chunk.setBlockLight(x, z, y, 0);
          chunk.setSkyLight(x, z, y, 15);
        }
      }
    }
    return chunk;
  }
View Full Code Here

   * Tests the {@link FlatGrassWorldGenerator#generate(int, int)} method.
   */
  @Test
  public void testGenerate() {
    WorldGenerator generator = new FlatGrassWorldGenerator();
    Chunk chunk = generator.generate(17, 5);

    for (int x = 0; x < Chunk.WIDTH; x++) {
      for (int z = 0; z < Chunk.HEIGHT; z++) {
        assertEquals(2, chunk.getType(x, z, 60));

        assertEquals(7, chunk.getType(x, z, 0));

        for (int y = 1; y < 55; y++)
          assertEquals(1, chunk.getType(x, z, y));

        for (int y = 55; y < 60; y++)
          assertEquals(3, chunk.getType(x, z, y));

        for (int y = 61; y < Chunk.HEIGHT; y++)
          assertEquals(0, chunk.getType(x, z, y));
      }
    }
  }
View Full Code Here

TOP

Related Classes of net.lightstone.model.Chunk$Key

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.