PageRenderTime 292ms CodeModel.GetById 26ms RepoModel.GetById 147ms app.codeStats 0ms

/src/classes/CustomPacketHandler.class.php

https://github.com/domanicYL/PocketMine-MP
PHP | 555 lines | 517 code | 6 blank | 32 comment | 43 complexity | 6aa886dcb26ee548efe61dd7cc7053b6 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /*
  3. -
  4. / \
  5. / \
  6. / PocketMine \
  7. / MP \
  8. |\ @shoghicp /|
  9. |. \ / .|
  10. | .. \ / .. |
  11. | .. | .. |
  12. | .. | .. |
  13. \ | /
  14. \ | /
  15. \ | /
  16. \ | /
  17. This program is free software: you can redistribute it and/or modify
  18. it under the terms of the GNU Lesser General Public License as published by
  19. the Free Software Foundation, either version 3 of the License, or
  20. (at your option) any later version.
  21. */
  22. class CustomPacketHandler{
  23. var $offset, $raw, $c, $data, $name = "";
  24. private function get($len = true, $check = true){
  25. if($len === true){
  26. $data = substr($this->raw, $this->offset);
  27. if($check === true){
  28. $this->offset = strlen($this->raw);
  29. }
  30. return $data;
  31. }
  32. $data = substr($this->raw, $this->offset, $len);
  33. if($check === true){
  34. $this->offset += $len;
  35. }
  36. return $data;
  37. }
  38. public function __construct($pid, $raw = "", $data = array(), $create = false){
  39. $this->raw = $raw;
  40. $this->data = $data;
  41. $this->offset = 0;
  42. $this->c = (bool) $create;
  43. switch($pid){
  44. case MC_KEEP_ALIVE:
  45. if($this->c === false){
  46. $this->data["payload"] = Utils::readLong($this->get(8));
  47. }else{
  48. $this->raw .= Utils::writeLong($this->data["payload"]);
  49. }
  50. break;
  51. case 0x03:
  52. if($this->c === false){
  53. $this->data["unknown1"] = Utils::readLong($this->get(8));
  54. $this->data["unknown2"] = Utils::readLong($this->get(8));
  55. }else{
  56. $this->raw .= Utils::writeLong($this->data["unknown1"]);
  57. $this->raw .= Utils::writeLong($this->data["unknown2"]);
  58. }
  59. break;
  60. case MC_CLIENT_CONNECT:
  61. if($this->c === false){
  62. $this->data["clientID"] = Utils::readLong($this->get(8));
  63. $this->data["session"] = Utils::readLong($this->get(8));
  64. $this->data["unknown2"] = $this->get(1);
  65. }else{
  66. $this->raw .= Utils::writeLong($this->data["clientID"]);
  67. $this->raw .= Utils::writeLong($this->data["session"]);
  68. $this->raw .= "\x00";
  69. }
  70. break;
  71. case MC_SERVER_HANDSHAKE:
  72. if($this->c === false){
  73. $this->data["cookie"] = $this->get(4); // 043f57fe
  74. $this->data["security"] = $this->get(1);
  75. $this->data["port"] = Utils::readShort($this->get(2), false);
  76. $this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 10, $offset);
  77. $this->get($offset);
  78. $this->data["unknown1"] = $this->get(2);
  79. $this->data["session"] = Utils::readLong($this->get(8));
  80. $this->data["session2"] = Utils::readLong($this->get(8));
  81. }else{
  82. $this->raw .= "\x04\x3f\x57\xfe";
  83. $this->raw .= "\xcd";
  84. $this->raw .= Utils::writeShort($this->data["port"]);
  85. $this->raw .= Utils::writeDataArray(array(
  86. "\xff\xff\xff\xff",
  87. "\xff\xff\xff\xff",
  88. "\xff\xff\xff\xff",
  89. "\xff\xff\xff\xff",
  90. "\xff\xff\xff\xff",
  91. "\xff\xff\xff\xff",
  92. "\xff\xff\xff\xff",
  93. "\xff\xff\xff\xff",
  94. "\xff\xff\xff\xff",
  95. "\xff\xff\xff\xff",
  96. ));
  97. $this->raw .= "\x00\x00";
  98. $this->raw .= Utils::writeLong($this->data["session"]);
  99. $this->raw .= Utils::writeLong($this->data["session2"]);
  100. }
  101. break;
  102. case MC_CLIENT_HANDSHAKE:
  103. if($this->c === false){
  104. $this->data["cookie"] = $this->get(4); // 043f57fe
  105. $this->data["security"] = $this->get(1);
  106. $this->data["port"] = Utils::readShort($this->get(2), false);
  107. $this->data["dataArray0"] = $this->get(ord($this->get(1)));
  108. $this->data["dataArray"] = Utils::readDataArray($this->get(true, false), 9, $offset);
  109. $this->get($offset);
  110. $this->data["unknown1"] = $this->get(2);
  111. $this->data["session2"] = Utils::readLong($this->get(8));
  112. $this->data["session"] = Utils::readLong($this->get(8));
  113. }else{
  114. $this->raw .= "\x04\x3f\x57\xfe";
  115. $this->raw .= "\xed";
  116. $this->raw .= Utils::writeShort($this->data["port"]);
  117. $w = array_shift($this->data["dataArray"]);
  118. $this->raw .= chr(strlen($w)).$w;
  119. $this->raw .= Utils::writeDataArray($this->data["dataArray"]);
  120. $this->raw .= "\x00\x00";
  121. $this->raw .= Utils::writeLong($this->data["session2"]);
  122. $this->raw .= Utils::writeLong($this->data["session"]);
  123. }
  124. break;
  125. case MC_DISCONNECT:
  126. //null
  127. break;
  128. case 0x18:
  129. //null
  130. break;
  131. case MC_LOGIN:
  132. if($this->c === false){
  133. $this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
  134. $this->data["maxX"] = Utils::readInt($this->get(4));
  135. $this->data["maxY"] = Utils::readInt($this->get(4));
  136. }else{
  137. $this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
  138. $this->raw .= "\x00\x00\x00\x08\x00\x00\x00\x08";
  139. }
  140. break;
  141. case MC_LOGIN_STATUS:
  142. if($this->c === false){
  143. $this->data["status"] = Utils::readInt($this->get(4));
  144. }else{
  145. $this->raw .= Utils::writeInt($this->data["status"]);
  146. }
  147. break;
  148. case MC_READY:
  149. if($this->c === false){
  150. $this->data["status"] = ord($this->get(1));
  151. }else{
  152. $this->raw .= chr($this->data["status"]);
  153. }
  154. break;
  155. case MC_CHAT:
  156. if($this->c === false){
  157. $this->data["message"] = $this->get(Utils::readShort($this->get(2), false));
  158. }else{
  159. $this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"];
  160. }
  161. break;
  162. case MC_SET_TIME:
  163. if($this->c === false){
  164. $this->data["time"] = Utils::readInt($this->get(4));
  165. }else{
  166. $this->raw .= Utils::writeInt($this->data["time"]);
  167. }
  168. break;
  169. case MC_START_GAME:
  170. if($this->c === false){
  171. $this->data["seed"] = Utils::readInt($this->get(4));
  172. $this->data["unknown1"] = Utils::readInt($this->get(4));
  173. $this->data["gamemode"] = Utils::readInt($this->get(4));
  174. $this->data["eid"] = Utils::readInt($this->get(4));
  175. $this->data["x"] = Utils::readFloat($this->get(4));
  176. $this->data["y"] = Utils::readFloat($this->get(4));
  177. $this->data["z"] = Utils::readFloat($this->get(4));
  178. }else{
  179. $this->raw .= Utils::writeInt($this->data["seed"]);
  180. $this->raw .= Utils::writeInt($this->data["unknown1"]);
  181. $this->raw .= Utils::writeInt($this->data["gamemode"]);
  182. $this->raw .= Utils::writeInt($this->data["eid"]);
  183. $this->raw .= Utils::writeFloat($this->data["x"]);
  184. $this->raw .= Utils::writeFloat($this->data["y"]);
  185. $this->raw .= Utils::writeFloat($this->data["z"]);
  186. }
  187. break;
  188. case MC_ADD_MOB:
  189. if($this->c === false){
  190. $this->data["eid"] = Utils::readInt($this->get(4));
  191. $this->data["type"] = Utils::readInt($this->get(4));
  192. $this->data["x"] = Utils::readFloat($this->get(4));
  193. $this->data["y"] = Utils::readFloat($this->get(4));
  194. $this->data["z"] = Utils::readFloat($this->get(4));
  195. $this->data["metadata"] = Utils::readMetadata($this->get(true));
  196. }else{
  197. $this->raw .= Utils::writeInt($this->data["eid"]);
  198. $this->raw .= Utils::writeInt($this->data["type"]);
  199. $this->raw .= Utils::writeFloat($this->data["x"]);
  200. $this->raw .= Utils::writeFloat($this->data["y"]);
  201. $this->raw .= Utils::writeFloat($this->data["z"]);
  202. $this->raw .= Utils::writeMetadata(array(
  203. 1 => array("type" => 1, "value" => 300),
  204. 16 => array("type" => 0, "value" => 0),
  205. 17 => array("type" => 6, "value" => array(0, 0, 0)),
  206. ));
  207. }
  208. break;
  209. case MC_ADD_PLAYER:
  210. if($this->c === false){
  211. $this->data["clientID"] = Utils::readLong($this->get(8));
  212. $this->data["username"] = $this->get(Utils::readShort($this->get(2), false));
  213. $this->data["eid"] = Utils::readInt($this->get(4));
  214. $this->data["x"] = Utils::readFloat($this->get(4));
  215. $this->data["y"] = Utils::readFloat($this->get(4));
  216. $this->data["z"] = Utils::readFloat($this->get(4));
  217. $this->data["metadata"] = Utils::readMetadata($this->get(true));
  218. }else{
  219. $this->raw .= Utils::writeLong($this->data["clientID"]);
  220. $this->raw .= Utils::writeShort(strlen($this->data["username"])).$this->data["username"];
  221. $this->raw .= Utils::writeInt($this->data["eid"]);
  222. $this->raw .= Utils::writeFloat($this->data["x"]);
  223. $this->raw .= Utils::writeFloat($this->data["y"]);
  224. $this->raw .= Utils::writeFloat($this->data["z"]);
  225. $this->raw .= Utils::writeMetadata(array(
  226. 1 => array("type" => 1, "value" => 300),
  227. 16 => array("type" => 0, "value" => 0),
  228. 17 => array("type" => 6, "value" => array(0, 0, 0)),
  229. ));
  230. }
  231. break;
  232. case MC_ADD_ENTITY:
  233. if($this->c === false){
  234. $this->data["eid"] = Utils::readInt($this->get(4));
  235. $this->data["type"] = ord($this->get(1));
  236. $this->data["x"] = Utils::readFloat($this->get(4));
  237. $this->data["y"] = Utils::readFloat($this->get(4));
  238. $this->data["z"] = Utils::readFloat($this->get(4));
  239. }else{
  240. $this->raw .= Utils::writeInt($this->data["eid"]);
  241. $this->raw .= chr($this->data["type"]);
  242. $this->raw .= Utils::writeFloat($this->data["x"]);
  243. $this->raw .= Utils::writeFloat($this->data["y"]);
  244. $this->raw .= Utils::writeFloat($this->data["z"]);
  245. $this->raw .= Utils::hexToStr("000000020000ffd30000");//Utils::writeInt(0);
  246. /*$this->raw .= Utils::writeShort(0);
  247. $this->raw .= Utils::writeShort(0);
  248. $this->raw .= Utils::writeShort(0);*/
  249. }
  250. break;
  251. case MC_REMOVE_ENTITY:
  252. if($this->c === false){
  253. $this->data["eid"] = Utils::readInt($this->get(4));
  254. }else{
  255. $this->raw .= Utils::writeInt($this->data["eid"]);
  256. }
  257. break;
  258. case MC_ADD_ITEM_ENTITY:
  259. if($this->c === false){
  260. $this->data["eid"] = Utils::readInt($this->get(4));
  261. $this->data["block"] = Utils::readShort($this->get(2), false);
  262. $this->data["stack"] = ord($this->get(1));
  263. $this->data["meta"] = Utils::readShort($this->get(2), false);
  264. $this->data["x"] = Utils::readFloat($this->get(4));
  265. $this->data["y"] = Utils::readFloat($this->get(4));
  266. $this->data["z"] = Utils::readFloat($this->get(4));
  267. $this->data["yaw"] = Utils::readByte($this->get(1));
  268. $this->data["pitch"] = Utils::readByte($this->get(1));
  269. $this->data["roll"] = Utils::readByte($this->get(1));
  270. }else{
  271. $this->raw .= Utils::writeInt($this->data["eid"]);
  272. $this->raw .= Utils::writeShort($this->data["block"]);
  273. $this->raw .= chr($this->data["stack"]);
  274. $this->raw .= Utils::writeShort($this->data["meta"]);
  275. $this->raw .= Utils::writeFloat($this->data["x"]);
  276. $this->raw .= Utils::writeFloat($this->data["y"]);
  277. $this->raw .= Utils::writeFloat($this->data["z"]);
  278. $this->raw .= Utils::writeByte($this->data["yaw"]);
  279. $this->raw .= Utils::writeByte($this->data["pitch"]);
  280. $this->raw .= Utils::writeByte($this->data["roll"]);
  281. }
  282. break;
  283. case MC_TAKE_ITEM_ENTITY:
  284. if($this->c === false){
  285. $this->data["target"] = Utils::readInt($this->get(4));
  286. $this->data["eid"] = Utils::readInt($this->get(4));
  287. }else{
  288. $this->raw .= Utils::writeInt($this->data["target"]);
  289. $this->raw .= Utils::writeInt($this->data["eid"]);
  290. }
  291. break;
  292. case MC_MOVE_ENTITY:
  293. if($this->c === false){
  294. $this->data["eid"] = Utils::readInt($this->get(4));
  295. $this->data["x"] = Utils::readFloat($this->get(4));
  296. $this->data["y"] = Utils::readFloat($this->get(4));
  297. $this->data["z"] = Utils::readFloat($this->get(4));
  298. }else{
  299. $this->raw .= Utils::writeInt($this->data["eid"]);
  300. $this->raw .= Utils::writeFloat($this->data["x"]);
  301. $this->raw .= Utils::writeFloat($this->data["y"]);
  302. $this->raw .= Utils::writeFloat($this->data["z"]);
  303. }
  304. break;
  305. case MC_MOVE_ENTITY_POSROT:
  306. if($this->c === false){
  307. $this->data["eid"] = Utils::readInt($this->get(4));
  308. $this->data["x"] = Utils::readFloat($this->get(4));
  309. $this->data["y"] = Utils::readFloat($this->get(4));
  310. $this->data["z"] = Utils::readFloat($this->get(4));
  311. $this->data["yaw"] = Utils::readFloat($this->get(4));
  312. $this->data["pitch"] = Utils::readFloat($this->get(4));
  313. }else{
  314. $this->raw .= Utils::writeInt($this->data["eid"]);
  315. $this->raw .= Utils::writeFloat($this->data["x"]);
  316. $this->raw .= Utils::writeFloat($this->data["y"]);
  317. $this->raw .= Utils::writeFloat($this->data["z"]);
  318. $this->raw .= Utils::writeFloat($this->data["yaw"]);
  319. $this->raw .= Utils::writeFloat($this->data["pitch"]);
  320. }
  321. break;
  322. case MC_MOVE_PLAYER:
  323. if($this->c === false){
  324. $this->data["eid"] = Utils::readInt($this->get(4));
  325. $this->data["x"] = Utils::readFloat($this->get(4));
  326. $this->data["y"] = Utils::readFloat($this->get(4));
  327. $this->data["z"] = Utils::readFloat($this->get(4));
  328. $this->data["yaw"] = Utils::readFloat($this->get(4));
  329. $this->data["pitch"] = Utils::readFloat($this->get(4));
  330. }else{
  331. $this->raw .= Utils::writeInt($this->data["eid"]);
  332. $this->raw .= Utils::writeFloat($this->data["x"]);
  333. $this->raw .= Utils::writeFloat($this->data["y"]);
  334. $this->raw .= Utils::writeFloat($this->data["z"]);
  335. $this->raw .= Utils::writeFloat($this->data["yaw"]);
  336. $this->raw .= Utils::writeFloat($this->data["pitch"]);
  337. }
  338. break;
  339. case MC_PLACE_BLOCK:
  340. if($this->c === false){
  341. $this->data["eid"] = Utils::readInt($this->get(4));
  342. $this->data["x"] = Utils::readInt($this->get(4));
  343. $this->data["z"] = Utils::readInt($this->get(4));
  344. $this->data["y"] = ord($this->get(1));
  345. $this->data["block"] = ord($this->get(1));
  346. $this->data["meta"] = ord($this->get(1));
  347. $this->data["face"] = Utils::readByte($this->get(1));
  348. }else{
  349. $this->raw .= Utils::writeInt($this->data["eid"]);
  350. $this->raw .= Utils::writeInt($this->data["x"]);
  351. $this->raw .= Utils::writeInt($this->data["z"]);
  352. $this->raw .= chr($this->data["y"]);
  353. $this->raw .= chr($this->data["block"]);
  354. $this->raw .= chr($this->data["meta"]);
  355. $this->raw .= chr($this->data["face"]);
  356. }
  357. break;
  358. case MC_REMOVE_BLOCK:
  359. if($this->c === false){
  360. $this->data["eid"] = Utils::readInt($this->get(4));
  361. $this->data["x"] = Utils::readInt($this->get(4));
  362. $this->data["z"] = Utils::readInt($this->get(4));
  363. $this->data["y"] = ord($this->get(1));
  364. }else{
  365. $this->raw .= Utils::writeInt($this->data["eid"]);
  366. $this->raw .= Utils::writeInt($this->data["x"]);
  367. $this->raw .= Utils::writeInt($this->data["z"]);
  368. $this->raw .= chr($this->data["y"]);
  369. }
  370. break;
  371. case MC_UPDATE_BLOCK:
  372. if($this->c === false){
  373. $this->data["x"] = Utils::readInt($this->get(4));
  374. $this->data["z"] = Utils::readInt($this->get(4));
  375. $this->data["y"] = ord($this->get(1));
  376. $this->data["block"] = ord($this->get(1));
  377. $this->data["meta"] = ord($this->get(1));
  378. }else{
  379. $this->raw .= Utils::writeInt($this->data["x"]);
  380. $this->raw .= Utils::writeInt($this->data["z"]);
  381. $this->raw .= chr($this->data["y"]);
  382. $this->raw .= chr($this->data["block"]);
  383. $this->raw .= chr($this->data["meta"]);
  384. }
  385. break;
  386. case MC_REQUEST_CHUNK:
  387. if($this->c === false){
  388. $this->data["x"] = Utils::readInt($this->get(4));
  389. $this->data["z"] = Utils::readInt($this->get(4));
  390. }else{
  391. $this->raw .= Utils::writeInt($this->data["x"]);
  392. $this->raw .= Utils::writeInt($this->data["z"]);
  393. }
  394. break;
  395. case MC_CHUNK_DATA:
  396. if($this->c === false){
  397. $this->data["x"] = Utils::readInt($this->get(4));
  398. $this->data["z"] = Utils::readInt($this->get(4));
  399. $this->data["data"] = $this->get(true);
  400. }else{
  401. $this->raw .= Utils::writeInt($this->data["x"]);
  402. $this->raw .= Utils::writeInt($this->data["z"]);
  403. $this->raw .= $this->data["data"];
  404. }
  405. break;
  406. case MC_PLAYER_EQUIPMENT:
  407. if($this->c === false){
  408. $this->data["eid"] = Utils::readInt($this->get(4));
  409. $this->data["block"] = Utils::readShort($this->get(2), false);
  410. $this->data["meta"] = Utils::readShort($this->get(2), false);
  411. }else{
  412. $this->raw .= Utils::writeInt($this->data["eid"]);
  413. $this->raw .= Utils::writeShort($this->data["block"]);
  414. $this->raw .= Utils::writeShort($this->data["meta"]);
  415. }
  416. break;
  417. case MC_INTERACT:
  418. if($this->c === false){
  419. $this->data["action"] = Utils::readByte($this->get(1));
  420. $this->data["eid"] = Utils::readInt($this->get(4));
  421. $this->data["target"] = Utils::readInt($this->get(4));
  422. }else{
  423. $this->raw .= Utils::writeByte($this->data["action"]);
  424. $this->raw .= Utils::writeInt($this->data["eid"]);
  425. $this->raw .= Utils::writeInt($this->data["target"]);
  426. }
  427. break;
  428. case MC_USE_ITEM:
  429. if($this->c === false){
  430. $this->data["x"] = Utils::readInt($this->get(4));
  431. $this->data["y"] = Utils::readInt($this->get(4));
  432. $this->data["z"] = Utils::readInt($this->get(4));
  433. $this->data["face"] = Utils::readInt($this->get(4));
  434. $this->data["block"] = Utils::readShort($this->get(2));
  435. $this->data["meta"] = Utils::readByte($this->get(1));
  436. $this->data["eid"] = Utils::readInt($this->get(4));
  437. $this->data["fx"] = Utils::readFloat($this->get(4));
  438. $this->data["fy"] = Utils::readFloat($this->get(4));
  439. $this->data["fz"] = Utils::readFloat($this->get(4));
  440. }else{
  441. /*$this->raw .= Utils::writeByte($this->data["action"]);
  442. $this->raw .= Utils::writeInt($this->data["eid"]);
  443. $this->raw .= Utils::writeInt($this->data["target"]);*/
  444. }
  445. break;
  446. case MC_SET_ENTITY_DATA:
  447. if($this->c === false){
  448. $this->data["eid"] = Utils::readInt($this->get(4));
  449. }else{
  450. $this->raw .= Utils::writeInt($this->data["eid"]);
  451. $this->raw .= Utils::writeMetadata(array(
  452. ));
  453. }
  454. break;
  455. case MC_SET_HEALTH:
  456. if($this->c === false){
  457. $this->data["health"] = ord($this->get(1));
  458. }else{
  459. $this->raw .= chr($this->data["health"]);
  460. }
  461. break;
  462. case MC_ANIMATE:
  463. if($this->c === false){
  464. $this->data["action"] = Utils::readByte($this->get(1));
  465. $this->data["eid"] = Utils::readInt($this->get(4));
  466. }else{
  467. $this->raw .= Utils::writeByte($this->data["action"]);
  468. $this->raw .= Utils::writeInt($this->data["eid"]);
  469. }
  470. break;
  471. case MC_RESPAWN:
  472. if($this->c === false){
  473. $this->data["eid"] = Utils::readInt($this->get(4));
  474. $this->data["x"] = Utils::readFloat($this->get(4));
  475. $this->data["y"] = Utils::readFloat($this->get(4));
  476. $this->data["z"] = Utils::readFloat($this->get(4));
  477. }else{
  478. $this->raw .= Utils::writeInt($this->data["eid"]);
  479. $this->raw .= Utils::writeFloat($this->data["x"]);
  480. $this->raw .= Utils::writeFloat($this->data["y"]);
  481. $this->raw .= Utils::writeFloat($this->data["z"]);
  482. }
  483. break;
  484. case MC_DROP_ITEM:
  485. if($this->c === false){
  486. $this->data["eid"] = Utils::readInt($this->get(4));
  487. $this->data["unknown1"] = ord($this->get(1));
  488. $this->data["block"] = Utils::readShort($this->get(2), false);
  489. $this->data["stack"] = ord($this->get(1));
  490. $this->data["meta"] = Utils::readShort($this->get(2), false);
  491. }else{
  492. $this->raw .= Utils::writeInt($this->data["eid"]);
  493. $this->raw .= chr($this->data["unknown1"]);
  494. $this->raw .= Utils::writeShort($this->data["block"]);
  495. $this->raw .= chr($this->data["stack"]);
  496. $this->raw .= Utils::writeShort($this->data["meta"]);
  497. }
  498. break;
  499. case MC_CLIENT_MESSAGE:
  500. if($this->c === false){
  501. $this->data["message"] = $this->get(Utils::readShort($this->get(2), false));
  502. }else{
  503. $this->raw .= Utils::writeShort(strlen($this->data["message"])).$this->data["message"];
  504. }
  505. break;
  506. case MC_SIGN_UPDATE:
  507. if($this->c === false){
  508. $this->data["x"] = Utils::readShort($this->get(2));
  509. $this->data["y"] = ord($this->get(1));
  510. $this->data["z"] = Utils::readShort($this->get(2));
  511. for($i = 0; $i < 4; ++$i){
  512. $this->data["line$i"] = $this->get(Utils::readLShort($this->get(2), false));
  513. }
  514. }else{
  515. $this->raw .= Utils::writeShort($this->data["x"]);
  516. $this->raw .= chr($this->data["y"]);
  517. $this->raw .= Utils::writeShort($this->data["z"]);
  518. for($i = 0; $i < 4; ++$i){
  519. $this->raw .= Utils::writeLShort(strlen($this->data["line$i"])).$this->data["line$i"];
  520. }
  521. }
  522. break;
  523. case MC_ADVENTURE_SETTINGS:
  524. if($this->c === false){
  525. $this->data["x"] = Utils::readShort($this->get(2));
  526. $this->data["y"] = ord($this->get(1));
  527. $this->data["z"] = Utils::readShort($this->get(2));
  528. for($i = 0; $i < 4; ++$i){
  529. $this->data["line$i"] = $this->get(Utils::readLShort($this->get(2), false));
  530. }
  531. }else{
  532. $this->raw .= $this->data["unknown1"];
  533. $this->raw .= $this->data["unknown2"];
  534. }
  535. break;
  536. default:
  537. if($this->c === false){
  538. console("[DEBUG] Received unknown Data Packet ID 0x".dechex($pid), true, true, 2);
  539. }else{
  540. console("[DEBUG] Sent unknown Data Packet ID 0x".dechex($pid), true, true, 2);
  541. }
  542. break;
  543. }
  544. }
  545. }