shadow-player-reconnect-fix (#1686)

* if a bot is kill()ed for a duplicate login, handle the disconnect immediately, Fixes #1468
This commit is contained in:
James McCulloch authored and GitHub committed 2023-05-24 14:38:48 +02:00
1 parent aeb68e9ba0
commit 9ca4e9538f
1 file changed
+6
@@ -5,6 +5,7 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPos;
import net.minecraft.core.UUIDUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
@@ -132,10 +133,15 @@ public class EntityPlayerMPFake extends ServerPlayer
public void kill(Component reason)
{
shakeOff();
if (reason.getContents() instanceof TranslatableContents text && text.getKey().equals("multiplayer.disconnect.duplicate_login")) {
this.connection.onDisconnect(reason);
} else {
this.server.tell(new TickTask(this.server.getTickCount(), () -> {
this.connection.onDisconnect(reason);
}));
}
}
@Override
public void tick()