Skip to content

Instantly share code, notes, and snippets.

@tomocrafter
Last active April 4, 2017 11:45
Show Gist options
  • Save tomocrafter/ad0b4a441729f7182098eae76b3088fa to your computer and use it in GitHub Desktop.
Save tomocrafter/ad0b4a441729f7182098eae76b3088fa to your computer and use it in GitHub Desktop.
<?php
const CURRENT_PROTOCOL = 46;
const ACCEPTED_PROTOCOLS = [45, 46];
const LOGIN_PACKET = 0x8f;
const PLAY_STATUS_PACKET = 0x90;
const DISCONNECT_PACKET = 0x91;
const BATCH_PACKET = 0x92;
const TEXT_PACKET = 0x93;
const SET_TIME_PACKET = 0x94;
const START_GAME_PACKET = 0x95;
const ADD_PLAYER_PACKET = 0x96;
const REMOVE_PLAYER_PACKET = 0x97;
const ADD_ENTITY_PACKET = 0x98;
const REMOVE_ENTITY_PACKET = 0x99;
const ADD_ITEM_ENTITY_PACKET = 0x9a;
const TAKE_ITEM_ENTITY_PACKET = 0x9b;
const MOVE_ENTITY_PACKET = 0x9c;
const MOVE_PLAYER_PACKET = 0x9d;
const REMOVE_BLOCK_PACKET = 0x9e;
const UPDATE_BLOCK_PACKET = 0x9f;
const ADD_PAINTING_PACKET = 0xa0;
const EXPLODE_PACKET = 0xa1;
const LEVEL_EVENT_PACKET = 0xa2;
const BLOCK_EVENT_PACKET = 0xa3;
const ENTITY_EVENT_PACKET = 0xa4;
const MOB_EFFECT_PACKET = 0xa5;
const UPDATE_ATTRIBUTES_PACKET = 0xa6;
const MOB_EQUIPMENT_PACKET = 0xa7;
const MOB_ARMOR_EQUIPMENT_PACKET = 0xa8;
const INTERACT_PACKET = 0xa9;
const USE_ITEM_PACKET = 0xaa;
const PLAYER_ACTION_PACKET = 0xab;
const HURT_ARMOR_PACKET = 0xac;
const SET_ENTITY_DATA_PACKET = 0xad;
const SET_ENTITY_MOTION_PACKET = 0xae;
const SET_ENTITY_LINK_PACKET = 0xaf;
const SET_HEALTH_PACKET = 0xb0;
const SET_SPAWN_POSITION_PACKET = 0xb1;
const ANIMATE_PACKET = 0xb2;
const RESPAWN_PACKET = 0xb3;
const DROP_ITEM_PACKET = 0xb4;
const CONTAINER_OPEN_PACKET = 0xb5;
const CONTAINER_CLOSE_PACKET = 0xb6;
const CONTAINER_SET_SLOT_PACKET = 0xb7;
const CONTAINER_SET_DATA_PACKET = 0xb8;
const CONTAINER_SET_CONTENT_PACKET = 0xb9;
const CRAFTING_DATA_PACKET = 0xba;
const CRAFTING_EVENT_PACKET = 0xbb;
const ADVENTURE_SETTINGS_PACKET = 0xbc;
const BLOCK_ENTITY_DATA_PACKET = 0xbd;
const PLAYER_INPUT_PACKET = 0xbe;
const FULL_CHUNK_DATA_PACKET = 0xbf;
const SET_DIFFICULTY_PACKET = 0xc0;
const CHANGE_DIMENSION_PACKET = 0xc1;
const SET_PLAYER_GAMETYPE_PACKET = 0xc2;
const PLAYER_LIST_PACKET = 0xc3;
//const TELEMETRY_EVENT_PACKET = 0xc4;
//const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5;
//const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0xc6;
//const MAP_INFO_REQUEST_PACKET = 0xc7;
const REQUEST_CHUNK_RADIUS_PACKET = 0xc8;
const CHUNK_RADIUS_UPDATE_PACKET = 0xc9;
const ITEM_FRAME_DROP_ITEM_PACKET = 0xca;
//const REPLACE_SELECTED_ITEM_PACKET = 0xcb;
echo "<pre>";
foreach(get_defined_constants(true)["user"] as $key => $value){
echo "const " . $key . " = ";
if(is_array($value)){
echo "[";
loop($value);
echo "]";
}else{
print_r($value);
}
echo ";\n";
}
echo "</pre>";
function loop($value, $i = 0){
if(is_array($value) && $value !== []){
print_r(array_shift($value));
if($i % 2 === 0){
echo ", ";
}
}else{
return;
}
loop($value, $i+1);
return;
}
//64bit centos linux でためしたばあい、以下の様な数値になった。
/*
[CURRENT_PROTOCOL] => 46
[ACCEPTED_PROTOCOLS] => [45, 46]
[LOGIN_PACKET] => 143
[PLAY_STATUS_PACKET] => 144
[DISCONNECT_PACKET] => 145
[BATCH_PACKET] => 146
[TEXT_PACKET] => 147
[SET_TIME_PACKET] => 148
[START_GAME_PACKET] => 149
[ADD_PLAYER_PACKET] => 150
[REMOVE_PLAYER_PACKET] => 151
[ADD_ENTITY_PACKET] => 152
[REMOVE_ENTITY_PACKET] => 153
[ADD_ITEM_ENTITY_PACKET] => 154
[TAKE_ITEM_ENTITY_PACKET] => 155
[MOVE_ENTITY_PACKET] => 156
[MOVE_PLAYER_PACKET] => 157
[REMOVE_BLOCK_PACKET] => 158
[UPDATE_BLOCK_PACKET] => 159
[ADD_PAINTING_PACKET] => 160
[EXPLODE_PACKET] => 161
[LEVEL_EVENT_PACKET] => 162
[BLOCK_EVENT_PACKET] => 163
[ENTITY_EVENT_PACKET] => 164
[MOB_EFFECT_PACKET] => 165
[UPDATE_ATTRIBUTES_PACKET] => 166
[MOB_EQUIPMENT_PACKET] => 167
[MOB_ARMOR_EQUIPMENT_PACKET] => 168
[INTERACT_PACKET] => 169
[USE_ITEM_PACKET] => 170
[PLAYER_ACTION_PACKET] => 171
[HURT_ARMOR_PACKET] => 172
[SET_ENTITY_DATA_PACKET] => 173
[SET_ENTITY_MOTION_PACKET] => 174
[SET_ENTITY_LINK_PACKET] => 175
[SET_HEALTH_PACKET] => 176
[SET_SPAWN_POSITION_PACKET] => 177
[ANIMATE_PACKET] => 178
[RESPAWN_PACKET] => 179
[DROP_ITEM_PACKET] => 180
[CONTAINER_OPEN_PACKET] => 181
[CONTAINER_CLOSE_PACKET] => 182
[CONTAINER_SET_SLOT_PACKET] => 183
[CONTAINER_SET_DATA_PACKET] => 184
[CONTAINER_SET_CONTENT_PACKET] => 185
[CRAFTING_DATA_PACKET] => 186
[CRAFTING_EVENT_PACKET] => 187
[ADVENTURE_SETTINGS_PACKET] => 188
[BLOCK_ENTITY_DATA_PACKET] => 189
[PLAYER_INPUT_PACKET] => 190
[FULL_CHUNK_DATA_PACKET] => 191
[SET_DIFFICULTY_PACKET] => 192
[CHANGE_DIMENSION_PACKET] => 193
[SET_PLAYER_GAMETYPE_PACKET] => 194
[PLAYER_LIST_PACKET] => 195
[REQUEST_CHUNK_RADIUS_PACKET] => 200
[CHUNK_RADIUS_UPDATE_PACKET] => 201
[ITEM_FRAME_DROP_ITEM_PACKET] => 202
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment