Skip to content

Instantly share code, notes, and snippets.

@TkTech
Created September 10, 2010 00:30
Show Gist options
  • Save TkTech/572830 to your computer and use it in GitHub Desktop.
Save TkTech/572830 to your computer and use it in GitHub Desktop.
# Table of types for packet definitions as well as their size
smp_fields = {
# Standard types
'byte' : ['b', 1],
'bool' : ['?', 1],
'short' : ['h', 2],
'int' : ['i', 4],
'float' : ['f', 4],
'double' : ['d', 8],
'long' : ['q', 8],
# Special types
'string' : ['h', 2],
'barray' : ['i', 4],
'sbarray' : ['h', 2]
}
# Table of packet definitions
smp_packets = {
# Misc. packets that don't really fit into any other category
0x00 : ['misc_ping', []],
0x01 : ['misc_login', ['int', 'string', 'string']],
0x02 : ['misc_handshake', ['string']],
0x03 : ['misc_chat', ['string']],
0x04 : ['misc_time', ['long']],
# Player-related packets
0x0A : ['player_flying', ['bool']],
0x0B : ['player_position', ['double', 'double', 'double', 'double', 'bool']],
0x0C : ['player_rotation', ['float', 'float', 'bool']],
0x0D : ['player_update', ['double', 'double', 'double', 'double', 'float', 'float', 'bool']],
0x0E : ['player_digging', ['byte', 'int', 'byte', 'int', 'byte']],
0x0F : ['player_block', ['short', 'int', 'byte', 'int', 'byte']],
0x10 : ['player_item', ['int', 'short']],
0x11 : ['player_add', ['short', 'byte', 'short']],
0x12 : ['player_arm', ['int', 'byte']],
# Entity-related packets
0x14 : ['entity_add_named', ['int', 'string', 'int', 'int', 'int', 'byte', 'byte', 'short']],
0x15 : ['entity_spawn', ['int', 'short', 'byte', 'int', 'int', 'int', 'byte', 'byte', 'byte']],
0x16 : ['entity_pickup', ['int', 'int']],
0x17 : ['entity_unknown', ['int', 'byte', 'int', 'int', 'int']],
0x18 : ['entity_add_mob', ['int', 'byte', 'int', 'int', 'int', 'byte', 'byte']],
0x1D : ['entity_destroy', ['int']],
# Entity movement-related packets
0x1E : ['entity_subclass', ['int']],
0x1F : ['entity_move', ['int', 'byte', 'byte', 'byte']],
0x20 : ['entity_rotation', ['int', 'byte', 'byte']],
0x21 : ['entity_update', ['int', 'byte', 'byte', 'byte', 'byte', 'byte']],
0x22 : ['entity_position', ['int', 'int', 'int', 'int', 'byte', 'byte']],
0x32 : ['chunk_notice', ['int', 'int', 'bool']],
0x33 : ['chunk_data', ['int', 'short', 'int', 'byte', 'byte', 'byte', 'barray']],
0x34 : ['chunk_update', ['int', 'int', 'sbarray']],
0x35 : ['chunk_block', ['int', 'byte', 'int', 'byte', 'byte']],
# Kick/Disconnect
0xFF : ['misc_kick', ['string']]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment