Don't not shuffle visible chunks (#6283)

This commit is contained in:
Nassim Jahnke 2021-08-02 10:00:31 +02:00 committed by GitHub
parent a44f486694
commit 8c28a33d4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 51 additions and 65 deletions

View file

@ -3079,7 +3079,7 @@ index e9d2034f0753670c2ce69cc93c7e98e89af65c87..2b62f4664f439808661d559dc99762bf
@Override @Override
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 9591f50922343283597bad6d9ac17c175d8ae230..8639ffa2347e3d5c44ab30de0aa98623f95d1fe7 100644 index 9591f50922343283597bad6d9ac17c175d8ae230..8513490230f5fae0042f536b69b401efca995293 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -44,6 +44,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana @@ -44,6 +44,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureMana
@ -3299,21 +3299,7 @@ index 9591f50922343283597bad6d9ac17c175d8ae230..8639ffa2347e3d5c44ab30de0aa98623
@Nullable @Nullable
@Override @Override
public ChunkAccess getChunk(int x, int z, ChunkStatus leastStatus, boolean create) { public ChunkAccess getChunk(int x, int z, ChunkStatus leastStatus, boolean create) {
@@ -425,10 +621,9 @@ public class ServerChunkCache extends ChunkSource { @@ -453,7 +649,7 @@ public class ServerChunkCache extends ChunkSource {
this.lastSpawnState = spawnercreature_d;
this.level.getProfiler().pop();
- List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
-
- Collections.shuffle(list);
- list.forEach((playerchunk) -> {
+ //List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
+ //Collections.shuffle(list); // Paper
+ this.chunkMap.getChunks().forEach((playerchunk) -> { // Paper - no... just no...
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
if (optional.isPresent()) {
@@ -453,7 +648,7 @@ public class ServerChunkCache extends ChunkSource {
} }
this.level.getProfiler().popPush("broadcast"); this.level.getProfiler().popPush("broadcast");
@ -3447,7 +3433,7 @@ index e6d003701426a823768966d944384c69b9701967..3b09f76805053802bb779e227749d814
@Override @Override
public float getBukkitYaw() { public float getBukkitYaw() {
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 3a830166b65e81b970b0e9930bd79cb3e4eafc74..9d9d7990c49fd37c660efcb2c87a6c3495d648a6 100644 index deac6d08082b3291e748af6394235b3d18790ff2..d0047fc5156f13c831ab4f23a429d567ed6a39ac 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -235,6 +235,7 @@ public abstract class Mob extends LivingEntity { @@ -235,6 +235,7 @@ public abstract class Mob extends LivingEntity {

View file

@ -669,7 +669,7 @@ index 0000000000000000000000000000000000000000..0fda52841b5e1643efeda92106124998
+ } + }
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index da922f395f0fff0881ead893c900c5b2623f48f0..f973828da3ab56dba768fb029a271b2e55cfc24e 100644 index 99ad5dfe52534048078a386020c4f3f277020107..997041d4bc1cd6be97a2d403723eded7eda60351 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -14,12 +14,15 @@ import java.util.concurrent.TimeUnit; @@ -14,12 +14,15 @@ import java.util.concurrent.TimeUnit;
@ -1135,7 +1135,7 @@ index 2b62f4664f439808661d559dc99762bfbac09b16..4788946d7fb25c1b0f26e6a038924c4a
public void broadcast(Entity entity, Packet<?> packet) { public void broadcast(Entity entity, Packet<?> packet) {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 8639ffa2347e3d5c44ab30de0aa98623f95d1fe7..bafd97074461d5b17b21579ba493ba8eae8468d8 100644 index 8513490230f5fae0042f536b69b401efca995293..c5bffd1b40ca9ae3c973044c1ad4947ba2c285ae 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -348,13 +348,15 @@ public class ServerChunkCache extends ChunkSource { @@ -348,13 +348,15 @@ public class ServerChunkCache extends ChunkSource {
@ -1176,7 +1176,7 @@ index 8639ffa2347e3d5c44ab30de0aa98623f95d1fe7..bafd97074461d5b17b21579ba493ba8e
this.level.timings.doChunkUnload.startTiming(); // Spigot this.level.timings.doChunkUnload.startTiming(); // Spigot
this.level.getProfiler().popPush("unload"); this.level.getProfiler().popPush("unload");
this.chunkMap.tick(booleansupplier); this.chunkMap.tick(booleansupplier);
@@ -616,13 +622,16 @@ public class ServerChunkCache extends ChunkSource { @@ -616,14 +622,17 @@ public class ServerChunkCache extends ChunkSource {
boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
this.level.getProfiler().push("naturalSpawnCount"); this.level.getProfiler().push("naturalSpawnCount");
@ -1187,13 +1187,14 @@ index 8639ffa2347e3d5c44ab30de0aa98623f95d1fe7..bafd97074461d5b17b21579ba493ba8e
this.lastSpawnState = spawnercreature_d; this.lastSpawnState = spawnercreature_d;
this.level.getProfiler().pop(); this.level.getProfiler().pop();
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
//Collections.shuffle(list); // Paper
Collections.shuffle(list);
+ this.level.timings.chunkTicks.startTiming(); // Paper + this.level.timings.chunkTicks.startTiming(); // Paper
this.chunkMap.getChunks().forEach((playerchunk) -> { // Paper - no... just no... list.forEach((playerchunk) -> {
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
@@ -636,15 +645,18 @@ public class ServerChunkCache extends ChunkSource { @@ -637,15 +646,18 @@ public class ServerChunkCache extends ChunkSource {
NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2); NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2);
} }
@ -1214,7 +1215,7 @@ index 8639ffa2347e3d5c44ab30de0aa98623f95d1fe7..bafd97074461d5b17b21579ba493ba8e
} }
this.level.getProfiler().popPush("broadcast"); this.level.getProfiler().popPush("broadcast");
@@ -652,15 +664,20 @@ public class ServerChunkCache extends ChunkSource { @@ -653,15 +665,20 @@ public class ServerChunkCache extends ChunkSource {
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error
Objects.requireNonNull(playerchunk); Objects.requireNonNull(playerchunk);

View file

@ -36,13 +36,13 @@ index 5ce8ac377b0d2b05dd90baa67f420945cc419609..919a489a5c7b338659c62ae67fc0a6ce
}); });
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index bafd97074461d5b17b21579ba493ba8eae8468d8..2c0dd4b5a751e413936f399106367d4b22c17dda 100644 index c5bffd1b40ca9ae3c973044c1ad4947ba2c285ae..918555ba0af8a779ad55c7cf73f615eb804d00d9 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -631,6 +631,15 @@ public class ServerChunkCache extends ChunkSource { @@ -632,6 +632,15 @@ public class ServerChunkCache extends ChunkSource {
this.level.getProfiler().pop(); List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper Collections.shuffle(list);
+ //Paper start - call player naturally spawn event + //Paper start - call player naturally spawn event
+ int chunkRange = level.spigotConfig.mobSpawnRange; + int chunkRange = level.spigotConfig.mobSpawnRange;
+ chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; + chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
@ -53,7 +53,7 @@ index bafd97074461d5b17b21579ba493ba8eae8468d8..2c0dd4b5a751e413936f399106367d4b
+ }; + };
+ // Paper end + // Paper end
this.level.timings.chunkTicks.startTiming(); // Paper this.level.timings.chunkTicks.startTiming(); // Paper
this.chunkMap.getChunks().forEach((playerchunk) -> { // Paper - no... just no... list.forEach((playerchunk) -> {
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 823fc38b5bbf5eac2d2e7cc48c4b0557d252f960..fb42d7e3a1a23c02e8fd2cc04e6986ead581018c 100644 index 823fc38b5bbf5eac2d2e7cc48c4b0557d252f960..fb42d7e3a1a23c02e8fd2cc04e6986ead581018c 100644

View file

@ -2623,7 +2623,7 @@ index db4dac607cf24d3d2cd407255c60678ae4be1a1b..6d024db8bfbd5139d4c94be3d3a48cfa
return this.poiManager; return this.poiManager;
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 2c0dd4b5a751e413936f399106367d4b22c17dda..7239dd29ff622a2823d7c25a89cd3dc9e0bafac1 100644 index 918555ba0af8a779ad55c7cf73f615eb804d00d9..c0bde909755190603e9b4946fe924ba1cac53072 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -322,10 +322,128 @@ public class ServerChunkCache extends ChunkSource { @@ -322,10 +322,128 @@ public class ServerChunkCache extends ChunkSource {
@ -2787,7 +2787,7 @@ index 2c0dd4b5a751e413936f399106367d4b22c17dda..7239dd29ff622a2823d7c25a89cd3dc9
ChunkPos chunkcoordintpair = new ChunkPos(i, j); ChunkPos chunkcoordintpair = new ChunkPos(i, j);
long k = chunkcoordintpair.toLong(); long k = chunkcoordintpair.toLong();
int l = 33 + ChunkStatus.getDistance(chunkstatus); int l = 33 + ChunkStatus.getDistance(chunkstatus);
@@ -837,11 +965,12 @@ public class ServerChunkCache extends ChunkSource { @@ -838,11 +966,12 @@ public class ServerChunkCache extends ChunkSource {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
public boolean pollTask() { public boolean pollTask() {
try { try {

View file

@ -233,18 +233,18 @@ index 2b291296821dc6d6a8437bd977eeba517cdb5003..962028a58ee54b99be20905c1fd16cfe
while (objectbidirectionaliterator.hasNext()) { while (objectbidirectionaliterator.hasNext()) {
Entry<ChunkHolder> entry = (Entry) objectbidirectionaliterator.next(); Entry<ChunkHolder> entry = (Entry) objectbidirectionaliterator.next();
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index a10c8df3061ebc20c32346462cf2dfccd85ad722..ac077d88e0102b50edce094a6ac4c63546915e88 100644 index 6f33d4f4ca86bfcad907b451a56e71de0d4585d5..228ff4b52a017e8af987f60d84b7906c9be098f0 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -772,7 +772,7 @@ public class ServerChunkCache extends ChunkSource { @@ -760,7 +760,7 @@ public class ServerChunkCache extends ChunkSource {
};
// Paper end
this.level.timings.chunkTicks.startTiming(); // Paper
- this.chunkMap.getChunks().forEach((playerchunk) -> { // Paper - no... just no...
+ this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
if (optional.isPresent()) { this.lastSpawnState = spawnercreature_d;
this.level.getProfiler().pop();
- List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
+ List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.visibleChunkMap.values()); // Paper
Collections.shuffle(list);
//Paper start - call player naturally spawn event
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index a4d05aeccc142808981f1ecebd001c905ae721ed..e6b7302554b2a54363d55e149744237679262174 100644 index a4d05aeccc142808981f1ecebd001c905ae721ed..e6b7302554b2a54363d55e149744237679262174 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java

View file

@ -147,7 +147,7 @@ index ce438760cbc92c08c079d06a8b97eaeda1018491..0115ffe84356468ddc254d8d5bdd719b
// Spigot Start // Spigot Start
CrashReport crashreport; CrashReport crashreport;
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index c86457b8d2e99072840f8d4f693502bc23c98b35..41c148b05771438855d157ddd0c3ab21f0267c96 100644 index 228ff4b52a017e8af987f60d84b7906c9be098f0..c9e4802251dd1582e467112d45a3bd5f31ac1be2 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -709,6 +709,7 @@ public class ServerChunkCache extends ChunkSource { @@ -709,6 +709,7 @@ public class ServerChunkCache extends ChunkSource {
@ -166,16 +166,15 @@ index c86457b8d2e99072840f8d4f693502bc23c98b35..41c148b05771438855d157ddd0c3ab21
this.level.timings.doChunkUnload.stopTiming(); // Spigot this.level.timings.doChunkUnload.stopTiming(); // Spigot
this.level.getProfiler().pop(); this.level.getProfiler().pop();
this.clearCache(); this.clearCache();
@@ -772,7 +774,7 @@ public class ServerChunkCache extends ChunkSource { @@ -773,6 +775,7 @@ public class ServerChunkCache extends ChunkSource {
}; };
// Paper end // Paper end
this.level.timings.chunkTicks.startTiming(); // Paper this.level.timings.chunkTicks.startTiming(); // Paper
- this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping + final int[] chunksTicked = {0}; // Paper
+ final int[] chunksTicked = {0}; this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping list.forEach((playerchunk) -> {
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
if (optional.isPresent()) { @@ -784,6 +787,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -783,6 +785,7 @@ public class ServerChunkCache extends ChunkSource {
chunk.setInhabitedTime(chunk.getInhabitedTime() + j); chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2); NaturalSpawner.spawnForChunk(this.level, chunk, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag2);
@ -183,7 +182,7 @@ index c86457b8d2e99072840f8d4f693502bc23c98b35..41c148b05771438855d157ddd0c3ab21
} }
// this.level.timings.doTickTiles.startTiming(); // Spigot // Paper // this.level.timings.doTickTiles.startTiming(); // Spigot // Paper
@@ -800,7 +803,7 @@ public class ServerChunkCache extends ChunkSource { @@ -801,7 +805,7 @@ public class ServerChunkCache extends ChunkSource {
} }
this.level.getProfiler().popPush("broadcast"); this.level.getProfiler().popPush("broadcast");
@ -192,7 +191,7 @@ index c86457b8d2e99072840f8d4f693502bc23c98b35..41c148b05771438855d157ddd0c3ab21
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error
Objects.requireNonNull(playerchunk); Objects.requireNonNull(playerchunk);
@@ -964,6 +967,41 @@ public class ServerChunkCache extends ChunkSource { @@ -965,6 +969,41 @@ public class ServerChunkCache extends ChunkSource {
super.doRunTask(task); super.doRunTask(task);
} }

View file

@ -46,10 +46,10 @@ index 6d810cdb538d078dbf7ccd2ef84a4be27eb1f3e7..aa9846c7d6b8499e01bf0ffeece6a940
completablefuture1.thenAcceptAsync((either) -> { completablefuture1.thenAcceptAsync((either) -> {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 7cc8a898b5a6349da91b34b8be6ec00707183589..3e7469032d38b9432bb36d37214524ca2df11098 100644 index c9e4802251dd1582e467112d45a3bd5f31ac1be2..a50ad7a3268ea87be36f9718b1030d5ff56628b2 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -1014,6 +1014,7 @@ public class ServerChunkCache extends ChunkSource { @@ -1016,6 +1016,7 @@ public class ServerChunkCache extends ChunkSource {
return super.pollTask() || execChunkTask; // Paper return super.pollTask() || execChunkTask; // Paper
} }
} finally { } finally {

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Optimize isOutsideRange to use distance maps
Use a distance map to find the players in range quickly Use a distance map to find the players in range quickly
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index bf641519ce1592737feac6eaf1d155d8fd126ec7..4569788773c8a9dc072d5ae5239c17c4f50e9ab0 100644 index bbb94e8a5e3585701849e025b534a69a6e67949f..7223c6daf6f0eb959a5cab701096324a34b9c88a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -100,6 +100,18 @@ public class ChunkHolder { @@ -100,6 +100,18 @@ public class ChunkHolder {
@ -291,7 +291,7 @@ index b49d380ef088aed3204ec71abc437c348ef004fa..577b391dcba1db712c1e2c83296e1c87
public String getDebugStatus() { public String getDebugStatus() {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 3e7469032d38b9432bb36d37214524ca2df11098..b85a85fbb12802c355e8f458077b4b124380813b 100644 index a50ad7a3268ea87be36f9718b1030d5ff56628b2..7d8db5bc79fbff0832b87f4004f919d28bf44eca 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -735,6 +735,37 @@ public class ServerChunkCache extends ChunkSource { @@ -735,6 +735,37 @@ public class ServerChunkCache extends ChunkSource {
@ -332,10 +332,10 @@ index 3e7469032d38b9432bb36d37214524ca2df11098..b85a85fbb12802c355e8f458077b4b12
this.level.getProfiler().push("pollingChunks"); this.level.getProfiler().push("pollingChunks");
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
@@ -764,15 +795,7 @@ public class ServerChunkCache extends ChunkSource { @@ -765,15 +796,7 @@ public class ServerChunkCache extends ChunkSource {
this.level.getProfiler().pop(); List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.visibleChunkMap.values()); // Paper
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper Collections.shuffle(list);
- //Paper start - call player naturally spawn event - //Paper start - call player naturally spawn event
- int chunkRange = level.spigotConfig.mobSpawnRange; - int chunkRange = level.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; - chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
@ -345,11 +345,11 @@ index 3e7469032d38b9432bb36d37214524ca2df11098..b85a85fbb12802c355e8f458077b4b12
- entityPlayer.playerNaturallySpawnedEvent.callEvent(); - entityPlayer.playerNaturallySpawnedEvent.callEvent();
- }; - };
- // Paper end - // Paper end
+ // Paper - moved up + // Paper - moved natural spawn event up
this.level.timings.chunkTicks.startTiming(); // Paper this.level.timings.chunkTicks.startTiming(); // Paper
final int[] chunksTicked = {0}; this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping final int[] chunksTicked = {0}; // Paper
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left(); list.forEach((playerchunk) -> {
@@ -781,9 +804,9 @@ public class ServerChunkCache extends ChunkSource { @@ -783,9 +806,9 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk = (LevelChunk) optional.get(); LevelChunk chunk = (LevelChunk) optional.get();
ChunkPos chunkcoordintpair = chunk.getPos(); ChunkPos chunkcoordintpair = chunk.getPos();

View file

@ -25,7 +25,7 @@ Massive update to light to improve performance and chunk loading/generation.
8) Fix NPE risk that crashes server in getting nibble data 8) Fix NPE risk that crashes server in getting nibble data
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 90115430d7b068b1d92f92dee73214dd8dc0053e..a076829f21afaffd5c281f4c16ce0889a8c38a5e 100644 index 52fc256c0d4de63ba94625218661db397b6e704e..e3c8e7692e8ca005e98d4158de0c961087dfb199 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -773,6 +773,7 @@ public class ChunkHolder { @@ -773,6 +773,7 @@ public class ChunkHolder {
@ -126,10 +126,10 @@ index d3d6651eb51c852ed1d1eeb5689569d5308b246d..c2d36600a0081c78425868154bdcf7f4
m = Long.MAX_VALUE; m = Long.MAX_VALUE;
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index f4f6124c20c31224312070c5e95be00a62e89897..a24790b798d733976db4de430164d648b739158b 100644 index c63cbb6da6f734c3a93c63af2b28a6e588f22bf2..ddf28939d8037bcea456350093d077c503a3b66e 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -1074,7 +1074,7 @@ public class ServerChunkCache extends ChunkSource { @@ -1076,7 +1076,7 @@ public class ServerChunkCache extends ChunkSource {
if (ServerChunkCache.this.runDistanceManagerUpdates()) { if (ServerChunkCache.this.runDistanceManagerUpdates()) {
return true; return true;
} else { } else {