mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 16:50:17 +01:00
094bb03a37
- Lots of itemstack cloning removed. Only clone if the item is actually moved - Return true when a plugin cancels inventory move item event instead of false, as false causes pulls to cycle through all items. However, pushes do not exhibit the same behavior, so this is not something plugins could of been relying on. - Add option (Default on) to cooldown hoppers when they fail to move an item due to full inventory - Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
46 lines
2.7 KiB
Diff
46 lines
2.7 KiB
Diff
From 48b70d5e4a6b5cc7470d2bd282eaa54cae5c4af6 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Fri, 27 May 2016 21:41:26 -0400
|
|
Subject: [PATCH] Ensure Chunks never ever load async
|
|
|
|
Safely pushes the operation to main thread, then back to the posting thread
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
index 7b7a3d01b..9aaca21a7 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
|
|
@@ -4,6 +4,7 @@ import com.destroystokyo.paper.PaperConfig;
|
|
import net.minecraft.server.Chunk;
|
|
import net.minecraft.server.ChunkProviderServer;
|
|
import net.minecraft.server.ChunkRegionLoader;
|
|
+import net.minecraft.server.MCUtil; // Paper
|
|
import net.minecraft.server.World;
|
|
import org.bukkit.craftbukkit.util.AsynchronousExecutor;
|
|
|
|
@@ -14,7 +15,7 @@ public class ChunkIOExecutor {
|
|
private static final AsynchronousExecutor<QueuedChunk, Chunk, Runnable, RuntimeException> instance = new AsynchronousExecutor<QueuedChunk, Chunk, Runnable, RuntimeException>(new ChunkIOProvider(), BASE_THREADS);
|
|
|
|
public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) {
|
|
- return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider));
|
|
+ return MCUtil.ensureMain("Async Chunk Load", () -> instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider))); // Paper
|
|
}
|
|
|
|
public static void queueChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
|
|
index b5efb9c3f..ef9529add 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
|
|
@@ -35,8 +35,8 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
|
|
|
|
// sync stuff
|
|
public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException {
|
|
- if (chunk == null) {
|
|
- // If the chunk loading failed just do it synchronously (may generate)
|
|
+ if (chunk == null || queuedChunk.provider.chunks.containsKey(ChunkCoordIntPair.a(queuedChunk.x, queuedChunk.z))) { // Paper - also call original if it was already loaded
|
|
+ // If the chunk loading failed (or was already loaded for some reason) just do it synchronously (may generate)
|
|
queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z);
|
|
return;
|
|
}
|
|
--
|
|
2.16.1
|
|
|