From 3f21261162c439b3b167f057e75c2884193b75f7 Mon Sep 17 00:00:00 2001 From: David Choo Date: Sat, 7 Nov 2020 19:44:55 -0500 Subject: [PATCH] Actually fix lay for PosePlugin --- .../geysermc/connector/entity/PlayerEntity.java | 9 ++++++++- .../entity/spawn/JavaSpawnPlayerTranslator.java | 17 +++++++++++++---- .../org/geysermc/connector/utils/SkinUtils.java | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java index 53c8cb698..bb05b6131 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java @@ -77,12 +77,19 @@ public class PlayerEntity extends LivingEntity { * Saves the parrot currently on the player's right shoulder; otherwise null */ private ParrotEntity rightParrot; + /** + * UUID to use instead when spawning the player + * Bedrock expects uuids to be actually unique for each player entity + * Spawning another player entity with the same uuid will replace the old entity + */ + private UUID spawningUUID; public PlayerEntity(GameProfile gameProfile, long entityId, long geyserId, Vector3f position, Vector3f motion, Vector3f rotation) { super(entityId, geyserId, EntityType.PLAYER, position, motion, rotation); profile = gameProfile; uuid = gameProfile.getId(); + spawningUUID = uuid; username = gameProfile.getName(); effectCache = new EntityEffectCache(); if (geyserId == 1) valid = true; @@ -93,7 +100,7 @@ public class PlayerEntity extends LivingEntity { if (geyserId == 1) return; AddPlayerPacket addPlayerPacket = new AddPlayerPacket(); - addPlayerPacket.setUuid(uuid); + addPlayerPacket.setUuid(spawningUUID); addPlayerPacket.setUsername(username); addPlayerPacket.setRuntimeEntityId(geyserId); addPlayerPacket.setUniqueEntityId(geyserId); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnPlayerTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnPlayerTranslator.java index 99a6b0493..3fedfdd64 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnPlayerTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnPlayerTranslator.java @@ -35,6 +35,8 @@ import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.utils.LanguageUtils; import org.geysermc.connector.utils.SkinUtils; +import java.util.UUID; + @Translator(packet = ServerSpawnPlayerPacket.class) public class JavaSpawnPlayerTranslator extends PacketTranslator { @@ -53,10 +55,17 @@ public class JavaSpawnPlayerTranslator extends PacketTranslator