@Override
  public void readData(DataInputStream in) throws IOException {
    x = in.readInt();
    z = in.readInt();
    biomes = in.readBoolean();
    bitmask = in.readShort();
    additionalBitmask = in.readShort();
    int tempLength = in.readInt();

    byte[] compressedChunkData = new byte[tempLength];
    in.readFully(compressedChunkData, 0, tempLength);
    int i = 0;

    for (int j = 0; j < 16; j++) i += bitmask >> j & 1;

    int k = 12288 * i;

    if (biomes) k += 256;

    chunkData = new byte[k];
    Inflater inflater = new Inflater();
    inflater.setInput(compressedChunkData, 0, tempLength);

    try {
      inflater.inflate(chunkData);
    } catch (DataFormatException dataformatexception) {
      chunkData = null;
    } catch (OutOfMemoryError error) {
      System.gc();
      try {
        inflater.end();

        inflater = new Inflater();
        inflater.setInput(compressedChunkData, 0, tempLength);

        inflater.inflate(chunkData);
      } catch (DataFormatException dataformatexception) {
        chunkData = null;
      } catch (OutOfMemoryError error2) {
        chunkData = null;
      }
    } finally {
      inflater.end();
    }
  }
Exemple #2
0
 public void write(byte b[], int off, int len) throws IOException {
   if (len == 0) return;
   if (compress) {
     dos.write(b, off, len);
   } else {
     inflater.setInput(b, off, len, true);
     int err = JZlib.Z_OK;
     while (inflater.avail_in > 0) {
       inflater.setOutput(buf, 0, buf.length);
       err = inflater.inflate(flush);
       if (inflater.next_out_index > 0) out.write(buf, 0, inflater.next_out_index);
       if (err != JZlib.Z_OK) break;
     }
     if (err != JZlib.Z_OK) throw new ZStreamException("inflating: " + inflater.msg);
     return;
   }
 }
  public void func_73267_a(DataInputStream p_73267_1_) throws IOException {
    short word0 = p_73267_1_.readShort();
    field_73585_g = p_73267_1_.readInt();
    field_73589_c = new int[word0];
    field_73586_d = new int[word0];
    field_73590_a = new int[word0];
    field_73588_b = new int[word0];
    field_73584_f = new byte[word0][];
    if (field_73591_h.length < field_73585_g) {
      field_73591_h = new byte[field_73585_g];
    }
    p_73267_1_.readFully(field_73591_h, 0, field_73585_g);
    byte abyte0[] = new byte[0x30100 * word0];
    Inflater inflater = new Inflater();
    inflater.setInput(field_73591_h, 0, field_73585_g);
    try {
      inflater.inflate(abyte0);
    } catch (DataFormatException dataformatexception) {
      throw new IOException("Bad compressed data format");
    } finally {
      inflater.end();
    }
    int i = 0;
    for (int j = 0; j < word0; j++) {
      field_73589_c[j] = p_73267_1_.readInt();
      field_73586_d[j] = p_73267_1_.readInt();
      field_73590_a[j] = p_73267_1_.readShort();
      field_73588_b[j] = p_73267_1_.readShort();
      int k = 0;
      for (int l = 0; l < 16; l++) {
        k += field_73590_a[j] >> l & 1;
      }

      int i1 = 2048 * (5 * k) + 256;
      field_73584_f[j] = new byte[i1];
      System.arraycopy(abyte0, i, field_73584_f[j], 0, i1);
      i += i1;
    }
  }