Exemple #1
0
        public Packet51MapChunk(int x, int y, int z, int xSize, int ySize, int zSize, net.minecraft.src.World world)
        {
            isChunkDataPacket = true;
            xPosition         = x;
            yPosition         = y;
            zPosition         = z;
            this.xSize        = xSize;
            this.ySize        = ySize;
            this.zSize        = zSize;
            byte[] abyte0 = world.GetChunkData(x, y, z, xSize, ySize, zSize);
            //java.util.zip.Deflater deflater = new java.util.zip.Deflater(-1);
            //try
            //{
            //	deflater.SetInput(abyte0);
            //	deflater.Finish();
            //	chunk = new byte[(l * i1 * j1 * 5) / 2];
            //	chunkSize = deflater.Deflate(chunk);
            //}
            //finally
            //{
            //	deflater.End();
            //}

            using (Compressor compressor = new LibDeflate.ZlibCompressor(abyte0.Length < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS))
            {
                chunk = compressor.Compress(abyte0, true);
                if (chunk == null)
                {
                    throw new System.Exception($"Chunk data was too small to effectively compress or some other error occurred??? (Size: {abyte0.Length})");
                }

                chunkSize = chunk.Length;
                //ms.CopyTo(ds);
                //ds.Flush();
                //chunk = output.ToArray();
                //chunkSize = chunk.Length;
            }
        }