Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
4e958e229f
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: zml <zml@stellardrift.ca> Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
46 Zeilen
2.0 KiB
Diff
46 Zeilen
2.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 1096ecf62127ad92dfed3872dbf6053c13975c94..1c1dceb98413ccb24e3111435119b3b8c1b760c4 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -66,6 +66,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
public final List<EntityPlayer> players = Lists.newArrayList(); // Paper - private -> public
|
|
public final ChunkProviderServer chunkProvider; // Paper - public
|
|
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;
|
|
public final WorldDataServer worldDataServer; // CraftBukkit - type
|
|
public boolean savingDisabled;
|
|
@@ -533,6 +543,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
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
|
|
|
|
Entity entity2;
|