mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 11:42:55 +01:00
more chunk unload queue fixes, hopefully fix various odd bugs
This commit is contained in:
parent
092733e8ff
commit
a9d8237509
3 changed files with 74 additions and 38 deletions
|
@ -1,11 +1,11 @@
|
|||
From 0241d5c821cff01bc4ad9d4b1b3611338228a68a Mon Sep 17 00:00:00 2001
|
||||
From 064ef8799679a16ccfc7538d2796d374f4a1b0f4 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 2 Mar 2016 23:55:20 -0600
|
||||
Subject: [PATCH] Don't create a chunk just to unload it
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 898316f..46648bf 100644
|
||||
index 899ce8f..83b14d9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -213,7 +213,13 @@ public class CraftWorld implements World {
|
||||
|
@ -14,7 +14,7 @@ index 898316f..46648bf 100644
|
|||
private boolean unloadChunk0(int x, int z, boolean save, boolean safe) {
|
||||
- net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z);
|
||||
+ // Paper start - Don't create a chunk just to unload it
|
||||
+ net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getLoadedChunkAt(x, z);
|
||||
+ net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkIfLoaded(x, z);
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
|
@ -24,5 +24,5 @@ index 898316f..46648bf 100644
|
|||
save = true;
|
||||
}
|
||||
--
|
||||
2.8.2
|
||||
2.8.3
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
From 11580ee1b1f7b4c824750e7bc35e86acb15e21f5 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 12 May 2016 02:03:56 -0400
|
||||
Subject: [PATCH] Fix Chunk Unload Queue Issues
|
||||
|
||||
Vanilla implemented similar logic as Paper had pre 1.9.4, but Spigot
|
||||
has not resolved all the bugs with the changes.
|
||||
|
||||
This patch fixes known issues and really should be applied by Spigot team.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index d7b9581..e3cc816 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -47,7 +47,7 @@ public class Chunk {
|
||||
private long w;
|
||||
private int x;
|
||||
private ConcurrentLinkedQueue<BlockPosition> y;
|
||||
- public boolean d;
|
||||
+ public boolean d;public void setShouldUnload(boolean unload) { this.d = unload; } public boolean isUnloading() { return d; } // Paper // OBFHELPER
|
||||
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
|
||||
|
||||
// Paper start
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 6d1b98b..4a2cad6 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -309,6 +309,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
Chunk chunk = (Chunk) this.chunks.get(olong);
|
||||
|
||||
if (chunk != null && chunk.d) {
|
||||
+ chunk.setShouldUnload(false); // Paper
|
||||
// CraftBukkit start
|
||||
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 03dae89..58f5141 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -303,6 +303,9 @@ public class CraftWorld implements World {
|
||||
// Use the default variant of loadChunk when generate == true.
|
||||
return world.getChunkProviderServer().getChunkAt(x, z) != null;
|
||||
}
|
||||
+ // Paper start - below is not updated for the new unload queue logic.
|
||||
+ return world.getChunkProviderServer().getOrLoadChunkAt(x, z) != null;
|
||||
+ /*
|
||||
|
||||
world.getChunkProviderServer().unloadQueue.remove(ChunkCoordIntPair.a(x, z));
|
||||
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(ChunkCoordIntPair.a(x, z));
|
||||
@@ -312,7 +315,7 @@ public class CraftWorld implements World {
|
||||
chunk = world.getChunkProviderServer().getOrLoadChunkAt(x, z);
|
||||
world.timings.syncChunkLoadTimer.stopTiming(); // Spigot
|
||||
}
|
||||
- return chunk != null;
|
||||
+ return chunk != null;*/ // Paper end
|
||||
}
|
||||
|
||||
private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int cx, int cz) {
|
||||
@@ -1548,7 +1551,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
// Already unloading?
|
||||
- if (cps.unloadQueue.contains(ChunkCoordIntPair.a(chunk.locX, chunk.locZ))) {
|
||||
+ if (chunk.isUnloading()) { // Paper
|
||||
continue;
|
||||
}
|
||||
|
||||
--
|
||||
2.8.3
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
From 315afb375674d27304fae4183a583984e739055f Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 12 May 2016 02:03:56 -0400
|
||||
Subject: [PATCH] Unmark chunk as unloading when unload is cancelled
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index d7b9581..40d4c9c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -47,7 +47,7 @@ public class Chunk {
|
||||
private long w;
|
||||
private int x;
|
||||
private ConcurrentLinkedQueue<BlockPosition> y;
|
||||
- public boolean d;
|
||||
+ public boolean d;public void setShouldUnload(boolean unload) { this.d = unload; } // Paper // OBFHELPER
|
||||
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
|
||||
|
||||
// Paper start
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index 6d1b98b..4a2cad6 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -309,6 +309,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
Chunk chunk = (Chunk) this.chunks.get(olong);
|
||||
|
||||
if (chunk != null && chunk.d) {
|
||||
+ chunk.setShouldUnload(false); // Paper
|
||||
// CraftBukkit start
|
||||
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
||||
this.world.getServer().getPluginManager().callEvent(event);
|
||||
--
|
||||
2.7.4 (Apple Git-66)
|
||||
|
Loading…
Reference in a new issue