Examples of AnyTag


Examples of se.llbit.nbt.AnyTag

      caves = CorruptLayer.INSTANCE;
    }
  }

  private byte[] extractBiomeData(@NotNull Map<String, AnyTag> data) {
    AnyTag biomesTag = data.get(LEVEL_BIOMES);
    if (biomesTag.isByteArray(X_MAX*Z_MAX)) {
      return biomesTag.byteArray();
    } else {
      return new byte[X_MAX*Z_MAX];
    }
  }
 
View Full Code Here

Examples of se.llbit.nbt.AnyTag

      return new byte[X_MAX*Z_MAX];
    }
  }

  private int[] extractHeightmapData(@NotNull Map<String, AnyTag> data) {
    AnyTag heightmapTag = data.get(LEVEL_HEIGHTMAP);
    if (heightmapTag.isIntArray(X_MAX*Z_MAX)) {
      return heightmapTag.intArray();
    } else {
      int[] fallback = new int[X_MAX*Z_MAX];
      for (int i = 0; i < fallback.length; ++i) {
        fallback[i] = Y_MAX-1;
      }
View Full Code Here

Examples of se.llbit.nbt.AnyTag

      return fallback;
    }
  }

  private void extractChunkData(@NotNull Map<String, AnyTag> data, @NotNull byte[] blocks, @NotNull byte[] blockData) {
    AnyTag sections = data.get(LEVEL_SECTIONS);
    if (sections.isList()) {
      for (SpecificTag section : ((ListTag) sections).getItemList()) {
        AnyTag yTag = section.get("Y");
        int yOffset = yTag.byteValue() & 0xFF;
        AnyTag blocksTag = section.get("Blocks");
        if (blocksTag.isByteArray(SECTION_BYTES)) {
          System.arraycopy(blocksTag.byteArray(), 0, blocks, SECTION_BYTES*yOffset, SECTION_BYTES);
        }
        AnyTag dataTag = section.get("Data");
        if (dataTag.isByteArray(SECTION_HALF_NIBBLES)) {
          System.arraycopy(dataTag.byteArray(), 0, blockData, SECTION_HALF_NIBBLES*yOffset, SECTION_HALF_NIBBLES);
        }
      }
    }
  }
View Full Code Here

Examples of se.llbit.nbt.AnyTag

    Set<String> request = new HashSet<String>();
    request.add(LEVEL_SECTIONS);
    request.add(LEVEL_BIOMES);
    Map<String, AnyTag> data = getChunkData(request);
    AnyTag sections = data.get(LEVEL_SECTIONS);
    AnyTag biomesTag = data.get(LEVEL_BIOMES);
    if (sections.isList() && biomesTag.isByteArray(X_MAX*Z_MAX)) {
      byte[] chunkBiomes = extractBiomeData(data);
      System.arraycopy(chunkBiomes, 0, biomes, 0, chunkBiomes.length);
      extractChunkData(data, blocks, blockData);
    }
  }
View Full Code Here

Examples of se.llbit.nbt.AnyTag

      surface = CorruptLayer.INSTANCE;
      return;
    }

    Heightmap heightmap = world.heightmap();
    AnyTag sections = data.get(LEVEL_SECTIONS);
    if (sections.isList()) {
      int[] heightmapData = extractHeightmapData(data);
      byte[] biomeData = extractBiomeData(data);
      byte[] chunkData = new byte[CHUNK_BYTES];
      byte[] blockData = new byte[CHUNK_BYTES];
      extractChunkData(data, chunkData, blockData);
View Full Code Here

Examples of se.llbit.nbt.AnyTag

    if (data == null) {
      layer = CorruptLayer.INSTANCE;
      return;
    }

    AnyTag sections = data.get(LEVEL_SECTIONS);
    if (sections.isList()) {
      byte[] biomeData = extractBiomeData(data);
      byte[] chunkData = new byte[CHUNK_BYTES];
      extractChunkData(data, chunkData, new byte[CHUNK_BYTES]);
      layer = new BlockLayer(chunkData, biomeData, requestedLayer);
    } else {
View Full Code Here

Examples of se.llbit.nbt.AnyTag

    if (data == null) {
      caves = CorruptLayer.INSTANCE;
      return;
    }

    AnyTag sections = data.get(LEVEL_SECTIONS);
    if (sections.isList()) {
      int[] heightmapData = extractHeightmapData(data);
      byte[] chunkData = new byte[CHUNK_BYTES];
      extractChunkData(data, chunkData, new byte[CHUNK_BYTES]);
      caves = new CaveLayer(chunkData, heightmapData);
    } else {
View Full Code Here

Examples of se.llbit.nbt.AnyTag

      request.add(".Data.Player.SpawnZ");
      request.add(".Data.LevelName");
      request.add(".Data.GameType");
      Map<String, AnyTag> result = NamedTag.quickParse(in, request);

      AnyTag dim = result.get(".Data.Player.Dimension");
      playerDimension = dim.intValue();

      AnyTag version = result.get(".Data.version");
      if (logWarnings && version.intValue() != NBT_VERSION) {
        logger.warn("The world format for the world " + levelName +
            " is not supported by Chunky.\n" +
            "Will attempt to load the world anyway.");
      }
      AnyTag posX = result.get(".Data.Player.Pos.0");
      AnyTag posY = result.get(".Data.Player.Pos.1");
      AnyTag posZ = result.get(".Data.Player.Pos.2");
      AnyTag yaw = result.get(".Data.Player.Rotation.0");
      AnyTag pitch = result.get(".Data.Player.Rotation.1");
      AnyTag spawnX = result.get(".Data.Player.SpawnX");
      AnyTag spawnY = result.get(".Data.Player.SpawnY");
      AnyTag spawnZ = result.get(".Data.Player.SpawnZ");
      AnyTag gameType = result.get(".Data.GameType");
      AnyTag randomSeed = result.get(".Data.RandomSeed");

      gameMode  = gameType.intValue(0);
      seed = randomSeed.longValue(0);

      playerX = posX.doubleValue();
      playerY = posY.doubleValue();
      playerZ = posZ.doubleValue();
      playerYaw = yaw.floatValue();
View Full Code Here

Examples of se.llbit.nbt.AnyTag

  public static void main(String[] args) {
    String fn = "test.chunk";
    try {
      System.out.println("parsing test.chunk");
      DataInputStream in = new DataInputStream(new GZIPInputStream(new FileInputStream(fn)));
      AnyTag tag = NamedTag.read(in);
      PrintStream out = new PrintStream(new File("output.test"));
      out.print(tag.dumpTree());
      out.close();
      System.out.println("done");
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

Examples of se.llbit.nbt.AnyTag

    String fn = args[0];
    Long seed = Long.parseLong(args[1]);
    try {
      System.out.println("loading save: "+fn);
      DataInputStream in = new DataInputStream(new GZIPInputStream(new FileInputStream(fn)));
      AnyTag tag = NamedTag.read(in);
      LongTag seedTag = (LongTag) tag.unpack().get("Data").get("RandomSeed");
      seedTag.setData(seed);
      DataOutputStream out = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(args[2])));
      tag.write(out);
      out.close();
      System.out.println("done");
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.