Exemple #1
0
void packet_send_open_window(struct client *client, uint8_t type, const char *title, uint8_t slots)
{
    bedrock_packet packet;
    uint8_t use_title = 1;

    if (!title)
    {
        title = "";
        use_title = 0;
    }

    while (++window_id == 0);

#if 0
    packet_init(&packet, SERVER_OPEN_WINDOW);

    packet_pack_byte(&packet, window_id);
    packet_pack_byte(&packet, type);
    packet_pack_string(&packet, title);
    packet_pack_byte(&packet, slots);
    packet_pack_byte(&packet, use_title);

    client_send_packet(client, &packet);

    client->window_data.id = window_id;
    client->window_data.type = type;
#endif
}
void packet_send_player_list_item(struct client *client, struct client *c, uint8_t online)
{
	bedrock_packet packet;

#if 0
	packet_init(&packet, SERVER_PLAYER_LIST);

	packet_pack_string(&packet, c->name);
	packet_pack_byte(&packet, online);
	packet_pack_short(&packet, c->ping);

	client_send_packet(client, &packet);
#endif
}
void packet_send_encryption_request(struct client *client)
{
	int16_t pubkey_len = crypto_pubkey_len();
	int16_t verify_token_length = BEDROCK_VERIFY_TOKEN_LEN;
	bedrock_packet packet;

	packet_init(&packet, LOGIN_SERVER_ENCRYPTION_REQUEST);

	packet_pack_string(&packet, "-"); // server ID

	packet_pack_int(&packet, &pubkey_len, sizeof(pubkey_len));
	packet_pack(&packet, crypto_pubkey(), pubkey_len);

	packet_pack_int(&packet, &verify_token_length, sizeof(verify_token_length));
	packet_pack(&packet, crypto_auth_token(), BEDROCK_VERIFY_TOKEN_LEN);

	client_send_packet(client, &packet);
}
Exemple #4
0
void packet_send_join_game(struct client *client)
{
	bedrock_packet packet;
	int32_t dimension;
	uint8_t b;

	nbt_copy(client->data, TAG_INT, &dimension, sizeof(dimension), 1, "Dimension");

	packet_init(&packet, SERVER_JOIN_GAME);

	packet_pack_int(&packet, &client->id, sizeof(client->id)); /* Entity ID */
	b = client->gamemode;
	packet_pack_int(&packet, &b, sizeof(b));
	b = dimension;
	packet_pack_int(&packet, &b, sizeof(b));
	packet_pack_int(&packet, nbt_read(client->world->data, TAG_BYTE, 2, "Data", "hardcore"), sizeof(uint8_t)); /* hardcore */
	b = server_maxusers;
	packet_pack_int(&packet, &b, sizeof(b)); /* Max players */
	packet_pack_string(&packet, nbt_read_string(client->world->data, 2, "Data", "generatorName")); /* Level type */

	client_send_packet(client, &packet);

	bedrock_assert(client->state == STATE_LOGGED_IN, ;);