From 2f04c10f3e42a801d7fee8b06b8d489ef6da54f7 Mon Sep 17 00:00:00 2001 From: Max Lee Date: Sun, 7 Jun 2020 21:57:52 +0100 Subject: [PATCH] Maps shouldn't load chunks (#3518) Previously maps would load all chunks in a certain radius depending on their scale when trying to update their content. This would result in main thread chunk loads when they weren't really necessary, especially on low view distances or "slow" async chunk loads after teleports or other prioritisation. This changes it to only try to render already loaded chunks based on the assumption that the chunks around the player will get loaded eventually anyways. --- .../Maps-shouldn-t-load-chunks.patch | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Spigot-Server-Patches/Maps-shouldn-t-load-chunks.patch diff --git a/Spigot-Server-Patches/Maps-shouldn-t-load-chunks.patch b/Spigot-Server-Patches/Maps-shouldn-t-load-chunks.patch new file mode 100644 index 0000000000..86c8eb7ac4 --- /dev/null +++ b/Spigot-Server-Patches/Maps-shouldn-t-load-chunks.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Phoenix616 +Date: Sun, 7 Jun 2020 21:43:42 +0100 +Subject: [PATCH] Maps shouldn't load chunks + +Previously maps would load all chunks in a certain radius depending on + their scale when trying to update their content. This would result in + main thread chunk loads when they weren't really necessary, especially + on low view distances or "slow" async chunk loads after teleports or + other prioritisation. + + This changes it to only try to render already loaded chunks based on + the assumption that the chunks around the player will get loaded + eventually anyways and that maps will get checked for update every + five ticks that movement occur in anyways. + +diff --git a/src/main/java/net/minecraft/server/ItemWorldMap.java b/src/main/java/net/minecraft/server/ItemWorldMap.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/ItemWorldMap.java ++++ b/src/main/java/net/minecraft/server/ItemWorldMap.java +@@ -0,0 +0,0 @@ public class ItemWorldMap extends ItemWorldMapBase { + int k2 = (j / i + k1 - 64) * i; + int l2 = (k / i + l1 - 64) * i; + Multiset multiset = LinkedHashMultiset.create(); +- Chunk chunk = world.getChunkAtWorldCoords(new BlockPosition(k2, 0, l2)); ++ Chunk chunk = world.getChunkIfLoaded(new BlockPosition(k2, 0, l2)); // Paper - Maps shouldn't load chunks + +- if (!chunk.isEmpty()) { ++ if (chunk != null && !chunk.isEmpty()) { // Paper - Maps shouldn't load chunks + ChunkCoordIntPair chunkcoordintpair = chunk.getPos(); + int i3 = k2 & 15; + int j3 = l2 & 15;