From cf6edfedbed26276be5c21bf65049b628757613b Mon Sep 17 00:00:00 2001 From: Moulberry Date: Fri, 12 Apr 2024 21:38:02 +0800 Subject: [PATCH] Fix not being able to spawn entities with passenger --- .../axiom/packet/SpawnEntityPacketListener.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moulberry/axiom/packet/SpawnEntityPacketListener.java b/src/main/java/com/moulberry/axiom/packet/SpawnEntityPacketListener.java index 873e2b6..4c2be11 100644 --- a/src/main/java/com/moulberry/axiom/packet/SpawnEntityPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/SpawnEntityPacketListener.java @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; public class SpawnEntityPacketListener implements PluginMessageListener { @@ -99,12 +100,18 @@ public class SpawnEntityPacketListener implements PluginMessageListener { if (!tag.contains("id")) continue; + AtomicBoolean useNewUuid = new AtomicBoolean(true); + Entity spawned = EntityType.loadEntityRecursive(tag, serverLevel, entity -> { String type = EntityType.getKey(entity.getType()).toString(); if (!whitelistedEntities.isEmpty() && !whitelistedEntities.contains(type)) return null; if (blacklistedEntities.contains(type)) return null; - entity.setUUID(entry.newUuid); + if (useNewUuid.getAndSet(false)) { + entity.setUUID(entry.newUuid); + } else { + entity.setUUID(UUID.randomUUID()); + } if (entity instanceof HangingEntity hangingEntity) { float changedYaw = entry.yaw - entity.getYRot();