public function interfaceToServer(DesktopPlayer $player, Packet $packet)
 {
     //if($packet->pid() !== 0x00 and $packet->pid() !== 0x03 and $packet->pid() !== 0x04 and $packet->pid() !== 0x05 and $packet->pid() !== 0x06){
     echo "[Receive] 0x" . bin2hex(chr($packet->pid())) . "\n";
     //Debug
     //}
     switch ($packet->pid()) {
         case 0x0:
             //TeleportConfirmPacket
             /*case 0x00: //KeepAlivePacket
             				$pk->id = mt_rand();
             				$player->putRawPacket($pk);
             				return null;
             
             			case 0x01: //ChatPacket
             				$pk = new TextPacket();
             				$pk->type = 1;//Chat Type
             				$pk->source = "";
             				$pk->message = $packet->message;
             				return $pk;
             
             			case 0x02: //UseEntityPacket
             				$pk = new InteractPacket();
             				$pk->target = $packet->target;
             				$pk->action = $packet->type;
             				return $pk;
             
             			case 0x03: //PlayerPacket
             				$player->setSetting(["onGround" => $packet->onGround]);
             				return null;
             
             			case 0x04: //PlayerPositonPacket
             				$pk = new MovePlayerPacket();
             				$pk->x = $packet->x;
             				$pk->y = $packet->y + $player->getEyeHeight();
             				$pk->z = $packet->z;
             				$pk->yaw = $player->yaw;
             				$pk->bodyYaw = $player->yaw;
             				$pk->pitch = $player->pitch;
             				return $pk;
             
             			case 0x05: //PlayerLookPacket
             				$pk = new MovePlayerPacket();
             				$pk->x = $player->x;
             				$pk->y = $player->y + $player->getEyeHeight();
             				$pk->z = $player->z;
             				$pk->yaw = $packet->yaw;
             				$pk->bodyYaw = $packet->yaw;
             				$pk->pitch = $packet->pitch;
             				return $pk;
             
             			case 0x06: //PlayerPositionAndLookPacket
             				$pk = new MovePlayerPacket();
             				$pk->x = $packet->x;
             				$pk->y = $packet->y + $player->getEyeHeight();
             				$pk->z = $packet->z;
             				$pk->yaw = $packet->yaw;
             				$pk->bodyYaw = $packet->yaw;
             				$pk->pitch = $packet->pitch;
             				return $pk;
             
             			case 0x07: //PlayerDiggingPacket
             				switch($packet->status){
             					case 0:
             						if($player->getGamemode() === 1){
             							$pk = new RemoveBlockPacket();
             							$pk->eid = 0;
             							$pk->x = $packet->x;
             							$pk->y = $packet->y;
             							$pk->z = $packet->z;
             							return $pk;
             						}else{
             							$pk = new PlayerActionPacket();
             							$pk->eid = 0;
             							$pk->action = PlayerActionPacket::ACTION_START_BREAK;
             							$pk->x = $packet->x;
             							$pk->y = $packet->y;
             							$pk->z = $packet->z;
             							$pk->face = $packet->face;
             							return $pk;
             						}
             					break;
             					case 1:
             						$pk = new PlayerActionPacket();
             						$pk->eid = 0;
             						$pk->action = PlayerActionPacket::ACTION_ABORT_BREAK;
             						$pk->x = $packet->x;
             						$pk->y = $packet->y;
             						$pk->z = $packet->z;
             						$pk->face = $packet->face;
             						return $pk;
             					break;
             					case 2:
             						if($player->getGamemode() !== 1){
             							$packets = [];
             							$pk = new PlayerActionPacket();
             							$pk->eid = 0;
             							$pk->action = PlayerActionPacket::ACTION_STOP_BREAK;
             							$pk->x = $packet->x;
             							$pk->y = $packet->y;
             							$pk->z = $packet->z;
             							$pk->face = $packet->face;
             							$packets[] = $pk;
             
             							$pk = new RemoveBlockPacket();
             							$pk->eid = 0;
             							$pk->x = $packet->x;
             							$pk->y = $packet->y;
             							$pk->z = $packet->z;
             							$packets[] = $pk;
             							return $packets;
             						}else{
             							echo "PlayerDiggingPacket: ".$packet->status."\n";
             						}
             					break;
             					default:
             						echo "PlayerDiggingPacket: ".$packet->status."\n";
             					break;
             				}
             
             				return null;
             
             			case 0x08; //PlayerBlockPlacementPacket
             				echo "PlayerBlockPlacementPacket: ".$packet->direction."\n";
             
             				if($packet->direction !== 255){
             					$pk = new UseItemPacket();
             					$pk->x = $packet->x;
             					$pk->y = $packet->y;
             					$pk->z = $packet->z;
             					$pk->face = $packet->direction;
             					$pk->item = $packet->heldItem;
             					$pk->fx = $packet->cursorX / 16;
             					$pk->fy = $packet->cursorY / 16;
             					$pk->fz = $packet->cursorZ / 16;
             					$pk->posX = $player->getX();
             					$pk->posY = $player->getY();
             					$pk->posZ = $player->getZ();
             					return $pk;
             				}else{
             
             				}
             
             				return null;
             
             			case 0x09: //HeldItemChangePacket
             				$item = $player->getInventory()->getItem($packet->selectedSlot);
             				$olditem = $player->getInventory()->getItem($player->getInventory()->getHeldItemIndex());
             
             				if($item->getId() !== 0 or $item->getId() === 0 and $olditem->getId() !== 0){
             					$pk = new MobEquipmentPacket();
             					$pk->eid = 0;
             					$pk->item = $item;
             					if($item->getId() === 0){
             						$pk->slot = 255;
             					}else{
             						$pk->slot = Item::getCreativeItemIndex($item) + 9;
             					}
             					$pk->selectedSlot = $packet->selectedSlot;
             					return $pk;
             				}
             
             				return null;
             
             			case 0x0a: //PlayerArmSwingPacket
             				$pk = new AnimatePacket();
             				$pk->action = 1;
             				$pk->eid = 0;
             				return $pk;
             
             			case 0x0b: //AnimatePacket
             				switch($packet->actionID){
             					case 0:
             						if(!$player->getSetting("isFlying")){
             							$pk = new PlayerActionPacket();
             							$pk->eid = $packet->eid;
             							$pk->action = PlayerActionPacket::ACTION_START_SNEAK;
             							$pk->x = $player->getX();
             							$pk->y = $player->getY();
             							$pk->z = $player->getZ();
             							$pk->face = 0;
             							return $pk;
             						}
             					break;
             					case 1:
             						if(!$player->getSetting("isFlying")){
             							$pk = new PlayerActionPacket();
             							$pk->eid = $packet->eid;
             							$pk->action = PlayerActionPacket::ACTION_STOP_SNEAK;
             							$pk->x = $player->getX();
             							$pk->y = $player->getY();
             							$pk->z = $player->getZ();
             							$pk->face = 0;
             							return $pk;
             						}
             					break;
             					case 2:
             						$pk = new PlayerActionPacket();
             						$pk->eid = $packet->eid;
             						$pk->action = PlayerActionPacket::ACTION_STOP_SLEEPING;
             						$pk->x = $player->getX();
             						$pk->y = $player->getY();
             						$pk->z = $player->getZ();
             						$pk->face = 0;
             						return $pk;
             					break;
             					case 3:
             						$pk = new PlayerActionPacket();
             						$pk->eid = $packet->eid;
             						$pk->action = PlayerActionPacket::ACTION_START_SPRINT;
             						$pk->x = $player->getX();
             						$pk->y = $player->getY();
             						$pk->z = $player->getZ();
             						$pk->face = 0;
             						return $pk;
             					break;
             					case 4:
             						$pk = new PlayerActionPacket();
             						$pk->eid = $packet->eid;
             						$pk->action = PlayerActionPacket::ACTION_STOP_SPRINT;
             						$pk->x = $player->getX();
             						$pk->y = $player->getY();
             						$pk->z = $player->getZ();
             						$pk->face = 0;
             						return $pk;
             					break;
             					/*case 6:
             
             					break;*/
             /*
             					default:
             						echo "[AnimatePacket] ".$packet->actionID."\n";//Debug Code
             					break;
             				}
             				return null;
             
             			case 0x0d: //CTSCloseWindowPacket
             				if($packet->windowID !== 0x00){
             					$pk = new ContainerClosePacket();
             					$pk->windowid = $packet->windowID;
             					return $pk;
             				}
             
             			case 0x10: //CreativeInventoryActionPacket
             				echo "Slot: ".$packet->slot."\n";
             				echo "ItemId: ".$packet->item->getId()." : ".$packet->item->getDamage()."\n";
             
             				/*if($packet->slot === 65535){
             					$pk = new DropItemPacket();
             					$pk->type = 0;
             					$pk->item = $packet->item;
             					return $pk;
             				}else{
             					$pk = new ContainerSetSlotPacket();
             					$pk->windowid = 0;
             					$pk->slot = $packet->slot;
             					$pk->item = $packet->item;
             					return $pk;
             				}*/
             /*
             
             				return null;
             
             			case 0x13: //CPlayerAbilitiesPacket
             				$player->setSetting(["isFlying" => $packet->isFlying]);
             				return null;
             
             			case 0x14: //CTabCompletePacket
             				/*$pk = new STabComletePacket();
             
             				foreach($player->getServer()->getCommandMap()->getCommands() as $command){
             					if($command->testPermissionSilent($player)){
             						$pk->matches[] = $command->getName();
             					}
             				}
             
             				foreach($player->getServer()->getOnlinePlayers() as $packetplayer){
             					$pk->matches[] = $packetplayer->getName();
             				}
             
             				//TODO
             
             				//echo $packet->text."\n";
             
             				return $pk;*/
             /*
             				return null;
             
             			case 0x15: //ClientSettingsPacket
             				$player->setSetting([
             					"Lang" => $packet->lang,
             					"View" => $packet->view,
             					"ChatMode" => $packet->chatmode,
             					"ChatColor" => $packet->chatcolor,
             					"SkinSettings" => $packet->skinsetting,
             				]);
             
             				return null;
             
             			case 0x16: //ClientStatusPacket
             				switch($packet->actionID){
             					case 0:
             						$pk = new PlayerActionPacket();
             						$pk->eid = 0;
             						$pk->action = PlayerActionPacket::ACTION_RESPAWN;
             						$pk->x = 0;
             						$pk->y = 0;
             						$pk->z = 0;
             						$pk->face = 0;
             						return $pk;
             					break;
             					case 1:
             						$statistic = [];
             						$statistic[] = ["achievement.openInventory", 1];//
             						foreach($player->achievements as $achievement => $count){
             							$statistic[] = ["achievement.".$achievement, $count];
             						}
             
             						//stat
             						//https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0
             
             						$pk = new StatisticsPacket();
             						$pk->count = count($statistic);//TODO stat
             						$pk->statistic = $statistic;
             						$player->putRawPacket($pk);
             					break;
             					case 2:
             						//$player->awardAchievement("openInventory"); this for DesktopPlayer
             						//Achievement::broadcast($player, "openInventory");//Debug
             					break;
             				}
             				return null;
             
             			case 0x17: //PluginMessagePacket
             				switch($packet->channel){
             					case "REGISTER"://Mods Register
             						$player->setSetting(["Channels" => $packet->data]);
             					break;
             					case "MC|Brand": //ServerType
             						$player->setSetting(["ServerType" => $packet->data]);
             					break;
             					default:
             						echo "PluginChannel: ".$packet->channel."\n";
             					break;
             				}
             				return null;
             
             			case 0x19: //ResourcePackStatusPacket
             				$player->setSetting(["ResourceStatus" => $packet->status, "ResourceHash" => $packet->hash]);
             				return null;*/
         //TeleportConfirmPacket
         /*case 0x00: //KeepAlivePacket
         				$pk->id = mt_rand();
         				$player->putRawPacket($pk);
         				return null;
         
         			case 0x01: //ChatPacket
         				$pk = new TextPacket();
         				$pk->type = 1;//Chat Type
         				$pk->source = "";
         				$pk->message = $packet->message;
         				return $pk;
         
         			case 0x02: //UseEntityPacket
         				$pk = new InteractPacket();
         				$pk->target = $packet->target;
         				$pk->action = $packet->type;
         				return $pk;
         
         			case 0x03: //PlayerPacket
         				$player->setSetting(["onGround" => $packet->onGround]);
         				return null;
         
         			case 0x04: //PlayerPositonPacket
         				$pk = new MovePlayerPacket();
         				$pk->x = $packet->x;
         				$pk->y = $packet->y + $player->getEyeHeight();
         				$pk->z = $packet->z;
         				$pk->yaw = $player->yaw;
         				$pk->bodyYaw = $player->yaw;
         				$pk->pitch = $player->pitch;
         				return $pk;
         
         			case 0x05: //PlayerLookPacket
         				$pk = new MovePlayerPacket();
         				$pk->x = $player->x;
         				$pk->y = $player->y + $player->getEyeHeight();
         				$pk->z = $player->z;
         				$pk->yaw = $packet->yaw;
         				$pk->bodyYaw = $packet->yaw;
         				$pk->pitch = $packet->pitch;
         				return $pk;
         
         			case 0x06: //PlayerPositionAndLookPacket
         				$pk = new MovePlayerPacket();
         				$pk->x = $packet->x;
         				$pk->y = $packet->y + $player->getEyeHeight();
         				$pk->z = $packet->z;
         				$pk->yaw = $packet->yaw;
         				$pk->bodyYaw = $packet->yaw;
         				$pk->pitch = $packet->pitch;
         				return $pk;
         
         			case 0x07: //PlayerDiggingPacket
         				switch($packet->status){
         					case 0:
         						if($player->getGamemode() === 1){
         							$pk = new RemoveBlockPacket();
         							$pk->eid = 0;
         							$pk->x = $packet->x;
         							$pk->y = $packet->y;
         							$pk->z = $packet->z;
         							return $pk;
         						}else{
         							$pk = new PlayerActionPacket();
         							$pk->eid = 0;
         							$pk->action = PlayerActionPacket::ACTION_START_BREAK;
         							$pk->x = $packet->x;
         							$pk->y = $packet->y;
         							$pk->z = $packet->z;
         							$pk->face = $packet->face;
         							return $pk;
         						}
         					break;
         					case 1:
         						$pk = new PlayerActionPacket();
         						$pk->eid = 0;
         						$pk->action = PlayerActionPacket::ACTION_ABORT_BREAK;
         						$pk->x = $packet->x;
         						$pk->y = $packet->y;
         						$pk->z = $packet->z;
         						$pk->face = $packet->face;
         						return $pk;
         					break;
         					case 2:
         						if($player->getGamemode() !== 1){
         							$packets = [];
         							$pk = new PlayerActionPacket();
         							$pk->eid = 0;
         							$pk->action = PlayerActionPacket::ACTION_STOP_BREAK;
         							$pk->x = $packet->x;
         							$pk->y = $packet->y;
         							$pk->z = $packet->z;
         							$pk->face = $packet->face;
         							$packets[] = $pk;
         
         							$pk = new RemoveBlockPacket();
         							$pk->eid = 0;
         							$pk->x = $packet->x;
         							$pk->y = $packet->y;
         							$pk->z = $packet->z;
         							$packets[] = $pk;
         							return $packets;
         						}else{
         							echo "PlayerDiggingPacket: ".$packet->status."\n";
         						}
         					break;
         					default:
         						echo "PlayerDiggingPacket: ".$packet->status."\n";
         					break;
         				}
         
         				return null;
         
         			case 0x08; //PlayerBlockPlacementPacket
         				echo "PlayerBlockPlacementPacket: ".$packet->direction."\n";
         
         				if($packet->direction !== 255){
         					$pk = new UseItemPacket();
         					$pk->x = $packet->x;
         					$pk->y = $packet->y;
         					$pk->z = $packet->z;
         					$pk->face = $packet->direction;
         					$pk->item = $packet->heldItem;
         					$pk->fx = $packet->cursorX / 16;
         					$pk->fy = $packet->cursorY / 16;
         					$pk->fz = $packet->cursorZ / 16;
         					$pk->posX = $player->getX();
         					$pk->posY = $player->getY();
         					$pk->posZ = $player->getZ();
         					return $pk;
         				}else{
         
         				}
         
         				return null;
         
         			case 0x09: //HeldItemChangePacket
         				$item = $player->getInventory()->getItem($packet->selectedSlot);
         				$olditem = $player->getInventory()->getItem($player->getInventory()->getHeldItemIndex());
         
         				if($item->getId() !== 0 or $item->getId() === 0 and $olditem->getId() !== 0){
         					$pk = new MobEquipmentPacket();
         					$pk->eid = 0;
         					$pk->item = $item;
         					if($item->getId() === 0){
         						$pk->slot = 255;
         					}else{
         						$pk->slot = Item::getCreativeItemIndex($item) + 9;
         					}
         					$pk->selectedSlot = $packet->selectedSlot;
         					return $pk;
         				}
         
         				return null;
         
         			case 0x0a: //PlayerArmSwingPacket
         				$pk = new AnimatePacket();
         				$pk->action = 1;
         				$pk->eid = 0;
         				return $pk;
         
         			case 0x0b: //AnimatePacket
         				switch($packet->actionID){
         					case 0:
         						if(!$player->getSetting("isFlying")){
         							$pk = new PlayerActionPacket();
         							$pk->eid = $packet->eid;
         							$pk->action = PlayerActionPacket::ACTION_START_SNEAK;
         							$pk->x = $player->getX();
         							$pk->y = $player->getY();
         							$pk->z = $player->getZ();
         							$pk->face = 0;
         							return $pk;
         						}
         					break;
         					case 1:
         						if(!$player->getSetting("isFlying")){
         							$pk = new PlayerActionPacket();
         							$pk->eid = $packet->eid;
         							$pk->action = PlayerActionPacket::ACTION_STOP_SNEAK;
         							$pk->x = $player->getX();
         							$pk->y = $player->getY();
         							$pk->z = $player->getZ();
         							$pk->face = 0;
         							return $pk;
         						}
         					break;
         					case 2:
         						$pk = new PlayerActionPacket();
         						$pk->eid = $packet->eid;
         						$pk->action = PlayerActionPacket::ACTION_STOP_SLEEPING;
         						$pk->x = $player->getX();
         						$pk->y = $player->getY();
         						$pk->z = $player->getZ();
         						$pk->face = 0;
         						return $pk;
         					break;
         					case 3:
         						$pk = new PlayerActionPacket();
         						$pk->eid = $packet->eid;
         						$pk->action = PlayerActionPacket::ACTION_START_SPRINT;
         						$pk->x = $player->getX();
         						$pk->y = $player->getY();
         						$pk->z = $player->getZ();
         						$pk->face = 0;
         						return $pk;
         					break;
         					case 4:
         						$pk = new PlayerActionPacket();
         						$pk->eid = $packet->eid;
         						$pk->action = PlayerActionPacket::ACTION_STOP_SPRINT;
         						$pk->x = $player->getX();
         						$pk->y = $player->getY();
         						$pk->z = $player->getZ();
         						$pk->face = 0;
         						return $pk;
         					break;
         					/*case 6:
         
         					break;*/
         /*
         					default:
         						echo "[AnimatePacket] ".$packet->actionID."\n";//Debug Code
         					break;
         				}
         				return null;
         
         			case 0x0d: //CTSCloseWindowPacket
         				if($packet->windowID !== 0x00){
         					$pk = new ContainerClosePacket();
         					$pk->windowid = $packet->windowID;
         					return $pk;
         				}
         
         			case 0x10: //CreativeInventoryActionPacket
         				echo "Slot: ".$packet->slot."\n";
         				echo "ItemId: ".$packet->item->getId()." : ".$packet->item->getDamage()."\n";
         
         				/*if($packet->slot === 65535){
         					$pk = new DropItemPacket();
         					$pk->type = 0;
         					$pk->item = $packet->item;
         					return $pk;
         				}else{
         					$pk = new ContainerSetSlotPacket();
         					$pk->windowid = 0;
         					$pk->slot = $packet->slot;
         					$pk->item = $packet->item;
         					return $pk;
         				}*/
         /*
         
         				return null;
         
         			case 0x13: //CPlayerAbilitiesPacket
         				$player->setSetting(["isFlying" => $packet->isFlying]);
         				return null;
         
         			case 0x14: //CTabCompletePacket
         				/*$pk = new STabComletePacket();
         
         				foreach($player->getServer()->getCommandMap()->getCommands() as $command){
         					if($command->testPermissionSilent($player)){
         						$pk->matches[] = $command->getName();
         					}
         				}
         
         				foreach($player->getServer()->getOnlinePlayers() as $packetplayer){
         					$pk->matches[] = $packetplayer->getName();
         				}
         
         				//TODO
         
         				//echo $packet->text."\n";
         
         				return $pk;*/
         /*
         				return null;
         
         			case 0x15: //ClientSettingsPacket
         				$player->setSetting([
         					"Lang" => $packet->lang,
         					"View" => $packet->view,
         					"ChatMode" => $packet->chatmode,
         					"ChatColor" => $packet->chatcolor,
         					"SkinSettings" => $packet->skinsetting,
         				]);
         
         				return null;
         
         			case 0x16: //ClientStatusPacket
         				switch($packet->actionID){
         					case 0:
         						$pk = new PlayerActionPacket();
         						$pk->eid = 0;
         						$pk->action = PlayerActionPacket::ACTION_RESPAWN;
         						$pk->x = 0;
         						$pk->y = 0;
         						$pk->z = 0;
         						$pk->face = 0;
         						return $pk;
         					break;
         					case 1:
         						$statistic = [];
         						$statistic[] = ["achievement.openInventory", 1];//
         						foreach($player->achievements as $achievement => $count){
         							$statistic[] = ["achievement.".$achievement, $count];
         						}
         
         						//stat
         						//https://gist.github.com/thinkofdeath/a1842c21a0cf2e1fb5e0
         
         						$pk = new StatisticsPacket();
         						$pk->count = count($statistic);//TODO stat
         						$pk->statistic = $statistic;
         						$player->putRawPacket($pk);
         					break;
         					case 2:
         						//$player->awardAchievement("openInventory"); this for DesktopPlayer
         						//Achievement::broadcast($player, "openInventory");//Debug
         					break;
         				}
         				return null;
         
         			case 0x17: //PluginMessagePacket
         				switch($packet->channel){
         					case "REGISTER"://Mods Register
         						$player->setSetting(["Channels" => $packet->data]);
         					break;
         					case "MC|Brand": //ServerType
         						$player->setSetting(["ServerType" => $packet->data]);
         					break;
         					default:
         						echo "PluginChannel: ".$packet->channel."\n";
         					break;
         				}
         				return null;
         
         			case 0x19: //ResourcePackStatusPacket
         				$player->setSetting(["ResourceStatus" => $packet->status, "ResourceHash" => $packet->hash]);
         				return null;*/
         default:
             echo "[Receive] 0x" . bin2hex(chr($packet->pid())) . "\n";
             return null;
     }
 }
 protected function sendPacket($target, Packet $packet)
 {
     echo "[Send:Interface] 0x" . bin2hex(chr($packet->pid())) . "\n";
     $data = chr(ServerManager::PACKET_SEND_PACKET) . Binary::writeInt($target) . $packet->write();
     $this->thread->pushMainToThreadPacket($data);
 }
 protected function sendPacket($target, Packet $packet)
 {
     $data = chr(ServerManager::PACKET_SEND_PACKET) . Binary::writeInt($target) . $packet->write();
     $this->thread->pushMainToThreadPacket($data);
 }
