63 lines
3.1 KiB
Diff
63 lines
3.1 KiB
Diff
diff --git a/botcraft/src/Game/Entities/EntityManager.cpp b/botcraft/src/Game/Entities/EntityManager.cpp
|
|
index 3925686d..cc401e99 100644
|
|
--- a/botcraft/src/Game/Entities/EntityManager.cpp
|
|
+++ b/botcraft/src/Game/Entities/EntityManager.cpp
|
|
@@ -1,6 +1,9 @@
|
|
#include "botcraft/Game/Entities/EntityManager.hpp"
|
|
#include "botcraft/Game/Entities/entities/Entity.hpp"
|
|
#include "botcraft/Game/Entities/entities/UnknownEntity.hpp"
|
|
+#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
|
|
+#include "botcraft/Game/Entities/entities/decoration/ItemFrameEntity.hpp"
|
|
+#endif
|
|
#include "botcraft/Game/Entities/LocalPlayer.hpp"
|
|
#include "botcraft/Network/NetworkManager.hpp"
|
|
|
|
@@ -238,6 +241,23 @@ namespace Botcraft
|
|
entity->SetSpeed(Vector3<double>(packet.GetMovement()));
|
|
#endif
|
|
|
|
+#if PROTOCOL_VERSION > 770 /* > 1.21.5 */
|
|
+ if (entity->GetType() == EntityType::ItemFrame || entity->GetType() == EntityType::GlowItemFrame)
|
|
+ {
|
|
+ // Official 1.21.11 client: ItemFrame.getAddEntityPacket supplies
|
|
+ // getDirection().get3DDataValue() and getPos() to AddEntityPacket.
|
|
+ // Its (Entity, int, BlockPos) constructor sends integer anchor XYZ;
|
|
+ // recreateFromPacket sets direction from Data, not from yaw/pitch.
|
|
+ // Keep XYZ unchanged and initialize before publishing the entity:
|
|
+ // metadata may arrive later (or omit the default South direction).
|
|
+ const int direction = packet.GetData();
|
|
+ // Do not wrap malformed values into a valid face or retain South:
|
|
+ // -1 is deliberately invalid so targeting helpers can reject it.
|
|
+ std::static_pointer_cast<ItemFrameEntity>(entity)->SetDataDirection(
|
|
+ direction >= 0 && direction <= 5 ? direction : -1);
|
|
+ }
|
|
+#endif
|
|
+
|
|
std::scoped_lock<std::shared_mutex> lock(entity_manager_mutex);
|
|
entities[packet.GetEntityId()] = entity;
|
|
}
|
|
diff --git a/botcraft/src/Game/Entities/entities/decoration/HangingEntity.cpp b/botcraft/src/Game/Entities/entities/decoration/HangingEntity.cpp
|
|
index 8730b02b..0b9f13d2 100644
|
|
--- a/botcraft/src/Game/Entities/entities/decoration/HangingEntity.cpp
|
|
+++ b/botcraft/src/Game/Entities/entities/decoration/HangingEntity.cpp
|
|
@@ -53,7 +53,18 @@ namespace Botcraft
|
|
else if (index - hierarchy_metadata_count < metadata_count)
|
|
{
|
|
std::scoped_lock<std::shared_mutex> lock(entity_mutex);
|
|
- metadata[metadata_names[index - hierarchy_metadata_count]] = value;
|
|
+ // DATA_DIRECTION uses the DIRECTION serializer (not INT) in the
|
|
+ // official 1.21.11 client. Entity::LoadMetadataFromRawArray stores
|
|
+ // that as Direction; normalize it to our existing int getter/setter
|
|
+ // representation without wrapping invalid values into valid faces.
|
|
+ if (const auto* direction = std::any_cast<Direction>(&value))
|
|
+ {
|
|
+ metadata[metadata_names[index - hierarchy_metadata_count]] = static_cast<int>(*direction);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ metadata[metadata_names[index - hierarchy_metadata_count]] = value;
|
|
+ }
|
|
}
|
|
}
|
|
|