Advertisement
Guest User

Untitled

a guest
Nov 27th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
  2.        
  3. buf.writeInt(x);
  4. buf.writeShort(y);
  5. buf.writeInt(z);
  6. buf.writeByte(Chunk.WIDTH - 1);
  7. buf.writeByte(Chunk.HEIGHT - 1);
  8. buf.writeByte(Chunk.LENGTH - 1);
  9.        
  10. byte[] compressedData = new byte[(Chunk.WIDTH * Chunk.LENGTH * Chunk.HEIGHT * 5) / 2]; // 81,920
  11.        
  12. Deflater deflater = new Deflater(Deflater.BEST_SPEED);
  13. deflater.setInput(data);
  14. deflater.finish();
  15.        
  16. int compressed = deflater.deflate(compressedData);
  17. deflater.end();
  18.        
  19. buf.writeInt(compressed);
  20. buf.writeBytes(compressedData, 0, compressed);
  21.  
  22. return buf;
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement