Add mid-tick task execution to block ticking

Dropped from the ticking block list rewrite
This commit is contained in:
Spottedleaf 2022-02-22 14:24:28 -08:00
parent 9cab01ed1d
commit cdb893bb9e
5 changed files with 29 additions and 13 deletions

View File

@ -128,7 +128,7 @@ index ab1b24820a5ec576f33095ad5688aaecd44910f4..264105bb8b806d64d1a108bb438a8623
}
// Paper start - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 3c2c326c974531eda95757893981a28fb52b4d16..b5e60bd6c023cfc9d48fe8c567feff24b00b3a0e 100644
index 3c2c326c974531eda95757893981a28fb52b4d16..d932a4d0688cccac8cf7418bf2eaaa40fa2b649d 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -201,7 +201,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -142,6 +142,22 @@ index 3c2c326c974531eda95757893981a28fb52b4d16..b5e60bd6c023cfc9d48fe8c567feff24
// CraftBukkit start
private int tickPosition;
@@ -962,6 +964,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (fluid1.is(fluid)) {
fluid1.tick(this, pos);
}
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
}
@@ -971,6 +974,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (iblockdata.is(block)) {
iblockdata.tick(this, pos, this.random);
}
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c603dcbe89a49e9e7de7fbc5c863e4b3a9869f95..1a76c8a52926bf15f55640d5c053a7235c58d3ed 100644
--- a/src/main/java/net/minecraft/world/level/Level.java

View File

@ -77,10 +77,10 @@ index bcf53ec07b8eeec7a88fb67e6fb908362e6f51b0..acc12307f61e1e055896b68fe16654c9
});
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index cb327920cfa8d4eec626af1fe42ec1cc5e8953c7..3735b80c6f827500a9c474d4139d6e748b14863b 100644
index d932a4d0688cccac8cf7418bf2eaaa40fa2b649d..8b37f9048495f0da85b811caf4d26930b334edb9 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -976,7 +976,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -978,7 +978,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
@ -107,7 +107,7 @@ index cb327920cfa8d4eec626af1fe42ec1cc5e8953c7..3735b80c6f827500a9c474d4139d6e74
++TimingHistory.entityTicks; // Paper - timings
// Spigot start
co.aikar.timings.Timing timer; // Paper
@@ -1016,7 +1035,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1018,7 +1037,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(entity, entity1);
}
// } finally { timer.stopTiming(); } // Paper - timings - move up

View File

@ -110,10 +110,10 @@ index 69533a1239f12c41a255bf9deeb5640695edfa13..3c90c6514dc856490da7fca5c8a42023
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005fb8df50e7 100644
index a55d652f9523df8274cec2aef8c903b100dce70e..546220bdc732f88b0dfe6c5caee399bfd795d71e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1093,6 +1093,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1095,6 +1095,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void tickNonPassenger(Entity entity) {
// Paper start - log detailed entity tick information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
@ -121,7 +121,7 @@ index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005f
try {
if (currentlyTickingEntity.get() == null) {
currentlyTickingEntity.lazySet(entity);
@@ -1545,9 +1546,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1547,9 +1548,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) {
List<PathNavigation> list = new ObjectArrayList();
@ -142,7 +142,7 @@ index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005f
// CraftBukkit start - fix SPIGOT-6362
Mob entityinsentient;
try {
@@ -1569,16 +1579,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1571,16 +1581,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
try {
this.isUpdatingNavigations = true;
@ -169,7 +169,7 @@ index 9c73cb316522302bf88b671398ba53c0eb2d29d5..9f1f55d457b1a99c12f7fc94aaf9005f
}
} // Paper
@@ -2374,10 +2391,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2376,10 +2393,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void onTickingStart(Entity entity) {
ServerLevel.this.entityTickList.add(entity);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fix merchant inventory not closing on entity removal
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index d14948b581f0a659511ba482015a03388f4aa3c0..a2abb8aa1a257ccd2b5dbddc037fffc6eb600758 100644
index 546220bdc732f88b0dfe6c5caee399bfd795d71e..24b0912f3a99c19103f2a07e6f6ba66e23afe3bc 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2475,6 +2475,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2477,6 +2477,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Spigot end
// Spigot Start
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message

View File

@ -1853,7 +1853,7 @@ index 98be0ea366732695f76bc5b1a78e0a36060515bd..e20fc528b85a8278bffab32845daac22
return true;
} else {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index e9de8f8ac62dab370c28b4ef6a4b61c8d3ebbb15..4ebdeca14b4b4378bb433d68d5f60da99ca95b82 100644
index 24b0912f3a99c19103f2a07e6f6ba66e23afe3bc..835a17cd4ec487271ba28232280dd0fbf2687c4b 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -655,7 +655,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -1877,7 +1877,7 @@ index e9de8f8ac62dab370c28b4ef6a4b61c8d3ebbb15..4ebdeca14b4b4378bb433d68d5f60da9
}
protected void tickTime() {
@@ -2367,7 +2370,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2369,7 +2372,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
// Paper start - optimize is ticking ready type functions
ChunkHolder chunkHolder = this.chunkSource.chunkMap.getVisibleChunkIfPresent(chunkPos);