mirror of
https://github.com/SparklyPower/SparklyPaper.git
synced 2025-12-25 01:49:28 +00:00
Updated Upstream (Paper)
This commit is contained in:
@@ -2,7 +2,7 @@ group=net.sparklypower.sparklypaper
|
||||
version=1.21-R0.1-SNAPSHOT
|
||||
|
||||
mcVersion=1.21
|
||||
paperRef=c0268ca86eeb5ca767e5e2860aa2d936e5e7fc4f
|
||||
paperRef=38428c0d6cf9aeea31fffe8f63b8a92c982c8a4f
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
|
||||
@@ -14,10 +14,10 @@ This seems stupid, but it does seem that it improves the performance a bit, and
|
||||
We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index df00ea382915480be1279a5347872cf7a1417341..3bb88e49fa4513011a082f06d592e70e759fd2ae 100644
|
||||
index c96740a82eac9101f74edeb44edf4b64d1d633e0..c45507dce50ca8b553a620b4a0820883e9af2487 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1205,7 +1205,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -1178,7 +1178,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end - Configurable entity tracking range by Y
|
||||
|
||||
// CraftBukkit start - respect vanish API
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Revert "Fix MC-117075: Block entity unload lag spike"
|
||||
This reverts commit f3453b204569ea865cc1d1302edb6d125e7f0cb3.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 7fc7419988491dc558c10016a58ebaae485b6cfc..913abd2ae85cb2c558ba953ea446aab939074f43 100644
|
||||
index c8d5eb0b67678666f400d2f9e419655e23d43365..9f94c999f1f004d673a1844a4a10fe1443ffac22 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -957,8 +957,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -955,8 +955,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
boolean flag = this.tickRateManager().runsNormally();
|
||||
|
||||
int tilesThisCycle = 0;
|
||||
@@ -18,7 +18,7 @@ index 7fc7419988491dc558c10016a58ebaae485b6cfc..913abd2ae85cb2c558ba953ea446aab9
|
||||
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
||||
this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
||||
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
|
||||
@@ -967,13 +965,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -965,13 +963,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
if (tickingblockentity.isRemoved()) {
|
||||
// Spigot start
|
||||
tilesThisCycle--;
|
||||
|
||||
@@ -8,7 +8,7 @@ We replaced the `blockEntityTickers` list with a custom list based on fastutil's
|
||||
This is WAY FASTER than using `removeAll` with a list of entries to be removed, because we don't need to calculate the identity of each block entity to be removed, and we can jump directly to where the search should begin, giving a performance boost for small removals (because we don't need to loop thru the entire list to find what element should be removed) and a performance boost for big removals (no need to calculate the identity of each block entity).
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 913abd2ae85cb2c558ba953ea446aab939074f43..175402a4ce41a048429a6fdccce4190add75f17a 100644
|
||||
index 9f94c999f1f004d673a1844a4a10fe1443ffac22..5c7edd7323fd6cf82eead6822e3f65666c889462 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -115,7 +115,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -20,7 +20,7 @@ index 913abd2ae85cb2c558ba953ea446aab939074f43..175402a4ce41a048429a6fdccce4190a
|
||||
protected final NeighborUpdater neighborUpdater;
|
||||
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
||||
private boolean tickingBlockEntities;
|
||||
@@ -965,13 +965,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -963,13 +963,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
if (tickingblockentity.isRemoved()) {
|
||||
// Spigot start
|
||||
tilesThisCycle--;
|
||||
|
||||
@@ -12,10 +12,10 @@ But here's the thing: We don't care if we have a small performance penalty if th
|
||||
And finally, we also cache the chunk's coordinate key when creating the block entity, which is actually "free" because we just reuse the already cached chunk coordinate key from the chunk!
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 175402a4ce41a048429a6fdccce4190add75f17a..5c28b6491c3a23f850ca22da59261cedc774eddd 100644
|
||||
index 5c7edd7323fd6cf82eead6822e3f65666c889462..bc11ecc01fe67bcadc3a6417a20cd28f9dd450a7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -957,6 +957,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -955,6 +955,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
boolean flag = this.tickRateManager().runsNormally();
|
||||
|
||||
int tilesThisCycle = 0;
|
||||
@@ -26,7 +26,7 @@ index 175402a4ce41a048429a6fdccce4190add75f17a..5c28b6491c3a23f850ca22da59261ced
|
||||
for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
||||
this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
||||
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
|
||||
@@ -967,8 +971,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -965,8 +969,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
tilesThisCycle--;
|
||||
this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals
|
||||
// Spigot end
|
||||
@@ -60,7 +60,7 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..427cf73383155c52bca8fb4b32f43029
|
||||
+ long getChunkCoordinateKey(); // SparklyPaper - optimize tickBlockEntities
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 589c1f13006660c28378f447ee373651257169d9..652490f2d75940241ed93239a3d6b8b73048fd5f 100644
|
||||
index d388fbcbff63928f0e9140c02400a63ba8f19d9c..712510eea9044fca6cd939b94cf728d1336609a3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -74,6 +74,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -77,7 +77,7 @@ index 589c1f13006660c28378f447ee373651257169d9..652490f2d75940241ed93239a3d6b8b7
|
||||
};
|
||||
private final Map<BlockPos, LevelChunk.RebindableTickingBlockEntityWrapper> tickersInLevel;
|
||||
public boolean loaded;
|
||||
@@ -1039,7 +1046,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -914,7 +921,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
}
|
||||
|
||||
private <T extends BlockEntity> TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker<T> blockEntityTicker) {
|
||||
@@ -86,7 +86,7 @@ index 589c1f13006660c28378f447ee373651257169d9..652490f2d75940241ed93239a3d6b8b7
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
@@ -1090,6 +1097,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -965,6 +972,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
public String toString() {
|
||||
return String.valueOf(this.ticker) + " <wrapped>";
|
||||
}
|
||||
@@ -100,7 +100,7 @@ index 589c1f13006660c28378f447ee373651257169d9..652490f2d75940241ed93239a3d6b8b7
|
||||
}
|
||||
|
||||
private class BoundTickingBlockEntity<T extends BlockEntity> implements TickingBlockEntity {
|
||||
@@ -1097,10 +1111,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -972,10 +986,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
private final T blockEntity;
|
||||
private final BlockEntityTicker<T> ticker;
|
||||
private boolean loggedInvalidBlockState;
|
||||
@@ -114,7 +114,7 @@ index 589c1f13006660c28378f447ee373651257169d9..652490f2d75940241ed93239a3d6b8b7
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1168,5 +1184,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -1043,5 +1059,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
|
||||
return "Level ticker for " + s + "@" + String.valueOf(this.getPos());
|
||||
}
|
||||
|
||||
@@ -56,9 +56,18 @@ index 8b5293b0c696ef21d0101493ffa41b60bf0bc86b..601198a33adb29316b0617d5390d1620
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index a832b608fceb12b5ceeb4ff1f824e7d542bad32f..086ff182abaf0a3df4d20f98c6e5f9ddce26dc83 100644
|
||||
index 4f6175470b865ec32c3dafd79c6c1640639fbcc2..2d88bdf9aab500cff26f7c35df9b1c178ab6897b 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1670,7 +1670,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
/*
|
||||
getAllLevels().forEach(level -> {
|
||||
- for (final Entity entity : level.moonrise$getEntityLookup().getAllCopy()) { // Paper - rewrite chunk system
|
||||
+ for (final Entity entity : level.getEntities().getAll()) {
|
||||
if (entity.isRemoved()) {
|
||||
continue;
|
||||
}
|
||||
@@ -1746,7 +1746,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
try {
|
||||
@@ -73,11 +82,25 @@ index a832b608fceb12b5ceeb4ff1f824e7d542bad32f..086ff182abaf0a3df4d20f98c6e5f9dd
|
||||
+ worldserver.tickTimes10s.add(this.tickCount, j);
|
||||
+ worldserver.tickTimes60s.add(this.tickCount, j);
|
||||
+ // SparklyPaper end
|
||||
// Paper start
|
||||
for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) {
|
||||
regionManager.recalculateRegions();
|
||||
worldserver.timings.doTick.stopTiming(); // Spigot
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
@@ -2743,13 +2752,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
}
|
||||
|
||||
- // Paper start - rewrite chunk system
|
||||
- @Override
|
||||
- public boolean isSameThread() {
|
||||
- return io.papermc.paper.util.TickThread.isTickThread();
|
||||
- }
|
||||
- // Paper end - rewrite chunk system
|
||||
-
|
||||
// CraftBukkit start
|
||||
public boolean isDebugging() {
|
||||
return false;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index b81ac6db8ba1ee0722e9e85f8de8ef91169a3198..f6d0b7d94995fff41def7edcf66fac40c43fec61 100644
|
||||
index 798016774df02c3f7ebf909c9cc125f8427a39be..7e47c6f128090ea32ff36cf4fb2e660cc5ce04ef 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -496,6 +496,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
|
||||
@@ -541,7 +541,7 @@ index cb308808906a8cdb127df8284e106e00553473ca..323d41e2bed5e83a26dfe4c88dfce7ed
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a943e0cc85c 100644
|
||||
index 2d88bdf9aab500cff26f7c35df9b1c178ab6897b..7181ca59c564406da3da7673fe98e11a47a805da 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -324,6 +324,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -563,7 +563,7 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
this.nextTickTimeNanos += k * i;
|
||||
this.lastOverloadWarningNanos = this.nextTickTimeNanos;
|
||||
}
|
||||
@@ -1723,56 +1726,72 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1723,51 +1726,68 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked
|
||||
Iterator iterator = this.getAllLevels().iterator(); // Paper - Throw exception on world create while being ticked; move down
|
||||
@@ -572,6 +572,9 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
- worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
|
||||
- worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
|
||||
- net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
|
||||
-
|
||||
- this.profiler.push(() -> {
|
||||
- String s = String.valueOf(worldserver);
|
||||
+ // SparklyPaper start - parallel world ticking
|
||||
+ java.util.ArrayDeque<java.util.concurrent.Future<ServerLevel>> tasks = new java.util.ArrayDeque<>();
|
||||
+ try {
|
||||
@@ -592,15 +595,35 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
+ long i = Util.getNanos(); // SparklyPaper - track world's MSPT
|
||||
+ worldserver.tick(shouldKeepTicking);
|
||||
+
|
||||
+ for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) {
|
||||
+ regionManager.recalculateRegions();
|
||||
+ }
|
||||
+ worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
|
||||
|
||||
- this.profiler.push(() -> {
|
||||
- String s = String.valueOf(worldserver);
|
||||
+
|
||||
+ // SparklyPaper start - track world's MSPT
|
||||
+ long j = Util.getNanos() - i;
|
||||
+
|
||||
+ // These are from the "tickServer" function
|
||||
+ worldserver.tickTimes5s.add(this.tickCount, j);
|
||||
+ worldserver.tickTimes10s.add(this.tickCount, j);
|
||||
+ worldserver.tickTimes60s.add(this.tickCount, j);
|
||||
+ // SparklyPaper end
|
||||
+
|
||||
+ currentThread.currentlyTickingServerLevel = null; // Reset current ticking level
|
||||
+
|
||||
+ } catch (Throwable throwable) {
|
||||
+ // Spigot Start
|
||||
+ CrashReport crashreport;
|
||||
+ try {
|
||||
+ crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
+ } catch (Throwable t) {
|
||||
+ if (throwable instanceof ThreadDeath) {
|
||||
+ throw (ThreadDeath) throwable;
|
||||
+ } // Paper
|
||||
+ throw new RuntimeException("Error generating crash report", t);
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+ worldserver.fillReportDetails(crashreport);
|
||||
+ throw new ReportedException(crashreport);
|
||||
+ } finally {
|
||||
+ serverLevelTickingSemaphore.release();
|
||||
|
||||
- return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
- });
|
||||
@@ -609,17 +632,14 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
- this.profiler.push("timeSync");
|
||||
- this.synchronizeTime(worldserver);
|
||||
- this.profiler.pop();
|
||||
- }
|
||||
+ }
|
||||
+ }, worldserver)
|
||||
+ );
|
||||
}
|
||||
- // CraftBukkit end */
|
||||
+ // These are from the "tickServer" function
|
||||
+ worldserver.tickTimes5s.add(this.tickCount, j);
|
||||
+ worldserver.tickTimes10s.add(this.tickCount, j);
|
||||
+ worldserver.tickTimes60s.add(this.tickCount, j);
|
||||
+ // SparklyPaper end
|
||||
|
||||
- this.profiler.push("tick");
|
||||
+ currentThread.currentlyTickingServerLevel = null; // Reset current ticking level
|
||||
|
||||
-
|
||||
- try {
|
||||
- worldserver.timings.doTick.startTiming(); // Spigot
|
||||
- long i = Util.getNanos(); // SparklyPaper - track world's MSPT
|
||||
@@ -632,45 +652,19 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
- worldserver.tickTimes10s.add(this.tickCount, j);
|
||||
- worldserver.tickTimes60s.add(this.tickCount, j);
|
||||
- // SparklyPaper end
|
||||
- // Paper start
|
||||
- for (final io.papermc.paper.chunk.SingleThreadChunkRegionManager regionManager : worldserver.getChunkSource().chunkMap.regionManagers) {
|
||||
- regionManager.recalculateRegions();
|
||||
- }
|
||||
- // Paper end
|
||||
- worldserver.timings.doTick.stopTiming(); // Spigot
|
||||
- } catch (Throwable throwable) {
|
||||
- CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
+ } catch (Throwable throwable) {
|
||||
+ // Spigot Start
|
||||
+ CrashReport crashreport;
|
||||
+ try {
|
||||
+ crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
|
||||
|
||||
-
|
||||
- worldserver.fillReportDetails(crashreport);
|
||||
- throw new ReportedException(crashreport);
|
||||
+ } catch (Throwable t) {
|
||||
+ if (throwable instanceof ThreadDeath) {
|
||||
+ throw (ThreadDeath) throwable;
|
||||
+ } // Paper
|
||||
+ throw new RuntimeException("Error generating crash report", t);
|
||||
+ }
|
||||
+ // Spigot End
|
||||
+ worldserver.fillReportDetails(crashreport);
|
||||
+ throw new ReportedException(crashreport);
|
||||
+ } finally {
|
||||
+ serverLevelTickingSemaphore.release();
|
||||
+
|
||||
+ }
|
||||
+ }, worldserver)
|
||||
+ );
|
||||
+ while (!tasks.isEmpty()) {
|
||||
+ tasks.pop().get();
|
||||
}
|
||||
|
||||
-
|
||||
- this.profiler.pop();
|
||||
- this.profiler.pop();
|
||||
- worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
|
||||
+ while (!tasks.isEmpty()) {
|
||||
+ tasks.pop().get();
|
||||
+ }
|
||||
+ } catch (java.lang.InterruptedException | java.util.concurrent.ExecutionException e) {
|
||||
+ throw new RuntimeException(e); // Propagate exception
|
||||
}
|
||||
@@ -678,7 +672,7 @@ index cb93aed058c050107f948e95396975d50d53bfb1..7da56241422fab1ff3fe53af4e1b9a94
|
||||
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
|
||||
this.profiler.popPush("connection");
|
||||
@@ -2912,7 +2931,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2900,7 +2920,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
||||
@@ -717,19 +711,18 @@ index 17c862b5c33312539aab9be215834c06add818e7..7152b8126fa942c0ebcf98b570a70d18
|
||||
// SparklyPaper start - Spooky month optimizations
|
||||
halloweenManager.startHalloweenEpochTask();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 681fdab250d924a29ca160acffbcbf7f8a3ca78a..f3c5c66baf5e4d87d43c6e790923e22383211666 100644
|
||||
index 82e7f7c3c2f51bc135585f43bc5167bcde2f8a98..5bb01450d46106c8b1976ce66726a0867d6d6bca 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -252,7 +252,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -192,6 +192,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
|
||||
@Nullable
|
||||
public LevelChunk getChunkAtIfLoadedImmediately(int x, int z) {
|
||||
long k = ChunkPos.asLong(x, z);
|
||||
|
||||
- if (Thread.currentThread() == this.mainThread) {
|
||||
+ if (io.papermc.paper.util.TickThread.isTickThreadFor(level, x, z)) { // Paper - rewrite chunk system // SparklyPaper - parallel world ticking
|
||||
return this.getChunkAtIfLoadedMainThread(x, z);
|
||||
}
|
||||
|
||||
@@ -305,6 +305,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread(level, x, z, "Cannot get chunks immediately asyncronously"); // SparklyPaper - parallel world ticking
|
||||
return this.fullChunks.get(ChunkPos.asLong(x, z));
|
||||
}
|
||||
// Paper end
|
||||
@@ -226,6 +227,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@Override
|
||||
public ChunkAccess getChunk(int x, int z, ChunkStatus leastStatus, boolean create) {
|
||||
// Paper start - rewrite chunk system
|
||||
@@ -748,7 +741,7 @@ index 681fdab250d924a29ca160acffbcbf7f8a3ca78a..f3c5c66baf5e4d87d43c6e790923e223
|
||||
if (leastStatus == ChunkStatus.FULL) {
|
||||
final LevelChunk ret = this.fullChunks.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(x, z));
|
||||
|
||||
@@ -322,6 +334,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -243,6 +256,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@Nullable
|
||||
@Override
|
||||
public LevelChunk getChunkNow(int chunkX, int chunkZ) {
|
||||
@@ -767,7 +760,7 @@ index 681fdab250d924a29ca160acffbcbf7f8a3ca78a..f3c5c66baf5e4d87d43c6e790923e223
|
||||
return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getFullChunkIfLoaded(chunkX, chunkZ); // Paper - rewrite chunk system
|
||||
}
|
||||
|
||||
@@ -332,7 +356,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -253,7 +278,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
|
||||
public CompletableFuture<ChunkResult<ChunkAccess>> getChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||
@@ -1025,7 +1018,7 @@ index d524fcc191cb95d6ec7f12ae7fceeb8077bb08fc..451e5719613fc31bacf49c37978d4e49
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73fa10d148b 100644
|
||||
index bc11ecc01fe67bcadc3a6417a20cd28f9dd450a7..38acdc61426b33ed4aceb46b9a63d47d894fe8cb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -10,6 +10,8 @@ import java.util.function.Consumer;
|
||||
@@ -1045,16 +1038,23 @@ index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73f
|
||||
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
||||
public static BlockPos lastPhysicsProblem; // Spigot
|
||||
private org.spigotmc.TickLimiter entityLimiter;
|
||||
@@ -504,7 +507,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -504,10 +507,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public final LevelChunk getChunk(int chunkX, int chunkZ) { // Paper - final to help inline
|
||||
// Paper start - Perf: make sure loaded chunks get the inlined variant of this function
|
||||
net.minecraft.server.level.ServerChunkCache cps = ((ServerLevel)this).getChunkSource();
|
||||
- if (cps.mainThread == Thread.currentThread()) {
|
||||
+ if (TickThread.isTickThreadFor((ServerLevel) this, chunkX, chunkZ)) { // SparklyPaper - parallel world ticking, let tick threads load chunks via the main thread
|
||||
LevelChunk ifLoaded = cps.getChunkAtIfLoadedMainThread(chunkX, chunkZ);
|
||||
if (ifLoaded != null) {
|
||||
return ifLoaded;
|
||||
@@ -588,6 +591,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
+
|
||||
+ // SparklyPaper start - parallel world ticking, let tick threads load chunks via the main thread
|
||||
+ if (TickThread.isTickThreadFor((ServerLevel) this, chunkX, chunkZ)) {
|
||||
LevelChunk ifLoaded = cps.getChunkAtIfLoadedImmediately(chunkX, chunkZ);
|
||||
if (ifLoaded != null) {
|
||||
return ifLoaded;
|
||||
}
|
||||
+ // SparklyPaper end
|
||||
+ }
|
||||
return (LevelChunk) cps.getChunk(chunkX, chunkZ, ChunkStatus.FULL, true); // Paper - avoid a method jump
|
||||
// Paper end - Perf: make sure loaded chunks get the inlined variant of this function
|
||||
}
|
||||
@@ -586,6 +594,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
|
||||
@Override
|
||||
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
||||
@@ -1062,7 +1062,7 @@ index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73f
|
||||
// CraftBukkit start - tree generation
|
||||
if (this.captureTreeGeneration) {
|
||||
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
|
||||
@@ -1099,6 +1103,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1097,6 +1106,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
|
||||
@Nullable
|
||||
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
|
||||
@@ -1070,7 +1070,7 @@ index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73f
|
||||
// Paper start - Perf: Optimize capturedTileEntities lookup
|
||||
net.minecraft.world.level.block.entity.BlockEntity blockEntity;
|
||||
if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) {
|
||||
@@ -1106,10 +1111,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1104,10 +1114,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
}
|
||||
// Paper end - Perf: Optimize capturedTileEntities lookup
|
||||
// CraftBukkit end
|
||||
@@ -1083,7 +1083,7 @@ index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73f
|
||||
BlockPos blockposition = blockEntity.getBlockPos();
|
||||
|
||||
if (!this.isOutsideBuildHeight(blockposition)) {
|
||||
@@ -1195,6 +1201,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1193,6 +1204,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
|
||||
@Override
|
||||
public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) {
|
||||
@@ -1091,7 +1091,7 @@ index 5c28b6491c3a23f850ca22da59261cedc774eddd..f4e69d6496d6960147436b8244d7d73f
|
||||
this.getProfiler().incrementCounter("getEntities");
|
||||
// Paper start - rewrite chunk system
|
||||
final List<Entity> ret = new java.util.ArrayList<>();
|
||||
@@ -1505,8 +1512,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1503,8 +1515,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public abstract RecipeManager getRecipeManager();
|
||||
|
||||
public BlockPos getBlockRandomPos(int x, int y, int z, int l) {
|
||||
@@ -1321,10 +1321,10 @@ index 597599138f69c9ee05dc7657c51c25336337875e..c9876514091f5cd0fc9c24b4f1577b1a
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 652490f2d75940241ed93239a3d6b8b73048fd5f..b8f32894b14db232c26b5ee61c35e84dba22342a 100644
|
||||
index 712510eea9044fca6cd939b94cf728d1336609a3..29559ad8205ed3f984ff40e53da2e8019e77e942 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -425,6 +425,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
@@ -326,6 +326,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
|
||||
|
||||
@Nullable
|
||||
public BlockState setBlockState(BlockPos blockposition, BlockState iblockdata, boolean flag, boolean doPlace) {
|
||||
|
||||
@@ -90,7 +90,7 @@ index 0000000000000000000000000000000000000000..7d93652c1abbb6aee6eb7c26cf35d4d0
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 47a1e391a9ed800616b055ce1ef0026943e2ab89..2c8d65efb164508318900319454b7ef0ab402f4d 100644
|
||||
index 5857d889f3debcfcc383914e7bb22f697de99ec7..9ec3a5332d5ad30d753bb3829dc8f933dcbaa1a7 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -804,6 +804,10 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
|
||||
@@ -324,10 +324,10 @@ index 4bfa947531c4a67989e18032754dabf4c69e989c..caf4120721be8f2f7e2d737abbf73296
|
||||
|
||||
public BlockPos getHomePos() {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index f4e69d6496d6960147436b8244d7d73fa10d148b..661c004c543c5114dbbbd7663cf0cdc300154b7b 100644
|
||||
index 38acdc61426b33ed4aceb46b9a63d47d894fe8cb..678228ed89809f613e6d95c2dd0446935fe27a23 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1512,9 +1512,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@@ -1515,9 +1515,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public abstract RecipeManager getRecipeManager();
|
||||
|
||||
public BlockPos getBlockRandomPos(int x, int y, int z, int l) {
|
||||
|
||||
@@ -108,7 +108,7 @@ index 0048077dedd19adc6c5a88e7d916d88a71662115..358efd39ae73f0a8a5c25d116af48c3e
|
||||
List list;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 3bb88e49fa4513011a082f06d592e70e759fd2ae..26aab541e157b3dafbbffbeab9bcc1dbf13c13c2 100644
|
||||
index c45507dce50ca8b553a620b4a0820883e9af2487..a17136f7a762b19ce4c6240323d2b74f91ebfba3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -182,6 +182,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -119,7 +119,7 @@ index 3bb88e49fa4513011a082f06d592e70e759fd2ae..26aab541e157b3dafbbffbeab9bcc1db
|
||||
}
|
||||
|
||||
void updateMaps(ServerPlayer player) {
|
||||
@@ -222,6 +223,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -197,6 +198,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
public final io.papermc.paper.util.player.NearbyPlayers nearbyPlayers;
|
||||
// Paper end
|
||||
@@ -130,7 +130,7 @@ index 3bb88e49fa4513011a082f06d592e70e759fd2ae..26aab541e157b3dafbbffbeab9bcc1db
|
||||
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
super(new RegionStorageInfo(session.getLevelId(), world.dimension(), "chunk"), session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
@@ -335,7 +340,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -308,7 +313,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return this.randomState;
|
||||
}
|
||||
|
||||
@@ -187,10 +187,10 @@ index 71abe25cfb73af3857cbc85980aa32d0201aab62..51c5901efbe4b5e6789aa9b7edbe973b
|
||||
|
||||
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
|
||||
index f3c5c66baf5e4d87d43c6e790923e22383211666..9ae1a0d7a0b36eea43f85e0a0cdc2296aef2e655 100644
|
||||
index 5bb01450d46106c8b1976ce66726a0867d6d6bca..4c396b34ed9c7ea2bef762da9e894c3de6a844b3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -524,18 +524,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -446,18 +446,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
|
||||
gameprofilerfiller.push("pollingChunks");
|
||||
gameprofilerfiller.push("filteringLoadedChunks");
|
||||
@@ -211,7 +211,7 @@ index f3c5c66baf5e4d87d43c6e790923e22383211666..9ae1a0d7a0b36eea43f85e0a0cdc2296
|
||||
|
||||
if (this.level.tickRateManager().runsNormally()) {
|
||||
gameprofilerfiller.popPush("naturalSpawnCount");
|
||||
@@ -570,36 +562,107 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -492,36 +484,107 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
gameprofilerfiller.popPush("spawnAndTick");
|
||||
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||
|
||||
@@ -335,7 +335,7 @@ index f3c5c66baf5e4d87d43c6e790923e22383211666..9ae1a0d7a0b36eea43f85e0a0cdc2296
|
||||
this.level.timings.chunkTicks.stopTiming(); // Paper
|
||||
|
||||
gameprofilerfiller.popPush("customSpawners");
|
||||
@@ -611,11 +674,23 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -533,11 +596,23 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("broadcast");
|
||||
|
||||
Reference in New Issue
Block a user