From 66312e4d40a55c77586994c96093b1154c0bfbca Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 2 Mar 2018 15:54:21 +0100 Subject: [PATCH] Fix half-despawned player entities if they are inside an unloading chunk (fixes #111) --- src/main/java/com/replaymod/replay/ReplaySender.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/replaymod/replay/ReplaySender.java b/src/main/java/com/replaymod/replay/ReplaySender.java index f0073af8..c82e03aa 100755 --- a/src/main/java/com/replaymod/replay/ReplaySender.java +++ b/src/main/java/com/replaymod/replay/ReplaySender.java @@ -1044,6 +1044,16 @@ public class ReplaySender extends ChannelDuplexHandler { // Entity has left all loaded chunks entity.addedToChunk = false; } + } else if (entity instanceof EntityPlayer) { + // Minecraft occasionally unloads player entities with the UnloadChunk packet which + // leaves them in a bugged state: + // Right after the unload they will be in the unloadedEntityList and after the next entity tick + // they will be removed from the loadedEntityList but still be part of the playerEntities list. + // + // We can't have that, so we'll pretend the player left the chunk before it's unloaded without + // actually moving them outside of it. + chunk.removeEntityAtIndex(entity, entity.chunkCoordY); + entity.addedToChunk = false; } } }