Exemple #4
0
 public function writePacket(Packet $packet)
 {
     $data = $packet->write();
     if ($this->threshold === null) {
         $this->write(Binary::writeVarInt(strlen($data)) . $data);
     } else {
         $dataLength = strlen($data);
         if ($dataLength >= $this->threshold) {
             $data = zlib_encode($data, ZLIB_ENCODING_DEFLATE, 7);
         } else {
             $dataLength = 0;
         }
         $data = Binary::writeVarInt($dataLength) . $data;
         $this->write(Binary::writeVarInt(strlen($data)) . $data);
     }
 }
 public function interfaceToServer(DesktopPlayer $player, Packet $packet)
 {
     switch ($packet->pid()) {
         // TODO: move to Info
         case 0x1:
             //CTSChatPacket
             $pk = new TextPacket();
             $pk->source = "";
             $pk->message = $packet->message;
             return $pk;
         case 0x2:
             //UseEntityPacket
             $pk = new InteractPacket();
             $pk->target = $packet->target;
             $pk->action = $packet->mouse;
             return $pk;
         case 0x4:
             //PlayerPositionPacket
             $pk = new MovePlayerPacket();
             $pk->x = $packet->x;
             $pk->y = $packet->y;
             $pk->z = $packet->z;
             $pk->yaw = $player->yaw;
             $pk->bodyYaw = $player->yaw;
             $pk->pitch = $player->pitch;
             return $pk;
         case 0x5:
             //PlayerLookPacket
             $pk = new MovePlayerPacket();
             $pk->x = $player->x;
             $pk->y = $player->y;
             $pk->z = $player->z;
             $pk->yaw = $packet->yaw;
             $pk->bodyYaw = $packet->yaw;
             $pk->pitch = $packet->pitch;
             return $pk;
         case 0x6:
             //PlayerPositionAndLookPacket
             $pk = new MovePlayerPacket();
             $pk->x = $packet->x;
             $pk->y = $packet->y;
             $pk->z = $packet->z;
             $pk->yaw = $packet->yaw;
             $pk->bodyYaw = $packet->yaw;
             $pk->pitch = $packet->pitch;
             return $pk;
         case 0x7:
             //PlayerDiggingPacket
             if ($packet->status === 2 or $player->getGamemode() === 1 and $packet->status === 0) {
                 //Finished digging
                 $pk = new RemoveBlockPacket();
                 $pk->eid = 0;
                 $pk->x = $packet->x;
                 $pk->y = $packet->y;
                 $pk->z = $packet->z;
                 return $pk;
             }
             return null;
         case 0x8:
             //PlayerBlockPlacementPacket
             $pk = new UseItemPacket();
             $pk->x = $packet->x;
             $pk->y = $packet->y;
             $pk->z = $packet->z;
             $pk->face = $packet->direction;
             $pk->item = $packet->heldItem->getID();
             $pk->meta = $packet->heldItem->getDamage();
             $pk->eid = 0;
             $pk->fx = $packet->cursorX / 16;
             $pk->fy = $packet->cursorY / 16;
             $pk->fz = $packet->cursorZ / 16;
             return $pk;
         case 0xd:
             //CTSCloseWindowPacket
             $pk = new ContainerClosePacket();
             $pk->windowid = $packet->windowID;
             return $pk;
         case 0x16:
             //ClientStatusPacket
             if ($packet->actionID === 0) {
                 $pk = new RespawnPacket();
                 $pk->eid = 0;
                 $pk->x = $player->getSpawn()->getX();
                 $pk->y = $player->getSpawn()->getX();
                 $pk->z = $player->getSpawn()->getX();
                 return $pk;
             }
             return null;
         default:
             return null;
     }
 }