diff --git a/include/bedrock/command/command_context.h b/include/bedrock/command/command_context.h index 996970abd..8ff8c2687 100644 --- a/include/bedrock/command/command_context.h +++ b/include/bedrock/command/command_context.h @@ -22,14 +22,14 @@ class CommandContext { public: - CommandContext(std::string command_line, std::unique_ptr origin, int version) - : command_line_(std::move(command_line)), origin_(std::move(origin)), version_(version) + CommandContext(std::string command, std::unique_ptr origin, int version) + : command_(std::move(command)), origin_(std::move(origin)), version_(version) { } - [[nodiscard]] std::string getCommandLine() const + [[nodiscard]] std::string getCommand() const { - return command_line_; + return command_; } [[nodiscard]] CommandOrigin &getOrigin() const @@ -38,7 +38,7 @@ class CommandContext { } private: - std::string command_line_; // +0 + std::string command_; // +0 std::unique_ptr origin_; // +32 int version_; // +40 }; diff --git a/include/bedrock/command/command_output.h b/include/bedrock/command/command_output.h index 0d08fda99..5075a88cc 100644 --- a/include/bedrock/command/command_output.h +++ b/include/bedrock/command/command_output.h @@ -42,8 +42,8 @@ class CommandOutputMessage { class CommandOutputParameter { public: - std::string text; // +0 - int count; // +32 + std::string string; // +0 + int count; // +32 }; class CommandOutput { diff --git a/include/bedrock/command/command_version.h b/include/bedrock/command/command_version.h index 0d9d8fa7e..00d8f990d 100644 --- a/include/bedrock/command/command_version.h +++ b/include/bedrock/command/command_version.h @@ -15,8 +15,8 @@ #pragma once struct CommandVersion { - int min; - int max; + int from; + int to; static const int CurrentVersion; }; diff --git a/include/bedrock/command/minecraft_commands.h b/include/bedrock/command/minecraft_commands.h index 757b38810..6562c41b8 100644 --- a/include/bedrock/command/minecraft_commands.h +++ b/include/bedrock/command/minecraft_commands.h @@ -47,4 +47,3 @@ class MinecraftCommands { std::unique_ptr output_sender_; // +8 std::unique_ptr registry_; // +16 }; -BEDROCK_STATIC_ASSERT_SIZE(MinecraftCommands, 24, 24); diff --git a/include/bedrock/common/minecraft.h b/include/bedrock/common/minecraft.h index 4a7960883..c3a85cdf0 100644 --- a/include/bedrock/common/minecraft.h +++ b/include/bedrock/common/minecraft.h @@ -30,19 +30,18 @@ class Minecraft : public Bedrock::EnableNonOwnerReferences { private: GameCallbacks *callbacks_; // +24 IMinecraftEventing *eventing_; // +32 - std::unique_ptr resource_pack_manager_; // +40 + std::unique_ptr resource_loader_; // +40 std::unique_ptr structure_manager_; // +48 std::shared_ptr game_module_server_; // +56 AllowList *allow_list_; // +72 PermissionsFile *permissions_file_; // +80 - std::unique_ptr private_key_manager_; // +88 - std::string unk3_; // +96 + std::unique_ptr server_keys_; // +88 + std::string save_game_path_; // +96 Bedrock::NonOwnerPointer file_path_manager_; // +128 - ServerMetrics *metrics_; // +144 - bool unk4_; // +152 - bool unk5_; // +153 - double elapsed_time_seconds_; // +160 - double last_update_seconds_; // +168 - std::chrono::seconds unk6_; // +176 + ServerMetrics *server_metrics_; // +144 + bool corruption_detected_; // +152 + double frame_duration_; // +160 + double last_update_; // +168 + std::chrono::seconds max_player_idle_time_; // +176 std::unique_ptr commands_; // +184 }; diff --git a/include/bedrock/forward.h b/include/bedrock/forward.h index b8e20ef87..9abbcac05 100644 --- a/include/bedrock/forward.h +++ b/include/bedrock/forward.h @@ -139,6 +139,7 @@ class ResolvedItemIconInfo; class ResolvedTextObject; class ResourceLoadManager; class ResourcePackManager; +class RopeSystem; class SavedDataStorage; class Scheduler; class Scoreboard; diff --git a/include/bedrock/hashed_string.h b/include/bedrock/hashed_string.h index e771e6440..25524c5d8 100644 --- a/include/bedrock/hashed_string.h +++ b/include/bedrock/hashed_string.h @@ -19,7 +19,7 @@ class HashedString { public: - std::uint64_t hash; + std::uint64_t str_hash; std::string str; const HashedString *last_match; }; diff --git a/include/bedrock/mce.h b/include/bedrock/mce.h index 53c43b4d7..765b3b137 100644 --- a/include/bedrock/mce.h +++ b/include/bedrock/mce.h @@ -23,14 +23,14 @@ namespace mce { class UUID { public: - std::int64_t msb; // most significant bits - std::int64_t lsb; // least significant bits + std::int64_t data_0; // most significant bits + std::int64_t data_1; // least significant bits static mce::UUID fromEndstone(const endstone::UUID &in) { mce::UUID out; - auto *ms = reinterpret_cast(&out.msb); - auto *ls = reinterpret_cast(&out.lsb); + auto *ms = reinterpret_cast(&out.data_0); + auto *ls = reinterpret_cast(&out.data_1); std::reverse_copy(in.data + 0, in.data + 4, ms + 4); std::reverse_copy(in.data + 4, in.data + 6, ms + 2); std::reverse_copy(in.data + 6, in.data + 8, ms + 0); @@ -43,8 +43,8 @@ class UUID { [[nodiscard]] endstone::UUID toEndstone() const { auto out = endstone::UUID{}; - const auto *ms = reinterpret_cast(&msb); - const auto *ls = reinterpret_cast(&lsb); + const auto *ms = reinterpret_cast(&data_0); + const auto *ls = reinterpret_cast(&data_1); std::reverse_copy(ms + 4, ms + 8, out.data + 0); std::reverse_copy(ms + 2, ms + 4, out.data + 4); std::reverse_copy(ms + 0, ms + 2, out.data + 6); diff --git a/include/bedrock/network/network_identifier.h b/include/bedrock/network/network_identifier.h index f740c0433..865bca6db 100644 --- a/include/bedrock/network/network_identifier.h +++ b/include/bedrock/network/network_identifier.h @@ -30,14 +30,14 @@ class NetworkIdentifier { Generic = 4, }; - std::uint32_t nether_net_id; // +0 - RakNet::RakNetGUID raknet_guid; // +8 - union { // - sockaddr_storage sa_stor; // - sockaddr_in6 addr6; // - sockaddr_in addr4; // - } address; // +24 - Type type; // +152 + std::uint32_t nether_net_id; // +0 + RakNet::RakNetGUID guid; // +8 + union { // + sockaddr_storage sa_stor; // + sockaddr_in6 addr6; // + sockaddr_in addr4; // + } sock; // +24 + Type type; // +152 [[nodiscard]] std::string getAddress() const; [[nodiscard]] std::uint16_t getPort() const; diff --git a/include/bedrock/world/actor/actor.h b/include/bedrock/world/actor/actor.h index 75bb3c03c..0aefe79bc 100644 --- a/include/bedrock/world/actor/actor.h +++ b/include/bedrock/world/actor/actor.h @@ -227,25 +227,25 @@ class Actor { template [[nodiscard]] bool hasComponent() const { - return context_.hasComponent(); + return entity_context_.hasComponent(); } template Component *tryGetComponent() { - return context_.tryGetComponent(); + return entity_context_.tryGetComponent(); } template Component *tryGetComponent() const { - return context_.tryGetComponent(); + return entity_context_.tryGetComponent(); } template gsl::not_null getPersistentComponent() const { - return context_.tryGetComponent(); + return entity_context_.tryGetComponent(); }; BEDROCK_API void setDimension(WeakRef); @@ -272,28 +272,29 @@ class Actor { static Actor *tryGetFromEntity(EntityContext const &, bool include_removed); protected: - EntityContext context_; // +8 - ActorInitializationMethod initialization_method_; // +32 - std::string unknown2_; // +40 - std::array unknown3_; // +72 (+64) - std::int16_t unknown4_; // +232 (+224) - ActorDefinitionGroup *actor_definitions_; // +240 (+232) - std::unique_ptr actor_definition_desc_; // +248 (+240) - std::shared_ptr unknown5_; // +256 (+248) - std::string unknown6_; // +272 (+264) - char unknown7_[72]; // +304 (+288) - std::map>> unknown8_; // +376 (+360) - std::int32_t unknown9_; // +392 (+384) - SynchedActorDataEntityWrapper data_; // +400 (+392) - std::unique_ptr spatial_data_; // +448 (+440) - Vec3 unknown10_; // +456 (+448) - char unknown11_[116]; // +468 (+460) - WeakRef dimension_; // +584 (+576) - Level *level_; // +600 (+592) - HashedString renderer_id_; // +608 (+600) - ActorCategory categories_; // +656 (+640) - BuiltInActorComponents components_; // +664 (+648) - HashedString unknown13_; // +696 (+680) + EntityContext entity_context_; // +8 + ActorInitializationMethod init_method_; // +32 + std::string custom_init_event_name_; // +40 + std::array unknown3_; // +72 (+64) + bool force_init_method_to_spawn_on_reload_; // +232 (+224) + bool added_; // +233 (+225) + ActorDefinitionGroup *definitions_; // +240 (+232) + std::unique_ptr current_description_; // +248 (+240) + std::shared_ptr leash_rope_system_; // +256 (+248) + std::string unknown6_; // +272 (+264) + char unknown7_[72]; // +304 (+288) + std::map>> unknown8_; // +376 (+360) + std::int32_t unknown9_; // +392 (+384) + SynchedActorDataEntityWrapper entity_data_; // +400 (+392) + std::unique_ptr network_data_; // +448 (+440) + Vec3 sent_delta_; // +456 (+448) + char unknown11_[116]; // +468 (+460) + WeakRef dimension_; // +584 (+576) + Level *level_; // +600 (+592) + HashedString actor_renderer_id_; // +608 (+600) + ActorCategory categories_; // +656 (+640) + BuiltInActorComponents built_in_components_; // +664 (+648) + HashedString actor_renderer_id_that_animation_component_was_initialized_with_; // +696 (+680) public: [[nodiscard]] endstone::detail::EndstoneActor &getEndstoneActor() const; diff --git a/include/bedrock/world/actor/actor_location.h b/include/bedrock/world/actor/actor_location.h index bdfb36e66..317ea0c22 100644 --- a/include/bedrock/world/actor/actor_location.h +++ b/include/bedrock/world/actor/actor_location.h @@ -16,5 +16,12 @@ enum class ActorLocation { Feet = 0, - Eyes = 6 + Body = 1, + WeaponAttachPoint = 2, + Head = 3, + DropAttachPoint = 4, + ExplosionPoint = 5, + Eyes = 6, + BreathingPoint = 7, + Mouth = 8 }; diff --git a/include/bedrock/world/actor/actor_runtime_id.h b/include/bedrock/world/actor/actor_runtime_id.h index 0ab02b947..4bc7b6f4f 100644 --- a/include/bedrock/world/actor/actor_runtime_id.h +++ b/include/bedrock/world/actor/actor_runtime_id.h @@ -19,5 +19,5 @@ class ActorRuntimeID { public: - std::uint64_t id{0}; + std::uint64_t raw_id{0}; }; diff --git a/include/bedrock/world/actor/actor_unique_id.h b/include/bedrock/world/actor/actor_unique_id.h index 7656f480b..6e6776aa6 100644 --- a/include/bedrock/world/actor/actor_unique_id.h +++ b/include/bedrock/world/actor/actor_unique_id.h @@ -18,5 +18,5 @@ class ActorUniqueID { public: - std::int64_t id{-1}; + std::int64_t raw_id{-1}; }; diff --git a/include/bedrock/world/actor/components/actor_game_type_component.h b/include/bedrock/world/actor/components/actor_game_type_component.h index 979cee628..51452468d 100644 --- a/include/bedrock/world/actor/components/actor_game_type_component.h +++ b/include/bedrock/world/actor/components/actor_game_type_component.h @@ -14,6 +14,8 @@ #pragma once +#include "bedrock/world/level/game_type.h" + struct ActorGameTypeComponent { GameType game_type; }; diff --git a/include/bedrock/world/actor/components/actor_owner_component.h b/include/bedrock/world/actor/components/actor_owner_component.h index 4b5808adc..4350f7935 100644 --- a/include/bedrock/world/actor/components/actor_owner_component.h +++ b/include/bedrock/world/actor/components/actor_owner_component.h @@ -18,6 +18,6 @@ class ActorOwnerComponent { public: - Actor *owner; + std::unique_ptr actor; }; // static_assert(entt::type_hash::value() == 0x132A5818); diff --git a/include/bedrock/world/actor/components/actor_unique_id_component.h b/include/bedrock/world/actor/components/actor_unique_id_component.h index 5f9167478..5b01b34b1 100644 --- a/include/bedrock/world/actor/components/actor_unique_id_component.h +++ b/include/bedrock/world/actor/components/actor_unique_id_component.h @@ -17,5 +17,5 @@ #include "bedrock/world/actor/actor.h" struct ActorUniqueIDComponent { - ActorUniqueID id; + ActorUniqueID unique_id; }; diff --git a/include/bedrock/world/actor/components/post_tick_position_delta_component.h b/include/bedrock/world/actor/components/post_tick_position_delta_component.h index 28e7ff9dc..4ecf22a99 100644 --- a/include/bedrock/world/actor/components/post_tick_position_delta_component.h +++ b/include/bedrock/world/actor/components/post_tick_position_delta_component.h @@ -14,8 +14,6 @@ #pragma once -#include "bedrock/world/math/vec3.h" +#include "bedrock/world/actor/components/vec3_component.h" -struct PostTickPositionDeltaComponent { - Vec3 position_delta_; -}; +struct PostTickPositionDeltaComponent : public Vec3Component {}; diff --git a/include/bedrock/world/actor/components/runtime_id_component.h b/include/bedrock/world/actor/components/runtime_id_component.h index 43723cc0c..16ec906fc 100644 --- a/include/bedrock/world/actor/components/runtime_id_component.h +++ b/include/bedrock/world/actor/components/runtime_id_component.h @@ -17,5 +17,5 @@ #include "bedrock/world/actor/actor.h" struct RuntimeIDComponent { - ActorRuntimeID id; + ActorRuntimeID runtime_id; }; diff --git a/include/bedrock/world/actor/components/vec3_component.h b/include/bedrock/world/actor/components/vec3_component.h new file mode 100644 index 000000000..e24cab21d --- /dev/null +++ b/include/bedrock/world/actor/components/vec3_component.h @@ -0,0 +1,21 @@ +// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "bedrock/world/math/vec3.h" + +struct Vec3Component { + Vec3 value; +}; diff --git a/include/bedrock/world/actor/player/abilities/ability.h b/include/bedrock/world/actor/player/abilities/ability.h index f4c537870..6c0a990f5 100644 --- a/include/bedrock/world/actor/player/abilities/ability.h +++ b/include/bedrock/world/actor/player/abilities/ability.h @@ -24,10 +24,16 @@ class Ability { Bool = 2, Float = 3, }; + enum class Options { Default = 0 }; + union Value { + bool bool_val; + float float_val; + }; + Ability() = default; [[nodiscard]] Type getType() const @@ -37,20 +43,17 @@ class Ability { [[nodiscard]] bool getBool() const { - return type_ == Type::Bool ? value_.b : false; + return type_ == Type::Bool ? value_.bool_val : false; } [[nodiscard]] float getFloat() const { - return type_ == Type::Float ? value_.f : 0.0F; + return type_ == Type::Float ? value_.float_val : 0.0F; } private: Type type_; - union { - bool b; - float f; - } value_; + Value value_; Options options_; }; BEDROCK_STATIC_ASSERT_SIZE(Ability, 12, 12); diff --git a/include/bedrock/world/item/item_stack_base.h b/include/bedrock/world/item/item_stack_base.h index a2dd86108..8c26aa9b7 100644 --- a/include/bedrock/world/item/item_stack_base.h +++ b/include/bedrock/world/item/item_stack_base.h @@ -43,9 +43,9 @@ class ItemStackBase { std::chrono::steady_clock::time_point pick_up_time_; // +40 bool show_pick_up_; // +48 bool was_picked_up_; // +49 - std::vector can_place_on_; // +56 + std::vector can_place_on_; // +56 std::uint64_t can_place_on_hash_; // +80 - std::vector can_destroy_; // +88 + std::vector can_destroy_; // +88 std::uint64_t can_destroy_hash_; // +112 Tick blocking_tick_; // +120 std::unique_ptr charged_item_; // +128 diff --git a/include/bedrock/world/level/dimension/dimension.h b/include/bedrock/world/level/dimension/dimension.h index 7ed98c441..fe0986d68 100644 --- a/include/bedrock/world/level/dimension/dimension.h +++ b/include/bedrock/world/level/dimension/dimension.h @@ -28,19 +28,23 @@ class Level; -class Dimension : public IDimension, public LevelListener, public SavedData, public Bedrock::EnableNonOwnerReferences { +class Dimension : public IDimension, + public LevelListener, + public SavedData, + public Bedrock::EnableNonOwnerReferences, + public std::enable_shared_from_this { public: [[nodiscard]] Level &getLevel() const; [[nodiscard]] const std::string &getName() const; // Endstone private: - WeakRef weak_ref_; // +88 (+80) - std::vector chunk_transfers_; // +104 (+96) - std::unordered_map> unloaded_transfers_; // +128 (+120) - Level *level_; // +192 (+160) - DimensionHeightRange height_range_; // +200 (+168) - BlockSource *block_source_; // +208 (+176) - size_t pad_[14]; // - std::string name_; // +328 (+296) - AutomaticID id_; // +360 (+320) + std::vector actor_chunk_transfer_queue_; // +104 (+96) + std::unordered_map> // + actor_unloaded_chunk_transfer_queue_; // +128 (+120) + Level *level_; // +192 (+160) + DimensionHeightRange height_range_; // +200 (+168) + BlockSource *block_source_; // +208 (+176) + size_t pad_[14]; // + std::string name_; // +328 (+296) + AutomaticID id_; // +360 (+320) }; diff --git a/include/bedrock/world/level/dimension/dimension_height_range.h b/include/bedrock/world/level/dimension/dimension_height_range.h index 2c6c56115..dec569c03 100644 --- a/include/bedrock/world/level/dimension/dimension_height_range.h +++ b/include/bedrock/world/level/dimension/dimension_height_range.h @@ -18,6 +18,6 @@ class DimensionHeightRange { public: - std::int16_t min_height; - std::int16_t max_height; + std::int16_t min; + std::int16_t max; }; diff --git a/include/bedrock/world/level/event/event_ref.h b/include/bedrock/world/level/event/event_ref.h index 49d05cf19..b8e8dd6b6 100644 --- a/include/bedrock/world/level/event/event_ref.h +++ b/include/bedrock/world/level/event/event_ref.h @@ -17,5 +17,5 @@ template class EventRef { public: - E reference; + E variant; }; diff --git a/include/bedrock/world/level/tick.h b/include/bedrock/world/level/tick.h index 9dbeb0026..8bb3ad116 100644 --- a/include/bedrock/world/level/tick.h +++ b/include/bedrock/world/level/tick.h @@ -18,11 +18,5 @@ class Tick { public: - [[nodiscard]] std::uint64_t value() const - { - return t_; - } - -private: - std::uint64_t t_; + std::uint64_t tick_id; }; diff --git a/src/endstone_core/actor/actor.cpp b/src/endstone_core/actor/actor.cpp index 66eb60331..873a8dd8f 100644 --- a/src/endstone_core/actor/actor.cpp +++ b/src/endstone_core/actor/actor.cpp @@ -100,7 +100,7 @@ void EndstoneActor::setOp(bool value) std::uint64_t EndstoneActor::getRuntimeId() const { - return actor_.getRuntimeID().id; + return actor_.getRuntimeID().raw_id; } Location EndstoneActor::getLocation() const @@ -121,7 +121,7 @@ Vector EndstoneActor::getVelocity() const } auto *component = actor->tryGetComponent(); if (component) { - const auto &delta = component->position_delta_; + const auto &delta = component->value; return {delta.x, delta.y, delta.z}; } } diff --git a/src/endstone_core/player.cpp b/src/endstone_core/player.cpp index 283f4bb90..282707acc 100644 --- a/src/endstone_core/player.cpp +++ b/src/endstone_core/player.cpp @@ -42,8 +42,8 @@ EndstonePlayer::EndstonePlayer(EndstoneServer &server, ::Player &player) switch (component->network_id.getType()) { case NetworkIdentifier::Type::RakNet: { auto *peer = entt::locator::value(); - auto addr = peer->GetSystemAddressFromGuid(component->network_id.raknet_guid); - component->network_id.address.sa_stor = addr.address.sa_stor; + auto addr = peer->GetSystemAddressFromGuid(component->network_id.guid); + component->network_id.sock.sa_stor = addr.address.sa_stor; } case NetworkIdentifier::Type::Address: case NetworkIdentifier::Type::Address6: { @@ -235,7 +235,7 @@ std::chrono::milliseconds EndstonePlayer::getPing() const { auto *peer = entt::locator::value(); auto *component = player_.tryGetComponent(); - return std::chrono::milliseconds(peer->GetAveragePing({component->network_id.raknet_guid})); + return std::chrono::milliseconds(peer->GetAveragePing({component->network_id.guid})); } void EndstonePlayer::updateCommands() const @@ -265,12 +265,12 @@ bool EndstonePlayer::performCommand(std::string command) const CompoundTag origin; { origin.putByte("OriginType", static_cast(origin_type)); - origin.putInt64("EntityId", entity_id.id); + origin.putInt64("EntityId", entity_id.raw_id); } CompoundTag output_receiver; { output_receiver.putByte("OriginType", static_cast(origin_type)); - output_receiver.putInt64("EntityId", entity_id.id); + output_receiver.putInt64("EntityId", entity_id.raw_id); } tag.putByte("OriginType", static_cast(CommandOriginType::Virtual)); tag.putCompound("Origin", std::move(origin)); diff --git a/src/endstone_runtime/bedrock/command/minecraft_commands.cpp b/src/endstone_runtime/bedrock/command/minecraft_commands.cpp index f38c99ef4..8743673b9 100644 --- a/src/endstone_runtime/bedrock/command/minecraft_commands.cpp +++ b/src/endstone_runtime/bedrock/command/minecraft_commands.cpp @@ -36,9 +36,9 @@ MCRESULT MinecraftCommands::executeCommand(CommandContext &ctx, bool flag) const throw std::runtime_error("Command was executed by an non-player entity"); } endstone::Player &player = static_cast<::Player *>(entity)->getEndstonePlayer(); - server.getLogger().info("{} issued server command: {}", player.getName(), ctx.getCommandLine()); + server.getLogger().info("{} issued server command: {}", player.getName(), ctx.getCommand()); - endstone::PlayerCommandEvent event(player, ctx.getCommandLine()); + endstone::PlayerCommandEvent event(player, ctx.getCommand()); server.getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -47,7 +47,7 @@ MCRESULT MinecraftCommands::executeCommand(CommandContext &ctx, bool flag) const break; } case CommandOriginType::DedicatedServer: { - endstone::ServerCommandEvent event(server.getCommandSender(), ctx.getCommandLine()); + endstone::ServerCommandEvent event(server.getCommandSender(), ctx.getCommand()); server.getPluginManager().callEvent(event); if (event.isCancelled()) { diff --git a/src/endstone_runtime/bedrock/network/network_identifier.cpp b/src/endstone_runtime/bedrock/network/network_identifier.cpp index c0fc30070..d1af2ae73 100644 --- a/src/endstone_runtime/bedrock/network/network_identifier.cpp +++ b/src/endstone_runtime/bedrock/network/network_identifier.cpp @@ -19,13 +19,13 @@ std::string NetworkIdentifier::getAddress() const { char str[INET6_ADDRSTRLEN] = {0}; - if (address.addr4.sin_family == AF_INET) { - if (!inet_ntop(AF_INET, &(address.addr4.sin_addr), str, INET6_ADDRSTRLEN)) { + if (sock.addr4.sin_family == AF_INET) { + if (!inet_ntop(AF_INET, &(sock.addr4.sin_addr), str, INET6_ADDRSTRLEN)) { return "0.0.0.0"; } } else { - if (!inet_ntop(AF_INET6, &(address.addr6.sin6_addr), str, INET6_ADDRSTRLEN)) { + if (!inet_ntop(AF_INET6, &(sock.addr6.sin6_addr), str, INET6_ADDRSTRLEN)) { return "::"; } } @@ -34,7 +34,7 @@ std::string NetworkIdentifier::getAddress() const std::uint16_t NetworkIdentifier::getPort() const { - return ntohs(address.addr4.sin_port); + return ntohs(sock.addr4.sin_port); } NetworkIdentifier::Type NetworkIdentifier::getType() const diff --git a/src/endstone_runtime/bedrock/world/actor/actor.cpp b/src/endstone_runtime/bedrock/world/actor/actor.cpp index f1f5f545d..b95a70662 100644 --- a/src/endstone_runtime/bedrock/world/actor/actor.cpp +++ b/src/endstone_runtime/bedrock/world/actor/actor.cpp @@ -65,17 +65,17 @@ bool Actor::isRemoved() const bool Actor::isOnGround() const { - return ActorCollision::isOnGround(context_); + return ActorCollision::isOnGround(entity_context_); } bool Actor::isInWater() const { - return ActorEnvironment::getIsInWater(context_); + return ActorEnvironment::getIsInWater(entity_context_); } bool Actor::isInLava() const { - return ActorEnvironment::getIsInLava(context_); + return ActorEnvironment::getIsInLava(entity_context_); } Dimension &Actor::getDimension() const @@ -90,42 +90,42 @@ Level &Actor::getLevel() const Vec3 const &Actor::getPosition() const { - return components_.state_vector->position; + return built_in_components_.state_vector->position; } Vec3 const &Actor::getPosPrev() const { - return components_.state_vector->position_prev; + return built_in_components_.state_vector->position_prev; } Vec3 const &Actor::getPosDelta() const { - return components_.state_vector->position_delta; + return built_in_components_.state_vector->position_delta; } Vec2 const &Actor::getRotation() const { - return components_.rotation->rotation; + return built_in_components_.rotation->rotation; } AABB const &Actor::getAABB() const { - return components_.aabb->aabb; + return built_in_components_.aabb->aabb; } ActorRuntimeID Actor::getRuntimeID() const { - return tryGetComponent()->id; + return tryGetComponent()->runtime_id; } ActorUniqueID Actor::getOrCreateUniqueID() const { auto component = getPersistentComponent(); - if (component->id.id != -1) { - return component->id; + if (component->unique_id.raw_id != -1) { + return component->unique_id; } auto unique_id = level_->getNewUniqueID(); - return context_.getOrAddComponent(unique_id).id; + return entity_context_.getOrAddComponent(unique_id).unique_id; } Actor *Actor::getVehicle() const @@ -154,9 +154,9 @@ Actor *Actor::tryGetFromEntity(EntityContext const &ctx, bool include_removed) return nullptr; } - auto *actor = component->owner; + auto &actor = component->actor; if (actor && (!actor->isRemoved() || include_removed)) { - return actor; + return actor.get(); } return nullptr; } @@ -168,13 +168,13 @@ endstone::detail::EndstoneActor &Actor::getEndstoneActor() const if (isPlayer()) { auto *player = static_cast(self); - return context_.getOrAddComponent(server, *player); + return entity_context_.getOrAddComponent(server, *player); } // TODO(actor): add factory method for other actors - return context_.getOrAddComponent(server, *self); + return entity_context_.getOrAddComponent(server, *self); } bool Actor::isJumping() const { - return MobJump::isJumping(context_); + return MobJump::isJumping(entity_context_); } diff --git a/src/endstone_runtime/bedrock/world/level/event/event_coordinator.cpp b/src/endstone_runtime/bedrock/world/level/event/event_coordinator.cpp index 924bb5e43..175ec2e75 100644 --- a/src/endstone_runtime/bedrock/world/level/event/event_coordinator.cpp +++ b/src/endstone_runtime/bedrock/world/level/event/event_coordinator.cpp @@ -49,7 +49,7 @@ void ActorEventCoordinator::sendEvent(const EventRef> & // [](Details::ValueOrRef value) { cpptrace::generate_trace().print(); }, [](auto ignored) {}, }; - std::visit(visitor, ref.reference.event); + std::visit(visitor, ref.variant.event); ENDSTONE_HOOK_CALL_ORIGINAL(fp, this, ref); } @@ -60,7 +60,7 @@ CoordinatorResult ActorEventCoordinator::sendEvent(const EventRef> & auto visitor = entt::overloaded{ [](auto ignored) {}, }; - std::visit(visitor, ref.reference.event); + std::visit(visitor, ref.variant.event); ENDSTONE_HOOK_CALL_ORIGINAL(fp, this, ref); } @@ -91,7 +91,7 @@ void LevelEventCoordinator::sendEvent(const EventRef> & // [](Details::ValueOrRef value) { cpptrace::generate_trace().print(); }, [](auto ignored) {}, }; - std::visit(visitor, ref.reference.event); + std::visit(visitor, ref.variant.event); ENDSTONE_HOOK_CALL_ORIGINAL(&LevelEventCoordinator::sendEvent, this, ref); } @@ -109,7 +109,7 @@ void PlayerEventCoordinator::sendEvent(const EventRef> // [](Details::ValueOrRef value) {}, [](auto ignored) {}, }; - std::visit(visitor, ref.reference.event); + std::visit(visitor, ref.variant.event); ENDSTONE_HOOK_CALL_ORIGINAL(fp, this, ref); } @@ -120,7 +120,7 @@ CoordinatorResult PlayerEventCoordinator::sendEvent(const EventRef::value(); auto &scheduler = static_cast(server.getScheduler()); - scheduler.mainThreadHeartbeat(getCurrentServerTick().value()); + scheduler.mainThreadHeartbeat(getCurrentServerTick().tick_id); #if _WIN32 ENDSTONE_HOOK_CALL_ORIGINAL_NAME(&Level::tick, __FUNCDNAME__, this);