Fix some [but not all] chunk unload issues
Dieser Commit ist enthalten in:
Ursprung
c5e9a169fa
Commit
7e9122e74d
@ -1,13 +1,12 @@
|
|||||||
--- a/net/minecraft/server/ChunkProviderServer.java
|
--- a/net/minecraft/server/ChunkProviderServer.java
|
||||||
+++ b/net/minecraft/server/ChunkProviderServer.java
|
+++ b/net/minecraft/server/ChunkProviderServer.java
|
||||||
@@ -14,10 +14,17 @@
|
@@ -14,10 +14,16 @@
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.Server;
|
+import org.bukkit.Server;
|
||||||
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
|
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
|
||||||
+import org.bukkit.craftbukkit.util.LongHashSet;
|
|
||||||
+import org.bukkit.event.world.ChunkUnloadEvent;
|
+import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
@ -15,27 +14,11 @@
|
|||||||
|
|
||||||
private static final Logger a = LogManager.getLogger();
|
private static final Logger a = LogManager.getLogger();
|
||||||
- private final Set<Long> unloadQueue = Sets.newHashSet();
|
- private final Set<Long> unloadQueue = Sets.newHashSet();
|
||||||
+ public final LongHashSet unloadQueue = new LongHashSet(); // CraftBukkit - LongHashSet
|
+ public final it.unimi.dsi.fastutil.longs.LongSet unloadQueue = new it.unimi.dsi.fastutil.longs.LongArraySet(); // CraftBukkit Set -> LongSet
|
||||||
public final ChunkGenerator chunkGenerator;
|
public final ChunkGenerator chunkGenerator;
|
||||||
private final IChunkLoader chunkLoader;
|
private final IChunkLoader chunkLoader;
|
||||||
public final Long2ObjectMap<Chunk> chunks = new Long2ObjectOpenHashMap(8192);
|
public final Long2ObjectMap<Chunk> chunks = new Long2ObjectOpenHashMap(8192);
|
||||||
@@ -35,7 +42,14 @@
|
@@ -69,19 +75,68 @@
|
||||||
|
|
||||||
public void unload(Chunk chunk) {
|
|
||||||
if (this.world.worldProvider.c(chunk.locX, chunk.locZ)) {
|
|
||||||
- this.unloadQueue.add(Long.valueOf(ChunkCoordIntPair.a(chunk.locX, chunk.locZ)));
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ this.unloadQueue.add(chunk.locX, chunk.locZ);
|
|
||||||
+
|
|
||||||
+ Chunk c = chunks.get(ChunkCoordIntPair.a(chunk.locX, chunk.locZ));
|
|
||||||
+ if (c != null) {
|
|
||||||
+ c.mustSave = true;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
chunk.d = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -69,19 +83,68 @@
|
|
||||||
Chunk chunk = this.getLoadedChunkAt(i, j);
|
Chunk chunk = this.getLoadedChunkAt(i, j);
|
||||||
|
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
@ -105,7 +88,7 @@
|
|||||||
|
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
long k = ChunkCoordIntPair.a(i, j);
|
long k = ChunkCoordIntPair.a(i, j);
|
||||||
@@ -97,9 +160,37 @@
|
@@ -97,9 +152,37 @@
|
||||||
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
|
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
|
||||||
throw new ReportedException(crashreport);
|
throw new ReportedException(crashreport);
|
||||||
}
|
}
|
||||||
@ -143,7 +126,7 @@
|
|||||||
chunk.loadNearby(this, this.chunkGenerator);
|
chunk.loadNearby(this, this.chunkGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,10 +237,12 @@
|
@@ -146,10 +229,12 @@
|
||||||
|
|
||||||
public boolean a(boolean flag) {
|
public boolean a(boolean flag) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -159,54 +142,33 @@
|
|||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
this.saveChunkNOP(chunk);
|
this.saveChunkNOP(chunk);
|
||||||
@@ -174,22 +267,41 @@
|
@@ -182,6 +267,29 @@
|
||||||
|
Chunk chunk = (Chunk) this.chunks.get(olong);
|
||||||
|
|
||||||
public boolean unloadChunks() {
|
if (chunk != null && chunk.d) {
|
||||||
if (!this.world.savingDisabled) {
|
+ // CraftBukkit start
|
||||||
- if (!this.unloadQueue.isEmpty()) {
|
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
||||||
- Iterator iterator = this.unloadQueue.iterator();
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||||
-
|
+ if (event.isCancelled()) {
|
||||||
- for (int i = 0; i < 100 && iterator.hasNext(); iterator.remove()) {
|
+ continue;
|
||||||
- Long olong = (Long) iterator.next();
|
+ }
|
||||||
- Chunk chunk = (Chunk) this.chunks.get(olong);
|
+
|
||||||
+ // CraftBukkit start
|
+ // Update neighbor counts
|
||||||
+ Server server = this.world.getServer();
|
+ for (int x = -2; x < 3; x++) {
|
||||||
+ for (int i = 0; i < 100 && !this.unloadQueue.isEmpty(); ++i) {
|
+ for (int z = -2; z < 3; z++) {
|
||||||
+ long chunkcoordinates = this.unloadQueue.popFirst();
|
+ if (x == 0 && z == 0) {
|
||||||
+ Chunk chunk = this.chunks.get(chunkcoordinates);
|
+ continue;
|
||||||
+ if (chunk == null) continue;
|
+ }
|
||||||
|
+
|
||||||
|
+ Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
|
||||||
|
+ if (neighbor != null) {
|
||||||
|
+ neighbor.setNeighborUnloaded(-x, -z);
|
||||||
|
+ chunk.setNeighborUnloaded(x, z);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
|
|
||||||
+ server.getPluginManager().callEvent(event);
|
|
||||||
+ if (!event.isCancelled()) {
|
|
||||||
|
|
||||||
- if (chunk != null && chunk.d) {
|
|
||||||
+ if (chunk != null) {
|
|
||||||
chunk.removeEntities();
|
chunk.removeEntities();
|
||||||
this.saveChunk(chunk);
|
this.saveChunk(chunk);
|
||||||
this.saveChunkNOP(chunk);
|
this.saveChunkNOP(chunk);
|
||||||
- this.chunks.remove(olong);
|
|
||||||
- ++i;
|
|
||||||
+ this.chunks.remove(chunkcoordinates); // CraftBukkit
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Update neighbor counts
|
|
||||||
+ for (int x = -2; x < 3; x++) {
|
|
||||||
+ for (int z = -2; z < 3; z++) {
|
|
||||||
+ if (x == 0 && z == 0) {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
|
|
||||||
+ if (neighbor != null) {
|
|
||||||
+ neighbor.setNeighborUnloaded(-x, -z);
|
|
||||||
+ chunk.setNeighborUnloaded(x, z);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ // CraftBukkit end
|
|
||||||
|
|
||||||
this.chunkLoader.a();
|
|
||||||
}
|
|
||||||
|
@ -203,7 +203,7 @@ public class CraftWorld implements World {
|
|||||||
world.getChunkProviderServer().saveChunkNOP(chunk);
|
world.getChunkProviderServer().saveChunkNOP(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.getChunkProviderServer().unloadQueue.remove(x, z);
|
world.getChunkProviderServer().unloadQueue.remove(ChunkCoordIntPair.a(x, z));
|
||||||
world.getChunkProviderServer().chunks.remove(ChunkCoordIntPair.a(x, z));
|
world.getChunkProviderServer().chunks.remove(ChunkCoordIntPair.a(x, z));
|
||||||
|
|
||||||
// Update neighbor counts
|
// Update neighbor counts
|
||||||
@ -227,7 +227,7 @@ public class CraftWorld implements World {
|
|||||||
public boolean regenerateChunk(int x, int z) {
|
public boolean regenerateChunk(int x, int z) {
|
||||||
unloadChunk0(x, z, false, false);
|
unloadChunk0(x, z, false, false);
|
||||||
|
|
||||||
world.getChunkProviderServer().unloadQueue.remove(x, z);
|
world.getChunkProviderServer().unloadQueue.remove(ChunkCoordIntPair.a(x, z));
|
||||||
|
|
||||||
net.minecraft.server.Chunk chunk = null;
|
net.minecraft.server.Chunk chunk = null;
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ public class CraftWorld implements World {
|
|||||||
return world.getChunkProviderServer().getChunkAt(x, z) != null;
|
return world.getChunkProviderServer().getChunkAt(x, z) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
world.getChunkProviderServer().unloadQueue.remove(x, z);
|
world.getChunkProviderServer().unloadQueue.remove(ChunkCoordIntPair.a(x, z));
|
||||||
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(ChunkCoordIntPair.a(x, z));
|
net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(ChunkCoordIntPair.a(x, z));
|
||||||
|
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
@ -1515,7 +1515,7 @@ public class CraftWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Already unloading?
|
// Already unloading?
|
||||||
if (cps.unloadQueue.contains(chunk.locX, chunk.locZ)) {
|
if (cps.unloadQueue.contains(ChunkCoordIntPair.a(chunk.locX, chunk.locZ))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren