13
0
geforkt von Mirrors/Paper

Don't not shuffle visible chunks (#6283)

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-08-02 10:00:31 +02:00
Ursprung 007c5e34af
Commit 243cfdf6b5
6 geänderte Dateien mit 23 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -3300,20 +3300,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public ChunkAccess getChunk(int x, int z, ChunkStatus leastStatus, boolean create) {
@@ -0,0 +0,0 @@ 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()) {
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
}
this.level.getProfiler().popPush("broadcast");

Datei anzeigen

@ -170,11 +170,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
};
// Paper end
this.level.timings.chunkTicks.startTiming(); // Paper
- this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
+ final int[] chunksTicked = {0}; this.chunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
+ final int[] chunksTicked = {0}; // Paper
list.forEach((playerchunk) -> {
Optional<LevelChunk> optional = ((Either) playerchunk.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left();
if (optional.isPresent()) {
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
if (flag1 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunk.getPos()) && !this.chunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot

Datei anzeigen

@ -237,14 +237,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -0,0 +0,0 @@ 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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java

Datei anzeigen

@ -333,9 +333,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
this.level.getProfiler().pop();
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper
List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.visibleChunkMap.values()); // Paper
Collections.shuffle(list);
- //Paper start - call player naturally spawn event
- int chunkRange = level.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
@ -345,10 +345,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- entityPlayer.playerNaturallySpawnedEvent.callEvent();
- };
- // Paper end
+ // Paper - moved up
+ // Paper - moved natural spawn event up
this.level.timings.chunkTicks.startTiming(); // Paper
final int[] chunksTicked = {0}; 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();
final int[] chunksTicked = {0}; // Paper
list.forEach((playerchunk) -> {
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk = (LevelChunk) optional.get();
ChunkPos chunkcoordintpair = chunk.getPos();

Datei anzeigen

@ -40,9 +40,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
this.level.getProfiler().pop();
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper
List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
Collections.shuffle(list);
+ //Paper start - call player naturally spawn event
+ int chunkRange = level.spigotConfig.mobSpawnRange;
+ chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ };
+ // Paper end
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();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

Datei anzeigen

@ -1187,10 +1187,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.lastSpawnState = spawnercreature_d;
this.level.getProfiler().pop();
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper
List<ChunkHolder> list = Lists.newArrayList(this.chunkMap.getChunks());
Collections.shuffle(list);
+ 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();
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {