mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 11:06:29 +01:00
36f34f01c0
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots 3abebc9f #492: Let Tameable extend Animals rather than Entity 941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent 4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME CraftBukkit Changes:933e9094
#664: Add methods to get/set ItemStacks in EquipmentSlots18722312
#662: Expose ItemStack and hand used in PlayerShearEntityEvent
59 lines
2.8 KiB
Diff
59 lines
2.8 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 9b5f24c262edb82a424385f8f3cb6aa506c0dcd9..b3785775ecd8e3c13e7829f641f2c1b5fd0d9d47 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -60,6 +60,16 @@ public class WorldServer extends World {
|
|
private final Queue<Entity> entitiesToAdd = Queues.newArrayDeque();
|
|
public final List<EntityPlayer> players = Lists.newArrayList(); // Paper - private -> 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;
|
|
private final WorldNBTStorage dataManager;
|
|
public boolean savingDisabled;
|
|
@@ -531,6 +541,16 @@ public class WorldServer extends World {
|
|
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
|
|
|
|
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index eb7b48422e06d25974f19a582c31fecb3b80271c..ac257d50dea8f42a515f19bbae12ab5680e26bb4 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -2473,7 +2473,7 @@ public class CraftWorld implements World {
|
|
|
|
CompletableFuture<Chunk> ret = new CompletableFuture<>();
|
|
this.world.getChunkProvider().getChunkAtAsynchronously(x, z, gen, (net.minecraft.server.Chunk chunk) -> {
|
|
- ret.complete(chunk == null ? null : chunk.bukkitChunk);
|
|
+ this.world.doIfNotEntityTicking(() -> ret.complete(chunk == null ? null : chunk.bukkitChunk));
|
|
});
|
|
|
|
return ret;
|