public function serverToInterface(DesktopPlayer $player, DataPacket $packet) { switch ($packet->pid()) { case Info::DISCONNECT_PACKET: if ($player->bigBrother_getStatus() === 0) { $pk = new LoginDisconnectPacket(); $pk->reason = TextFormat::toJSON($packet->message === "" ? "You have been disconnected." : $packet->message); } else { $pk = new PlayDisconnectPacket(); $pk->reason = TextFormat::toJSON($packet->message === "" ? "You have been disconnected." : $packet->message); } return $pk; case Info::TEXT_PACKET: echo $player->getSetting("Lang") . "\n"; /*if($packet->message === "chat.type.achievement"){ /*$pk = new ScoreboardObjectivePacket(); $pk->ObjectiveName = $packet->parameters[0]; $pk->Mode = 0; $pk->ObjectiveValue = 3; return $pk;*/ /*echo "TextPacket: achievement\n"; return null; }else{ $pk = new STCChatPacket(); $pk->message = TextFormat::toJSON($packet->message, $packet->type, $packet->parameters); }*/ //return $pk; return null; case Info::SET_TIME_PACKET: $pk = new TimeUpdatePacket(); $pk->age = $packet->time; $pk->time = $packet->time; //TODO: calculate offset from MCPE return $pk; case Info::START_GAME_PACKET: $packets = []; $pk = new JoinGamePacket(); $pk->eid = $packet->eid; $pk->gamemode = $packet->gamemode; $pk->dimension = 0; $pk->difficulty = $player->getServer()->getDifficulty(); $pk->maxPlayers = $player->getServer()->getMaxPlayers(); $pk->levelType = "default"; $packets[] = $pk; $pk = new SpawnPositionPacket(); $pk->spawnX = $packet->spawnX; $pk->spawnY = $packet->spawnY; $pk->spawnZ = $packet->spawnZ; $packets[] = $pk; $pk = new PlayerAbilitiesPacket(); $pk->flyingSpeed = 0.05; $pk->walkingSpeed = 0.1; $pk->canFly = ($player->getGamemode() & 0x1) > 0; $pk->damageDisabled = ($player->getGamemode() & 0x1) > 0; $pk->isFlying = false; $pk->isCreative = ($player->getGamemode() & 0x1) > 0; $packets[] = $pk; $pk = new PositionAndLookPacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $player->yaw; $pk->pitch = $player->pitch; $packets[] = $pk; return $packets; case Info::ADD_PLAYER_PACKET: $packets = []; $packetplayer = $player->getServer()->getPlayerExact($packet->username); $pk = new PlayerListPacket(); $pk->actionID = PlayerListPacket::TYPE_ADD; $pk->players[] = [$packetplayer->getUniqueId()->toBinary(), $packetplayer->getName(), [], $packetplayer->getGamemode(), 0, false]; if ($packetplayer instanceof DesktopPlayer) { $pk->players[0][2] = $packetplayer->bigBrother_getPeroperties(); } $packets[] = $pk; $pk = new SpawnPlayerPacket(); $pk->eid = $packet->eid; $pk->uuid = $packetplayer->getUniqueId()->toBinary(); $pk->x = $packet->x; $pk->z = $packet->z; $pk->y = $packet->y; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $pk->item = $packetplayer->getInventory()->getItemInHand()->getId(); $pk->metadata = $packet->metadata; $packets[] = $pk; $pk = new EntityTeleportPacket(); $pk->eid = $packet->eid; $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $packets[] = $pk; return $packets; /*case Info::ADD_ENTITY_PACKET: return null;*/ /*case Info::REMOVE_PLAYER_PACKET: $pk = new PlayerListPacket(); $pk->actionID = PlayerListPacket::TYPE_REMOVE; $pk->players[] = [ $packet->clientId->toBinary() ]; $packets[] = $pk; $pk = new DestroyEntitiesPacket(); $pk->ids[] = $packet->eid; $packets[] = $pk; return $packets;*/ /*case Info::ADD_ENTITY_PACKET: return null;*/ /*case Info::REMOVE_PLAYER_PACKET: $pk = new PlayerListPacket(); $pk->actionID = PlayerListPacket::TYPE_REMOVE; $pk->players[] = [ $packet->clientId->toBinary() ]; $packets[] = $pk; $pk = new DestroyEntitiesPacket(); $pk->ids[] = $packet->eid; $packets[] = $pk; return $packets;*/ case Info::REMOVE_ENTITY_PACKET: $pk = new DestroyEntitiesPacket(); $pk->ids[] = $packet->eid; return $pk; case Info::ADD_ITEM_ENTITY_PACKET: $packets = []; $pk = new SpawnObjectPacket(); $pk->eid = $packet->eid; $pk->type = 2; $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $player->yaw; $pk->pitch = $player->pitch; $packets[] = $pk; $pk = new EntityMetadataPacket(); $pk->eid = $packet->eid; $pk->metadata = [0 => [0 => 0, 1 => 0], 10 => [0 => 5, 1 => $packet->item]]; $packets[] = $pk; return $packets; /*case Info::REMOVE_ITEM_ENTITY_PACKET: return null;*/ /*case Info::REMOVE_ITEM_ENTITY_PACKET: return null;*/ case Info::MOVE_ENTITY_PACKET: $packets = []; foreach ($packet->entities as $d) { $pk = new EntityTeleportPacket(); $pk->eid = $d[0]; $pk->x = $d[1]; $pk->y = $d[2] - $player->getEyeHeight(); $pk->z = $d[3]; $pk->yaw = $d[4]; $pk->pitch = $d[6]; $packets[] = $pk; $pk = new EntityHeadLookPacket(); $pk->eid = $d[0]; $pk->yaw = $d[5]; $packets[] = $pk; } return $packets; case Info::MOVE_PLAYER_PACKET: if ($packet->eid === 0) { $pk = new PositionAndLookPacket(); $pk->x = $packet->x; $pk->y = $packet->y - $player->getEyeHeight(); $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $pk->onGround = $player->isOnGround(); return $pk; } else { $packets = []; $pk = new EntityTeleportPacket(); $pk->eid = $packet->eid; $pk->x = $packet->x; $pk->y = $packet->y - $player->getEyeHeight(); $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $packets[] = $pk; $pk = new EntityHeadLookPacket(); $pk->eid = $packet->eid; $pk->yaw = $packet->yaw; $packets[] = $pk; return $packets; } case Info::UPDATE_BLOCK_PACKET: //TODO $pk = new BlockChangePacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->blockId = $packet->blockId; $pk->blockMeta = $packet->blockData; return $pk; case Info::MOB_EQUIPMENT_PACKET: $pk = new EntityEquipmentPacket(); $pk->eid = $packet->eid; $pk->slot = $packet->slot; $pk->item = $packet->item; return $pk; case Info::MOB_ARMOR_EQUIPMENT_PACKET: $packets = []; foreach ($packet->slots as $num => $item) { $pk = new EntityEquipmentPacket(); $pk->eid = $packet->eid; $pk->slot = $num + 1; $pk->item = $item; $packets[] = $pk; } return $packets; case Info::SET_ENTITY_DATA_PACKET: /*if(isset($packet->metadata[16])){ if($packet->metadata[16][1] === 2){ $pk = new UseBedPacket(); //Bug $pk->eid = $packet->eid; $bedXYZ = $player->getSetting("BedXYZ"); $pk->bedX = $bedXYZ[0]; $pk->bedY = $bedXYZ[1]; $pk->bedZ = $bedXYZ[2]; $player->removeSetting("BedXYZ"); }else{ $pk = new CAnimatePacket(); $pk->eid = $packet->eid; $pk->actionID = 2; } return $pk; }elseif(isset($packet->metadata[17])){ $player->setSetting(["BedXYZ" => $packet->metadata[17][1]]); }*/ $pk = new EntityMetadataPacket(); $pk->eid = $packet->eid; $pk->metadata = $packet->metadata; return $pk; case Info::SET_ENTITY_MOTION_PACKET: $pk = new EntityVelocityPacket(); $pk->eid = $packet->eid; $pk->velocityX = $packet->motionX; $pk->velocityY = $packet->motionY; $pk->velocityZ = $packet->motionZ; return $pk; case Info::SET_HEALTH_PACKET: $pk = new UpdateHealthPacket(); $pk->health = $packet->health; $pk->food = 20; $pk->saturation = 5; return $pk; case Info::SET_SPAWN_POSITION_PACKET: $pk = new SpawnPositionPacket(); $pk->spawnX = $packet->x; $pk->spawnY = $packet->y; $pk->spawnZ = $packet->z; return $pk; case Info::ANIMATE_PACKET: switch ($packet->action) { case 1: $pk = new CAnimatePacket(); $pk->actionID = 0; $pk->eid = $packet->eid; return $pk; break; case 3: //LeaveBed $pk = new CAnimatePacket(); $pk->actionID = 2; $pk->eid = $packet->eid; return $pk; break; default: echo "AnimatePacket: " . $packet->action . "\n"; break; } return null; case Info::RESPAWN_PACKET: $pk = new CRespawnPacket(); $pk->dimension = 0; $pk->difficulty = $player->getServer()->getDifficulty(); $pk->gamemode = $player->getGamemode(); $pk->levelType = "default"; return $pk; /*case Info::CONTAINER_OPEN_PACKET: $pk = new OpenWindowPacket(); $pk->windowID = $packet->windowid; $pk->inventoryType = $packet->type; $pk->windowTitle = ""; $pk->slots = $packet->slots; return $pk; case Info::CONTAINER_CLOSE_PACKET: $pk = new STCCloseWindowPacket(); $pk->windowID = $packet->windowid; return $pk; case Info::CONTAINER_SET_SLOT_PACKET: echo "ContainerSetSlotPacket: 0x".bin2hex(chr($packet->windowid))."\n"; $pk = new SetSlotPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0x00){ $pk->slot = $packet->slot + 36; }elseif($pk->windowID === 0x78){ $pk->windowID = 0; $pk->slot = $packet->slot + 5; }else{ $pk->slot = $packet->slot; } $pk->item = $packet->item; return $pk; case Info::CONTAINER_SET_CONTENT_PACKET://Bug echo "ContainerSetContentPacket: 0x".bin2hex(chr($packet->windowid))."\n"; if($packet->windowid !== 0x79 and $packet->windowid !== 0x78){ $pk = new WindowItemsPacket(); $pk->windowID = 0; for($i = 0; $i < 5; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } $pk->items[] = $player->getInventory()->getHelmet(); $pk->items[] = $player->getInventory()->getChestplate(); $pk->items[] = $player->getInventory()->getLeggings(); $pk->items[] = $player->getInventory()->getBoots(); if($player->getGamemode() === 0){ for($i = 9; $i < 36; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } }else{ for($i = 0; $i < 27; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } } for($i = 0; $i < 9; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } return $pk; } return null;*/ /*case Info::CONTAINER_OPEN_PACKET: $pk = new OpenWindowPacket(); $pk->windowID = $packet->windowid; $pk->inventoryType = $packet->type; $pk->windowTitle = ""; $pk->slots = $packet->slots; return $pk; case Info::CONTAINER_CLOSE_PACKET: $pk = new STCCloseWindowPacket(); $pk->windowID = $packet->windowid; return $pk; case Info::CONTAINER_SET_SLOT_PACKET: echo "ContainerSetSlotPacket: 0x".bin2hex(chr($packet->windowid))."\n"; $pk = new SetSlotPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0x00){ $pk->slot = $packet->slot + 36; }elseif($pk->windowID === 0x78){ $pk->windowID = 0; $pk->slot = $packet->slot + 5; }else{ $pk->slot = $packet->slot; } $pk->item = $packet->item; return $pk; case Info::CONTAINER_SET_CONTENT_PACKET://Bug echo "ContainerSetContentPacket: 0x".bin2hex(chr($packet->windowid))."\n"; if($packet->windowid !== 0x79 and $packet->windowid !== 0x78){ $pk = new WindowItemsPacket(); $pk->windowID = 0; for($i = 0; $i < 5; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } $pk->items[] = $player->getInventory()->getHelmet(); $pk->items[] = $player->getInventory()->getChestplate(); $pk->items[] = $player->getInventory()->getLeggings(); $pk->items[] = $player->getInventory()->getBoots(); if($player->getGamemode() === 0){ for($i = 9; $i < 36; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } }else{ for($i = 0; $i < 27; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } } for($i = 0; $i < 9; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } return $pk; } return null;*/ case Info::CRAFTING_DATA_PACKET: $player->setSetting(["Recipes" => $packet->entries, "cleanRecipes" => $packet->cleanRecipes]); return null; case Info::BLOCK_ENTITY_DATA_PACKET: $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->read($packet->namedtag); $nbt = $nbt->getData(); if ($nbt["id"] !== Tile::SIGN) { return null; } else { $index = Level::chunkHash($packet->x >> 4, $packet->z >> 4); if (isset($player->usedChunks[$index]) and $player->usedChunks[$index]) { $pk = new UpdateSignPacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->line1 = TextFormat::toJSON($nbt["Text1"]); $pk->line2 = TextFormat::toJSON($nbt["Text2"]); $pk->line3 = TextFormat::toJSON($nbt["Text3"]); $pk->line4 = TextFormat::toJSON($nbt["Text4"]); return $pk; } } return null; case Info::SET_DIFFICULTY_PACKET: $pk = new ServerDifficultyPacket(); $pk->difficulty = $packet->difficulty; return $pk; case Info::SET_PLAYER_GAMETYPE_PACKET: $packets = []; $pk = new PlayerAbilitiesPacket(); $pk->flyingSpeed = 0.05; $pk->walkingSpeed = 0.1; $pk->canFly = ($player->getGamemode() & 0x1) > 0; $pk->damageDisabled = ($player->getGamemode() & 0x1) > 0; $pk->isFlying = false; $pk->isCreative = ($player->getGamemode() & 0x1) > 0; $packets[] = $pk; $pk = new ChangeGameStatePacket(); $pk->reason = 3; $pk->value = $player->getGamemode(); $packets[] = $pk; return $packets; case Info::PLAY_STATUS_PACKET: case Info::PLAYER_LIST_PACKET: case Info::ADVENTURE_SETTINGS_PACKET: case Info::FULL_CHUNK_DATA_PACKET: case Info::BATCH_PACKET: return null; default: echo "[Send] 0x" . bin2hex(chr($packet->pid())) . "\n"; return null; } }
protected function handlePacket(DesktopPlayer $player, $payload) { $pid = ord($payload[0]); $offset = 1; $status = $player->bigBrother_getStatus(); if ($status === 1) { switch ($pid) { case 0x1: $pk = new CTSChatPacket(); break; case 0x2: $pk = new UseEntityPacket(); break; case 0x4: $pk = new PlayerPositionPacket(); break; case 0x5: $pk = new PlayerLookPacket(); break; case 0x6: $pk = new PlayerPositionAndLookPacket(); break; case 0x7: $pk = new PlayerDiggingPacket(); break; case 0x8: $pk = new PlayerBlockPlacementPacket(); break; case 0xd: $pk = new CTSCloseWindowPacket(); break; case 0x16: $pk = new ClientStatusPacket(); break; default: return; } $pk->read($payload, $offset); $this->receivePacket($player, $pk); } elseif ($status === 0) { if ($pid === 0x0) { $pk = new LoginStartPacket(); $pk->read($payload, $offset); $player->bigBrother_handleAuthentication($this->plugin, $pk->name, $this->plugin->isOnlineMode()); } elseif ($pid === 0x1 and $this->plugin->isOnlineMode()) { $pk = new EncryptionResponsePacket(); $pk->read($payload, $offset); $player->bigBrother_processAuthentication($this->plugin, $pk); } else { $player->close(TextFormat::YELLOW . $player->getName() . " has left the game", "Unexpected packet {$pid}"); } } }
protected function handlePacket(DesktopPlayer $player, $payload) { echo "[Receive:Interface] 0x" . bin2hex(chr($payload)) . "\n"; $pid = ord($payload[0]); $offset = 1; $status = $player->bigBrother_getStatus(); if ($status === 1) { switch ($pid) { case 0x0: $pk = new TeleportConfirmPacket(); break; /*case 0x00: $pk = new KeepAlivePacket(); break; case 0x01: $pk = new CTSChatPacket(); break; case 0x02: $pk = new UseEntityPacket(); break; case 0x03: $pk = new PlayerPacket(); break; case 0x04: $pk = new PlayerPositionPacket(); break; case 0x05: $pk = new PlayerLookPacket(); break; case 0x06: $pk = new PlayerPositionAndLookPacket(); break; case 0x07: $pk = new PlayerDiggingPacket(); break; case 0x08: $pk = new PlayerBlockPlacementPacket(); break; case 0x09: $pk = new HeldItemChangePacket(); break; case 0x0a: $pk = new PlayerArmSwingPacket(); break; case 0x0b: $pk = new AnimatePacket(); break; case 0x0d: $pk = new CTSCloseWindowPacket(); break; case 0x0e: break; case 0x0f: break; case 0x10: $pk = new CreativeInventoryActionPacket(); break; case 0x11: break; case 0x12: $pk = new CPlayerAbilitiesPacket(); break; case 0x14: $pk = new CTabCompletePacket(); break; case 0x15: $pk = new ClientSettingsPacket(); break; case 0x16: $pk = new ClientStatusPacket(); break; case 0x17: $pk = new PluginMessagePacket(); break; case 0x18: break; case 0x19: $pk = new ResourcePackStatusPacket(); break;*/ /*case 0x00: $pk = new KeepAlivePacket(); break; case 0x01: $pk = new CTSChatPacket(); break; case 0x02: $pk = new UseEntityPacket(); break; case 0x03: $pk = new PlayerPacket(); break; case 0x04: $pk = new PlayerPositionPacket(); break; case 0x05: $pk = new PlayerLookPacket(); break; case 0x06: $pk = new PlayerPositionAndLookPacket(); break; case 0x07: $pk = new PlayerDiggingPacket(); break; case 0x08: $pk = new PlayerBlockPlacementPacket(); break; case 0x09: $pk = new HeldItemChangePacket(); break; case 0x0a: $pk = new PlayerArmSwingPacket(); break; case 0x0b: $pk = new AnimatePacket(); break; case 0x0d: $pk = new CTSCloseWindowPacket(); break; case 0x0e: break; case 0x0f: break; case 0x10: $pk = new CreativeInventoryActionPacket(); break; case 0x11: break; case 0x12: $pk = new CPlayerAbilitiesPacket(); break; case 0x14: $pk = new CTabCompletePacket(); break; case 0x15: $pk = new ClientSettingsPacket(); break; case 0x16: $pk = new ClientStatusPacket(); break; case 0x17: $pk = new PluginMessagePacket(); break; case 0x18: break; case 0x19: $pk = new ResourcePackStatusPacket(); break;*/ default: echo "[Receive] 0x" . bin2hex(chr($pid)) . "\n"; //Debug return; } $pk->read($payload, $offset); $this->receivePacket($player, $pk); } elseif ($status === 0) { if ($pid === 0x0) { echo "LoginStart\n"; $pk = new LoginStartPacket(); $pk->read($payload, $offset); $player->bigBrother_handleAuthentication($this->plugin, $pk->name, $this->plugin->isOnlineMode()); } elseif ($pid === 0x1 and $this->plugin->isOnlineMode()) { echo "EncryptionResponse\n"; $pk = new EncryptionResponsePacket(); $pk->read($payload, $offset); $player->bigBrother_processAuthentication($this->plugin, $pk); } else { $player->close($player->getLeaveMessage(), "Unexpected packet {$pid}"); } } }
public function serverToInterface(DesktopPlayer $player, DataPacket $packet) { switch ($packet->pid()) { case Info::UPDATE_BLOCK_PACKET: $pk = new BlockChangePacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->blockId = $packet->block; $pk->blockMeta = $packet->meta; return $pk; case Info::START_GAME_PACKET: $packets = []; $pk = new JoinGamePacket(); $pk->eid = $packet->eid; $pk->gamemode = $player->getGamemode(); $pk->dimension = 0; $pk->difficulty = $player->getServer()->getDifficulty(); $pk->maxPlayers = $player->getServer()->getMaxPlayers(); $pk->levelType = "default"; $packets[] = $pk; $pk = new PlayerAbilitiesPacket(); $pk->flyingSpeed = 0.05; $pk->walkingSpeed = 0.1; $pk->canFly = ($player->getGamemode() & 0x1) > 0; $pk->damageDisabled = ($player->getGamemode() & 0x1) > 0; $pk->isFlying = false; $pk->isCreative = ($player->getGamemode() & 0x1) > 0; if ($player->spawned === true) { $packets = [$pk]; $pk = new ChangeGameStatePacket(); $pk->reason = 3; $pk->value = $player->getGamemode(); $packets[] = $pk; return $packets; } else { $packets[] = $pk; } $pk = new SpawnPositionPacket(); $pk->spawnX = $packet->spawnX; $pk->spawnY = $packet->spawnY; $pk->spawnZ = $packet->spawnZ; $packets[] = $pk; $pk = new PositionAndLookPacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $player->yaw; $pk->pitch = $player->pitch; $pk->onGround = $player->isOnGround(); $packets[] = $pk; return $packets; case Info::SET_HEALTH_PACKET: $pk = new UpdateHealthPacket(); $pk->health = $packet->health; $pk->food = 20; $pk->saturation = 5; return $pk; case Info::TEXT_PACKET: $pk = new STCChatPacket(); $pk->message = TextFormat::toJSON($packet->message); return $pk; case Info::SET_TIME_PACKET: $pk = new TimeUpdatePacket(); $pk->age = $packet->time; $pk->time = $packet->time; //TODO: calculate offset from MCPE return $pk; case Info::SET_SPAWN_POSITION_PACKET: $pk = new SpawnPositionPacket(); $pk->spawnX = $packet->x; $pk->spawnY = $packet->y; $pk->spawnZ = $packet->z; return $pk; case Info::REMOVE_ENTITY_PACKET: case Info::REMOVE_PLAYER_PACKET: $pk = new DestroyEntitiesPacket(); $pk->ids[] = $packet->eid; return $pk; case Info::MOVE_PLAYER_PACKET: if ($packet->eid === 0) { $pk = new PositionAndLookPacket(); $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $pk->onGround = $player->isOnGround(); return $pk; } else { $packets = []; $pk = new EntityTeleportPacket(); $pk->eid = $packet->eid; $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $packets[] = $pk; $pk = new EntityHeadLookPacket(); $pk->eid = $packet->eid; $pk->yaw = $packet->yaw; $packets[] = $pk; return $packets; } case Info::MOVE_ENTITY_PACKET: $packets = []; foreach ($packet->entities as $d) { $pk = new EntityTeleportPacket(); $pk->eid = $d[0]; $pk->x = $d[1]; $pk->y = $d[2]; $pk->z = $d[3]; $pk->yaw = $d[4]; $pk->pitch = $d[5]; $packets[] = $pk; $pk = new EntityHeadLookPacket(); $pk->eid = $d[0]; $pk->yaw = $d[4]; $packets[] = $pk; } return $packets; case Info::SET_ENTITY_MOTION_PACKET: $packets = []; foreach ($packet->entities as $d) { $pk = new EntityVelocityPacket(); $pk->eid = $d[0]; $pk->velocityX = $d[1]; $pk->velocityY = $d[2]; $pk->velocityZ = $d[3]; $packets[] = $pk; } return $packets; /* case Info::CONTAINER_CLOSE_PACKET: $pk = new STCCloseWindowPacket(); $pk->windowID = $packet->windowid; return $pk; case Info::CONTAINER_OPEN_PACKET: $pk = new OpenWindowPacket(); $pk->windowID = $packet->windowid; $pk->inventoryType = $packet->type; $pk->windowTitle = ""; $pk->slots = $packet->slots; return $pk; case Info::CONTAINER_SET_SLOT_PACKET: $pk = new SetSlotPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0){ $pk->slot = $packet->slot + 9; }elseif($pk->windowID === 0x78){ $pk->windowID = 0; $pk->slot = $packet->slot + 5; }else{ $pk->slot = $packet->slot; } $pk->item = $packet->item; return $pk; case Info::CONTAINER_SET_CONTENT_PACKET: $pk = new WindowItemsPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0 or $pk->windowID === 0x78){ $pk->windowID = 0; for($i = 0; $i < 5; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } $pk->items[] = $player->getInventory()->getHelmet(); $pk->items[] = $player->getInventory()->getChestplate(); $pk->items[] = $player->getInventory()->getLeggings(); $pk->items[] = $player->getInventory()->getBoots(); $slots = $player->getInventory()->getSize(); for($i = 0; $i < $slots; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } }else{ $pk->items = $packet->slots; } return $pk; */ /* case Info::CONTAINER_CLOSE_PACKET: $pk = new STCCloseWindowPacket(); $pk->windowID = $packet->windowid; return $pk; case Info::CONTAINER_OPEN_PACKET: $pk = new OpenWindowPacket(); $pk->windowID = $packet->windowid; $pk->inventoryType = $packet->type; $pk->windowTitle = ""; $pk->slots = $packet->slots; return $pk; case Info::CONTAINER_SET_SLOT_PACKET: $pk = new SetSlotPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0){ $pk->slot = $packet->slot + 9; }elseif($pk->windowID === 0x78){ $pk->windowID = 0; $pk->slot = $packet->slot + 5; }else{ $pk->slot = $packet->slot; } $pk->item = $packet->item; return $pk; case Info::CONTAINER_SET_CONTENT_PACKET: $pk = new WindowItemsPacket(); $pk->windowID = $packet->windowid; if($pk->windowID === 0 or $pk->windowID === 0x78){ $pk->windowID = 0; for($i = 0; $i < 5; ++$i){ $pk->items[] = Item::get(Item::AIR, 0, 0); } $pk->items[] = $player->getInventory()->getHelmet(); $pk->items[] = $player->getInventory()->getChestplate(); $pk->items[] = $player->getInventory()->getLeggings(); $pk->items[] = $player->getInventory()->getBoots(); $slots = $player->getInventory()->getSize(); for($i = 0; $i < $slots; ++$i){ $pk->items[] = $player->getInventory()->getItem($i); } }else{ $pk->items = $packet->slots; } return $pk; */ case Info::ADD_ITEM_ENTITY_PACKET: $packets = []; $pk = new SpawnObjectPacket(); $pk->eid = $packet->eid; $pk->type = 2; $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $packets[] = $pk; $pk = new EntityMetadataPacket(); $pk->eid = $packet->eid; $pk->metadata = $pk->metadata = [0 => ["type" => 0, "value" => 0], 10 => ["type" => 5, "value" => $packet->item]]; $packets[] = $pk; return $packets; case Info::ADD_PLAYER_PACKET: $packets = []; $pk = new SpawnPlayerPacket(); $pk->name = $packet->username; $pk->eid = $packet->eid; $pk->uuid = Binary::UUIDtoString("00000000000030008000000000000000"); $pk->x = $packet->x; $pk->z = $packet->y; $pk->y = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $pk->item = 0; $pk->metadata = $packet->metadata; $packets[] = $pk; $pk = new EntityTeleportPacket(); $pk->eid = $packet->eid; $pk->x = $packet->x; $pk->y = $packet->y; $pk->z = $packet->z; $pk->yaw = $packet->yaw; $pk->pitch = $packet->pitch; $packets[] = $pk; return $packets; default: return null; } }