From a7fbe995f826f427dfa589b535e255629519d24e Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sat, 4 Jul 2020 10:26:32 -0400 Subject: [PATCH] Add comment and check for null when removing passengers --- .../src/main/java/org/geysermc/connector/entity/Entity.java | 5 +++-- 1 file changed, 3 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 8f242dcc6..ffe13a50d 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -146,9 +146,10 @@ public class Entity { public boolean despawnEntity(GeyserSession session) { if (!valid) return true; - for (long passenger : passengers) { + for (long passenger : passengers) { // Make sure all passengers on the despawned entity are updated Entity entity = session.getEntityCache().getEntityByJavaId(passenger); - entity.getMetadata().getFlags().setFlag(EntityFlag.RIDING, false); + if (entity == null) continue; + entity.getMetadata().getOrCreateFlags().setFlag(EntityFlag.RIDING, false); entity.updateBedrockMetadata(session); }