Skip to content

Instantly share code, notes, and snippets.

@axus
axus / gist:841590
Created February 24, 2011 01:44
Minecraft 1.3 protocol
(0, 'jf')
(1, 'kx')
readInt
readUTF
readUTF
readLong
readByte
(2, 'ju')
readUTF
(3, 'lu')
@axus
axus / gist:718320
Created November 27, 2010 21:57
I'm in your world, zippin; your chunks
//Compress the packed byte_array to *compressed, set compressed_length
bool Chunk::zip()
{
//Delete old zip
if (zipped != NULL) { delete zipped; }
//Allocate more space for compressed than uncompressed, for header bytes
zipped_length = compressBound(byte_length);
zipped = new Bytef[ zipped_length ];
@axus
axus / gist:709032
Created November 21, 2010 19:06
Minecraft inventory packet parsing
//Update player inventory
size_t mcmm_client::getInventory(netpacket *pkt )
{
int32_t inv_type;
int16_t inv_count;
//Total length = 7 bytes + (4 shorts + health OR 36 shorts + health)
size_t packetsize = pkt->get_maxsize();
size_t minimumsize = SIZE_INVENTORY;