2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-04-12 01:31:40 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 11 Apr 2020 21:23:42 -0400
|
|
|
|
Subject: [PATCH] Delay unsafe actions until after entity ticking is done
|
|
|
|
|
|
|
|
This will help prevent many cases of unregistering entities during entity ticking
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-09-10 23:47:58 +00:00
|
|
|
index 5841e77096f06ee38f115c6e2da91bac508c560e..ad7c5aa671c3a1d6bc7615d93d64fe909b172d79 100644
|
2020-04-12 01:31:40 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-08-25 02:22:08 +00:00
|
|
|
@@ -62,6 +62,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-04-12 01:31:40 +00:00
|
|
|
public final List<EntityPlayer> players = Lists.newArrayList(); // Paper - private -> public
|
2020-06-26 01:53:21 +00:00
|
|
|
public final ChunkProviderServer chunkProvider; // Paper - public
|
2020-04-12 01:31:40 +00:00
|
|
|
boolean tickingEntities;
|
|
|
|
+ // Paper start
|
|
|
|
+ List<java.lang.Runnable> afterEntityTickingTasks = Lists.newArrayList();
|
|
|
|
+ public void doIfNotEntityTicking(java.lang.Runnable run) {
|
|
|
|
+ if (tickingEntities) {
|
|
|
|
+ afterEntityTickingTasks.add(run);
|
|
|
|
+ } else {
|
|
|
|
+ run.run();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
private final MinecraftServer server;
|
2020-06-26 01:53:21 +00:00
|
|
|
public final WorldDataServer worldDataServer; // CraftBukkit - type
|
2020-04-12 01:31:40 +00:00
|
|
|
public boolean savingDisabled;
|
2020-08-25 02:22:08 +00:00
|
|
|
@@ -529,6 +539,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-04-12 01:31:40 +00:00
|
|
|
timings.entityTick.stopTiming(); // Spigot
|
|
|
|
|
|
|
|
this.tickingEntities = false;
|
|
|
|
+ // Paper start
|
|
|
|
+ for (java.lang.Runnable run : this.afterEntityTickingTasks) {
|
|
|
|
+ try {
|
|
|
|
+ run.run();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ LOGGER.error("Error in After Entity Ticking Task", e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.afterEntityTickingTasks.clear();
|
|
|
|
+ // Paper end
|
|
|
|
this.getMinecraftServer().midTickLoadChunks(); // Paper
|
|
|
|
|
2020-06-26 01:53:21 +00:00
|
|
|
Entity entity2;
|