From a4339be212e119054d226583429c44f95708b990 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Thu, 30 Jul 2020 16:15:07 -0400 Subject: [PATCH] Only send metadata update once per Java metadata packet (#1022) While this doesn't fix any bugs, it may be a slight performance enhancement as we aren't sending multiple packets per one Java entity metadata packet. --- .../java/org/geysermc/connector/entity/Entity.java | 11 +++++++++-- .../java/entity/JavaEntityMetadataTranslator.java | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java index 78d0cd97..e4823b51 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -262,6 +262,11 @@ public class Entity { session.sendUpstreamPacket(updateAttributesPacket); } + /** + * Applies the Java metadata to the local Bedrock metadata copy + * @param entityMetadata the Java entity metadata + * @param session GeyserSession + */ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { switch (entityMetadata.getId()) { case 0: @@ -366,10 +371,12 @@ public class Entity { } break; } - - updateBedrockMetadata(session); } + /** + * Sends the Bedrock metadata to the client + * @param session GeyserSession + */ public void updateBedrockMetadata(GeyserSession session) { if (!valid) return; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityMetadataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityMetadataTranslator.java index dd097b7d..e3de626c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityMetadataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityMetadataTranslator.java @@ -47,5 +47,7 @@ public class JavaEntityMetadataTranslator extends PacketTranslator