Skip to content

Commit cdb893b

Browse files
committed
Add mid-tick task execution to block ticking
Dropped from the ticking block list rewrite
1 parent 9cab01e commit cdb893b

5 files changed

+29
-13
lines changed

patches/server/0749-Execute-chunk-tasks-mid-tick.patch

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ index ab1b24820a5ec576f33095ad5688aaecd44910f4..264105bb8b806d64d1a108bb438a8623
128128
}
129129
// Paper start - optimise chunk tick iteration
130130
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
131-
index 3c2c326c974531eda95757893981a28fb52b4d16..b5e60bd6c023cfc9d48fe8c567feff24b00b3a0e 100644
131+
index 3c2c326c974531eda95757893981a28fb52b4d16..d932a4d0688cccac8cf7418bf2eaaa40fa2b649d 100644
132132
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
133133
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
134134
@@ -201,7 +201,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -142,6 +142,22 @@ index 3c2c326c974531eda95757893981a28fb52b4d16..b5e60bd6c023cfc9d48fe8c567feff24
142142

143143
// CraftBukkit start
144144
private int tickPosition;
145+
@@ -962,6 +964,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
146+
if (fluid1.is(fluid)) {
147+
fluid1.tick(this, pos);
148+
}
149+
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
150+
151+
}
152+
153+
@@ -971,6 +974,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
154+
if (iblockdata.is(block)) {
155+
iblockdata.tick(this, pos, this.random);
156+
}
157+
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
158+
159+
}
160+
145161
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
146162
index c603dcbe89a49e9e7de7fbc5c863e4b3a9869f95..1a76c8a52926bf15f55640d5c053a7235c58d3ed 100644
147163
--- a/src/main/java/net/minecraft/world/level/Level.java

patches/server/0753-Detail-more-information-in-watchdog-dumps.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ index bcf53ec07b8eeec7a88fb67e6fb908362e6f51b0..acc12307f61e1e055896b68fe16654c9
7777
});
7878
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
7979
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
80-
index cb327920cfa8d4eec626af1fe42ec1cc5e8953c7..3735b80c6f827500a9c474d4139d6e748b14863b 100644
80+
index d932a4d0688cccac8cf7418bf2eaaa40fa2b649d..8b37f9048495f0da85b811caf4d26930b334edb9 100644
8181
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
8282
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
83-
@@ -976,7 +976,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
83+
@@ -978,7 +978,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
8484

8585
}
8686

@@ -107,7 +107,7 @@ index cb327920cfa8d4eec626af1fe42ec1cc5e8953c7..3735b80c6f827500a9c474d4139d6e74
107107
++TimingHistory.entityTicks; // Paper - timings
108108
// Spigot start
109109
co.aikar.timings.Timing timer; // Paper
110-
@@ -1016,7 +1035,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
110+
@@ -1018,7 +1037,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
111111
this.tickPassenger(entity, entity1);
112112
}
113113
// } finally { timer.stopTiming(); } // Paper - timings - move up

patches/server/0773-Optimise-WorldServer-notify.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ index 69533a1239f12c41a255bf9deeb5640695edfa13..3c90c6514dc856490da7fca5c8a42023
110110
}
111111

112112
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
113-
index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005fb8df50e7 100644
113+
index a55d652f9523df8274cec2aef8c903b100dce70e..546220bdc732f88b0dfe6c5caee399bfd795d71e 100644
114114
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
115115
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
116-
@@ -1093,6 +1093,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
116+
@@ -1095,6 +1095,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
117117
public void tickNonPassenger(Entity entity) {
118118
// Paper start - log detailed entity tick information
119119
io.papermc.paper.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
120120
+ this.entityManager.updateNavigatorsInRegion(entity); // Paper - optimise notify
121121
try {
122122
if (currentlyTickingEntity.get() == null) {
123123
currentlyTickingEntity.lazySet(entity);
124-
@@ -1545,9 +1546,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
124+
@@ -1547,9 +1548,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
125125

126126
if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) {
127127
List<PathNavigation> list = new ObjectArrayList();
@@ -142,7 +142,7 @@ index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005f
142142
// CraftBukkit start - fix SPIGOT-6362
143143
Mob entityinsentient;
144144
try {
145-
@@ -1569,16 +1579,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
145+
@@ -1571,16 +1581,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
146146

147147
try {
148148
this.isUpdatingNavigations = true;
@@ -169,7 +169,7 @@ index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005f
169169

170170
}
171171
} // Paper
172-
@@ -2374,10 +2391,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
172+
@@ -2376,10 +2393,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
173173

174174
public void onTickingStart(Entity entity) {
175175
ServerLevel.this.entityTickList.add(entity);

patches/server/0781-Fix-merchant-inventory-not-closing-on-entity-removal.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Subject: [PATCH] Fix merchant inventory not closing on entity removal
55

66

77
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
8-
index d14948b581f0a659511ba482015a03388f4aa3c0..a2abb8aa1a257ccd2b5dbddc037fffc6eb600758 100644
8+
index 546220bdc732f88b0dfe6c5caee399bfd795d71e..24b0912f3a99c19103f2a07e6f6ba66e23afe3bc 100644
99
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
1010
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
11-
@@ -2475,6 +2475,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
11+
@@ -2477,6 +2477,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
1212
// Spigot end
1313
// Spigot Start
1414
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message

patches/server/0868-Replace-player-chunk-loader-system.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ index 98be0ea366732695f76bc5b1a78e0a36060515bd..e20fc528b85a8278bffab32845daac22
18531853
return true;
18541854
} else {
18551855
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
1856-
index e9de8f8ac62dab370c28b4ef6a4b61c8d3ebbb15..4ebdeca14b4b4378bb433d68d5f60da99ca95b82 100644
1856+
index 24b0912f3a99c19103f2a07e6f6ba66e23afe3bc..835a17cd4ec487271ba28232280dd0fbf2687c4b 100644
18571857
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
18581858
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
18591859
@@ -655,7 +655,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1877,7 +1877,7 @@ index e9de8f8ac62dab370c28b4ef6a4b61c8d3ebbb15..4ebdeca14b4b4378bb433d68d5f60da9
18771877
}
18781878

18791879
protected void tickTime() {
1880-
@@ -2367,7 +2370,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
1880+
@@ -2369,7 +2372,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
18811881
private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
18821882
// Paper start - optimize is ticking ready type functions
18831883
ChunkHolder chunkHolder = this.chunkSource.chunkMap.getVisibleChunkIfPresent(chunkPos);

0 commit comments

Comments
 (0)