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.
This commit is contained in:
Camotoy 2020-07-30 16:15:07 -04:00 committed by GitHub
parent 9097f8547b
commit a4339be212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -262,6 +262,11 @@ public class Entity {
session.sendUpstreamPacket(updateAttributesPacket); 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) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
switch (entityMetadata.getId()) { switch (entityMetadata.getId()) {
case 0: case 0:
@ -366,10 +371,12 @@ public class Entity {
} }
break; break;
} }
updateBedrockMetadata(session);
} }
/**
* Sends the Bedrock metadata to the client
* @param session GeyserSession
*/
public void updateBedrockMetadata(GeyserSession session) { public void updateBedrockMetadata(GeyserSession session) {
if (!valid) return; if (!valid) return;

View file

@ -47,5 +47,7 @@ public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityM
for (EntityMetadata metadata : packet.getMetadata()) { for (EntityMetadata metadata : packet.getMetadata()) {
entity.updateBedrockMetadata(metadata, session); entity.updateBedrockMetadata(metadata, session);
} }
entity.updateBedrockMetadata(session);
} }
} }