Skip to content

Commit

Permalink
fix: hiding seeds from the client
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Jun 14, 2024
1 parent 1bc6023 commit c027ebd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 42 deletions.
35 changes: 0 additions & 35 deletions include/bedrock/network/packet/start_game_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,16 @@
#include <vector>

#include "bedrock/bedrock.h"
#include "bedrock/core/math/vec2.h"
#include "bedrock/core/math/vec3.h"
#include "bedrock/core/utility/uuid.h"
#include "bedrock/forward.h"
#include "bedrock/nbt/compound_tag.h"
#include "bedrock/network/packet.h"
#include "bedrock/server/packs/content_identity.h"
#include "bedrock/world/actor/actor_runtime_id.h"
#include "bedrock/world/actor/actor_unique_id.h"
#include "bedrock/world/actor/player/synced_player_movement_settings.h"
#include "bedrock/world/level/game_type.h"
#include "bedrock/world/level/level_settings.h"

class NetworkPermissions {
public:
bool unknown;
};

class StartGamePacket : public Packet {
public:
ENDSTONE_HOOK virtual void write(BinaryStream &) const;

private:
mutable LevelSettings settings_; // +48
ActorUniqueID entity_id_; // +1296 (+1072)
ActorRuntimeID runtime_id_; // +1304 (+1080)
GameType game_type_; // +1312 (+1088)
Vec3 position_; // +1316
Vec2 rotation_; // +1328
std::string level_id_; // +1336
std::string level_name_; // +1368
ContentIdentity template_content_identity_; // +1400
mce::UUID world_template_id_; // +1424
bool is_trial_; // +1440
SyncedPlayerMovementSettings movement_settings_; // +1444
std::uint64_t level_current_time_; // +1456
int enchantment_seed_; // +1464
std::string multiplayer_correlation_id_; // +1472
std::vector<void *> item_data_; // +1504
bool enable_item_stack_net_manager_; // +1528
std::string server_version_; // +1536
CompoundTag player_property_data_; // +1568
std::uint64_t server_block_type_registry_checksum_; // +1592
bool server_enabled_client_side_generation_; // +1600 (+1352)
bool block_network_ids_are_hashes_; // +1601 (+1353)
NetworkPermissions network_permissions_; // +1602 (+1354)
std::vector<std::pair<std::string, CompoundTag>> block_properties_; // +1608 (+1360)
};
6 changes: 0 additions & 6 deletions include/bedrock/world/level/level_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@ class LevelSettings {

private:
LevelSeed64 seed_;
#ifdef _WIN32
size_t pad_[1248 / 8 - 1];
#else
size_t pad_[1024 / 8 - 1];
#endif
};
BEDROCK_STATIC_ASSERT_SIZE(LevelSettings, 1248, 1024);
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@

#include "bedrock/network/packet/start_game_packet.h"

#include <entt/entt.hpp>

#include "endstone/detail/hook.h"
#include "endstone/detail/level/level.h"
#include "endstone/detail/server.h"

using endstone::detail::EndstoneLevel;
using endstone::detail::EndstoneServer;

void StartGamePacket::write(BinaryStream &stream) const
{
if (!server_enabled_client_side_generation_) {
static bool client_side_generation_enabled = []() {
auto &server = entt::locator<EndstoneServer>::value();
auto *level = static_cast<EndstoneLevel *>(server.getLevels()[0]);
return level->getHandle().isClientSideGenerationEnabled();
}();

if (!client_side_generation_enabled) {
settings_.setRandomSeed({0});
}

Expand Down

0 comments on commit c027ebd

Please sign in to comment.