aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0674-Force-close-world-loading-screen.patch
blob: 06e8370733b16635aa5815dde51b0be4f8f80393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
Date: Wed, 2 Mar 2022 09:45:56 +0100
Subject: [PATCH] Force close world loading screen

Dead players would be stuck in the world loading screen and other players may
miss messages and similar sent in the join event if chunk loading is slow.
Paper already circumvents falling through the world before chunks are loaded,
so we do not need that. The client only needs the chunk it is currently in to
be loaded to close the loading screen, so we just send an empty one.

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 95a02b081d60f9ea45cc49faa0b0da8d5d88c0e6..6c75c2baab97ed58dbda3143bf06f7366b72bebe 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -393,6 +393,16 @@ public abstract class PlayerList {
         this.sendActivePlayerEffects(player);
         // Paper start - Fire PlayerJoinEvent when Player is actually ready; move vehicle into method so it can be called above - short circuit around that code
         this.onPlayerJoinFinish(player, worldserver1, s1);
+        // Paper start - Send empty chunk, so players aren't stuck in the world loading screen with our chunk system not sending chunks when dead
+        if (player.isDeadOrDying()) {
+            net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> plains = worldserver1.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME)
+                .getHolderOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
+            player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket(
+                new net.minecraft.world.level.chunk.EmptyLevelChunk(worldserver1, player.chunkPosition(), plains),
+                worldserver1.getLightEngine(), (java.util.BitSet)null, (java.util.BitSet) null)
+            );
+        }
+        // Paper end - Send empty chunk
     }
     private void mountSavedVehicle(ServerPlayer player, ServerLevel worldserver1, Optional<CompoundTag> optional) {
         // Paper end - Fire PlayerJoinEvent when Player is actually ready