mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-17 02:34:30 +01:00
More progression on patches
This commit is contained in:
parent
8199a18b2b
commit
78640d1334
13 changed files with 4371 additions and 23 deletions
Spigot-Server-Patches
Anti-Xray.patchAsynchronous-chunk-IO-and-loading.patchDo-less-work-if-we-have-a-custom-Bukkit-generator.patchFix-AssertionError-when-player-hand-set-to-empty-typ.patchFix-World-isChunkGenerated-calls.patchFix-spawning-of-hanging-entities-that-are-not-ItemFr.patchFix-stuck-in-sneak-when-changing-worlds-MC-10657.patchFix-zero-tick-instant-grow-farms-MC-113809.patchMC-Dev-fixes.patchMC-Utils.patchPrevent-consuming-the-wrong-itemstack.patchUse-ChunkStatus-cache-when-saving-protochunks.patchimplement-optional-per-player-mob-spawns.patch
|
@ -1194,7 +1194,7 @@ index 14ec31f0a..863a2222f 100644
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 6371f2f5b..17cacafe7 100644
|
||||
index 961228e9d..a950ad801 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
|
||||
|
@ -1533,7 +1533,7 @@ index 47710067a..ef7ade797 100644
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
index 43d9a5634..615d27863 100644
|
||||
index 6f2cca07e..7a1578afa 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunk {
|
||||
|
@ -1558,7 +1558,7 @@ index 43d9a5634..615d27863 100644
|
|||
this.a(new PacketPlayOutMultiBlockChange(this.dirtyCount, this.dirtyBlocks, chunk), false);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index 93729eea2..fc6436c4f 100644
|
||||
index cbab813d9..6a54ccb86 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
|
3922
Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch
Normal file
3922
Spigot-Server-Patches/Asynchronous-chunk-IO-and-loading.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ If the Bukkit generator already has a spawn, use it immediately instead
|
|||
of spending time generating one that we won't use
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 8ea9b34a1..7b89b509a 100644
|
||||
index fecbe7914..a08308a12 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -0,0 +0,0 @@ public class WorldServer extends World {
|
||||
|
|
|
@ -7,7 +7,7 @@ Fixes an AssertionError when setting the player's item in hand to null or a new
|
|||
Fixes GH-2718
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index d04ea03bc..5431f8a8d 100644
|
||||
index 4690ef840..90fc7febe 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
||||
|
|
375
Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch
Normal file
375
Spigot-Server-Patches/Fix-World-isChunkGenerated-calls.patch
Normal file
|
@ -0,0 +1,375 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sat, 15 Jun 2019 08:54:33 -0700
|
||||
Subject: [PATCH] Fix World#isChunkGenerated calls
|
||||
|
||||
Optimize World#loadChunk() too
|
||||
This patch also adds a chunk status cache on region files (note that
|
||||
its only purpose is to cache the status on DISK)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index f138b112f..e9cd44fae 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
|
||||
private final WorldServer world;
|
||||
private final Thread serverThread;
|
||||
private final LightEngineThreaded lightEngine;
|
||||
- private final ChunkProviderServer.a serverThreadQueue;
|
||||
+ public final ChunkProviderServer.a serverThreadQueue; // Paper private -> public
|
||||
public final PlayerChunkMap playerChunkMap;
|
||||
private final WorldPersistentData worldPersistentData;
|
||||
private long lastTickTime;
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
|
||||
|
||||
return playerChunk.getFullChunk();
|
||||
}
|
||||
+
|
||||
+ @Nullable
|
||||
+ public IChunkAccess getChunkAtImmediately(int x, int z) {
|
||||
+ long k = ChunkCoordIntPair.pair(x, z);
|
||||
+
|
||||
+ // Note: Bypass cache to make this MT-Safe
|
||||
+
|
||||
+ PlayerChunk playerChunk = this.getChunk(k);
|
||||
+ if (playerChunk == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return playerChunk.getAvailableChunkNow();
|
||||
+
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index 6371f2f5b..961228e9d 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader {
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static ChunkStatus getStatus(NBTTagCompound compound) {
|
||||
+ if (compound == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ // Note: Copied from below
|
||||
+ return ChunkStatus.getStatus(compound.getCompound("Level").getString("Status"));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static ChunkStatus.Type a(@Nullable NBTTagCompound nbttagcompound) {
|
||||
if (nbttagcompound != null) {
|
||||
ChunkStatus chunkstatus = ChunkStatus.a(nbttagcompound.getCompound("Level").getString("Status"));
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkStatus.java b/src/main/java/net/minecraft/server/ChunkStatus.java
|
||||
index efdf611e6..134a4f0b7 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkStatus.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkStatus.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkStatus {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
+ public ChunkStatus getPreviousStatus() { return this.e(); } // Paper - OBFHELPER
|
||||
public ChunkStatus e() {
|
||||
return this.u;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ChunkStatus {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static ChunkStatus getStatus(String name) {
|
||||
+ try {
|
||||
+ // We need this otherwise we return EMPTY for invalid names
|
||||
+ MinecraftKey key = new MinecraftKey(name);
|
||||
+ return IRegistry.CHUNK_STATUS.getOptional(key).orElse(null);
|
||||
+ } catch (Exception ex) {
|
||||
+ return null; // invalid name
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
public static ChunkStatus a(String s) {
|
||||
return (ChunkStatus) IRegistry.CHUNK_STATUS.get(MinecraftKey.a(s));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/IChunkLoader.java b/src/main/java/net/minecraft/server/IChunkLoader.java
|
||||
index f0a052eec..2f95174fc 100644
|
||||
--- a/src/main/java/net/minecraft/server/IChunkLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/IChunkLoader.java
|
||||
@@ -0,0 +0,0 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class IChunkLoader implements AutoCloseable {
|
||||
|
||||
- private final IOWorker a;
|
||||
+ private final IOWorker a; public IOWorker getIOWorker() { return a; } // Paper - OBFHELPER
|
||||
protected final DataFixer b;
|
||||
@Nullable
|
||||
private PersistentStructureLegacy c;
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
index 43d9a5634..6f2cca07e 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunk {
|
||||
Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null);
|
||||
return either == null ? null : (Chunk) either.left().orElse(null);
|
||||
}
|
||||
+
|
||||
+ public IChunkAccess getAvailableChunkNow() {
|
||||
+ // TODO can we just getStatusFuture(EMPTY)?
|
||||
+ for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getPreviousStatus(); curr != next; curr = next, next = next.getPreviousStatus()) {
|
||||
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> future = this.getStatusFutureUnchecked(curr);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = future.getNow(null);
|
||||
+ if (either == null || !either.left().isPresent()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ return either.left().get();
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index 4379434f6..8e2208422 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
+ public NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { // Paper - private -> public
|
||||
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
||||
|
||||
- return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
||||
+ // Paper start - Cache chunk status on disk
|
||||
+ if (nbttagcompound == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ nbttagcompound = this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
||||
+ if (nbttagcompound == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ this.updateChunkStatusOnDisk(chunkcoordintpair, nbttagcompound);
|
||||
+
|
||||
+ return nbttagcompound;
|
||||
+ // Paper end
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - chunk status cache "api"
|
||||
+ public ChunkStatus getChunkStatusOnDiskIfCached(ChunkCoordIntPair chunkPos) {
|
||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getRegionFileIfLoaded(chunkPos);
|
||||
+
|
||||
+ return regionFile == null ? null : regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
||||
+ }
|
||||
+
|
||||
+ public ChunkStatus getChunkStatusOnDisk(ChunkCoordIntPair chunkPos) throws IOException {
|
||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, false);
|
||||
+
|
||||
+ if (!regionFile.chunkExists(chunkPos)) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ ChunkStatus status = regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
||||
+
|
||||
+ if (status != null) {
|
||||
+ return status;
|
||||
+ }
|
||||
+
|
||||
+ this.readChunkData(chunkPos);
|
||||
+
|
||||
+ return regionFile.getStatusIfCached(chunkPos.x, chunkPos.z);
|
||||
+ }
|
||||
+
|
||||
+ public void updateChunkStatusOnDisk(ChunkCoordIntPair chunkPos, @Nullable NBTTagCompound compound) throws IOException {
|
||||
+ RegionFile regionFile = this.getIOWorker().getRegionFileCache().getFile(chunkPos, false);
|
||||
+
|
||||
+ regionFile.setStatus(chunkPos.x, chunkPos.z, ChunkRegionLoader.getStatus(compound));
|
||||
+ }
|
||||
+
|
||||
+ public IChunkAccess getUnloadingChunk(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunkHolder = this.pendingUnload.get(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow();
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
||||
// Spigot start
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
|
||||
index 5d2cbbad2..7eb87c517 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
||||
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
|
||||
private final IntBuffer h;
|
||||
private final RegionFileBitSet freeSectors;
|
||||
|
||||
+ // Paper start - Cache chunk status
|
||||
+ private final ChunkStatus[] statuses = new ChunkStatus[32 * 32];
|
||||
+
|
||||
+ private boolean closed;
|
||||
+
|
||||
+ // invoked on write/read
|
||||
+ public void setStatus(int x, int z, ChunkStatus status) {
|
||||
+ if (this.closed) {
|
||||
+ // We've used an invalid region file.
|
||||
+ throw new IllegalStateException("RegionFile is closed");
|
||||
+ }
|
||||
+ this.statuses[this.getChunkLocation(new ChunkCoordIntPair(x, z))] = status;
|
||||
+ }
|
||||
+
|
||||
+ public ChunkStatus getStatusIfCached(int x, int z) {
|
||||
+ if (this.closed) {
|
||||
+ // We've used an invalid region file.
|
||||
+ throw new IllegalStateException("RegionFile is closed");
|
||||
+ }
|
||||
+ final int location = this.getChunkLocation(new ChunkCoordIntPair(x, z));
|
||||
+ return this.statuses[location];
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public RegionFile(File file, File file1) throws IOException {
|
||||
this(file.toPath(), file1.toPath(), RegionFileCompression.b);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable {
|
||||
return this.getOffset(chunkcoordintpair) != 0;
|
||||
}
|
||||
|
||||
+ private final int getChunkLocation(ChunkCoordIntPair chunkcoordintpair) { return this.g(chunkcoordintpair); } // Paper - OBFHELPER
|
||||
private static int g(ChunkCoordIntPair chunkcoordintpair) {
|
||||
return chunkcoordintpair.j() + chunkcoordintpair.k() * 32;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
+ this.closed = true; // Paper
|
||||
try {
|
||||
this.c();
|
||||
} finally {
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
index 57ce53cfd..1a6be7c6d 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
@@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable {
|
||||
this.b = file;
|
||||
}
|
||||
|
||||
- private RegionFile getFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
|
||||
+
|
||||
+ // Paper start
|
||||
+ public RegionFile getRegionFileIfLoaded(ChunkCoordIntPair chunkcoordintpair) {
|
||||
+ return this.cache.getAndMoveToFirst(ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
|
||||
+ }
|
||||
+
|
||||
+ // Paper end
|
||||
+ public RegionFile getFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - private > public
|
||||
long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
||||
RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i);
|
||||
|
||||
@@ -0,0 +0,0 @@ public final class RegionFileCache implements AutoCloseable {
|
||||
|
||||
try {
|
||||
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
|
||||
+ regionfile.setStatus(chunkcoordintpair.x, chunkcoordintpair.z, ChunkRegionLoader.getStatus(nbttagcompound)); // Paper - cache status on disk
|
||||
} catch (Throwable throwable1) {
|
||||
throwable = throwable1;
|
||||
throw throwable1;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index b1ae19be7..7d509856b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
|
||||
@Override
|
||||
public boolean isChunkGenerated(int x, int z) {
|
||||
+ // Paper start - Fix this method
|
||||
+ if (!Bukkit.isPrimaryThread()) {
|
||||
+ return CompletableFuture.supplyAsync(() -> {
|
||||
+ return CraftWorld.this.isChunkGenerated(x, z);
|
||||
+ }, world.getChunkProvider().serverThreadQueue).join();
|
||||
+ }
|
||||
+ IChunkAccess chunk = world.getChunkProvider().getChunkAtImmediately(x, z);
|
||||
+ if (chunk == null) {
|
||||
+ chunk = world.getChunkProvider().playerChunkMap.getUnloadingChunk(x, z);
|
||||
+ }
|
||||
+ if (chunk != null) {
|
||||
+ return chunk instanceof ProtoChunkExtension || chunk instanceof net.minecraft.server.Chunk;
|
||||
+ }
|
||||
try {
|
||||
- return world.getChunkProvider().getChunkAtIfCachedImmediately(x, z) != null || world.getChunkProvider().playerChunkMap.read(new ChunkCoordIntPair(x, z)) != null; // Paper (TODO check if the first part can be removed)
|
||||
+ return world.getChunkProvider().playerChunkMap.getChunkStatusOnDisk(new ChunkCoordIntPair(x, z)) == ChunkStatus.FULL;
|
||||
+ // Paper end
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
@Override
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
||||
- IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
|
||||
+ // Paper start - Optimize this method
|
||||
+ ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(x, z);
|
||||
|
||||
- // If generate = false, but the chunk already exists, we will get this back.
|
||||
- if (chunk instanceof ProtoChunkExtension) {
|
||||
- // We then cycle through again to get the full chunk immediately, rather than after the ticket addition
|
||||
- chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
|
||||
- }
|
||||
+ if (!generate) {
|
||||
|
||||
- if (chunk instanceof net.minecraft.server.Chunk) {
|
||||
- world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
|
||||
- return true;
|
||||
+ IChunkAccess immediate = world.getChunkProvider().getChunkAtImmediately(x, z);
|
||||
+ if (immediate == null) {
|
||||
+ immediate = world.getChunkProvider().playerChunkMap.getUnloadingChunk(x, z);
|
||||
+ }
|
||||
+ if (immediate != null) {
|
||||
+ if (!(immediate instanceof ProtoChunkExtension) && !(immediate instanceof net.minecraft.server.Chunk)) {
|
||||
+ return false; // not full status
|
||||
+ }
|
||||
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
||||
+ world.getChunkAt(x, z); // make sure we're at ticket level 32 or lower
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.server.RegionFile file;
|
||||
+ try {
|
||||
+ file = world.getChunkProvider().playerChunkMap.getIOWorker().getRegionFileCache().getFile(chunkPos, false);
|
||||
+ } catch (IOException ex) {
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+
|
||||
+ ChunkStatus status = file.getStatusIfCached(x, z);
|
||||
+ if (!file.chunkExists(chunkPos) || (status != null && status != ChunkStatus.FULL)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.EMPTY, true);
|
||||
+ if (!(chunk instanceof ProtoChunkExtension) && !(chunk instanceof net.minecraft.server.Chunk)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // fall through to load
|
||||
+ // we do this so we do not re-read the chunk data on disk
|
||||
}
|
||||
|
||||
- return false;
|
||||
+ world.getChunkProvider().addTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
||||
+ world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true);
|
||||
+ return true;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
--
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fix spawning of hanging entities that are not ItemFrames and
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index b1ae19be7..cd519a546 100644
|
||||
index 7abad24f0..73e987671 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Fix stuck in sneak when changing worlds (MC-10657)
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index 19ba79c65..453f02561 100644
|
||||
index c9492ed37..95a5643a6 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
|
|
@ -45,7 +45,7 @@ index c482aad3e..02c548dd9 100644
|
|||
int i = this.b(worldserver, blockposition) + 1;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java
|
||||
index 4c82fe335..44ce67eb8 100644
|
||||
index e0974e256..3524fcb92 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockCactus.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockCactus.java
|
||||
@@ -0,0 +0,0 @@ public class BlockCactus extends Block {
|
||||
|
@ -81,7 +81,7 @@ index 55b07444e..3bc3c5aa2 100644
|
|||
|
||||
for (i = 1; worldserver.getType(blockposition.down(i)).getBlock() == this; ++i) {
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index fd42390d4..4c53f8063 100644
|
||||
index 4da5c8982..b15fb2b63 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -0,0 +0,0 @@ public class WorldServer extends World {
|
||||
|
|
|
@ -278,6 +278,46 @@ index a2bbca22b..c8512f9f4 100644
|
|||
|
||||
if (pathfindertargetcondition.a(entityliving, t0)) {
|
||||
list1.add(t0);
|
||||
diff --git a/src/main/java/net/minecraft/server/IOWorker.java b/src/main/java/net/minecraft/server/IOWorker.java
|
||||
index a986f2912..c5658c077 100644
|
||||
--- a/src/main/java/net/minecraft/server/IOWorker.java
|
||||
+++ b/src/main/java/net/minecraft/server/IOWorker.java
|
||||
@@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable {
|
||||
if (throwable != null) {
|
||||
completablefuture.completeExceptionally(throwable);
|
||||
} else {
|
||||
- completablefuture.complete((Object) null);
|
||||
+ completablefuture.complete(null); // Paper - Decompile fix
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable {
|
||||
}));
|
||||
|
||||
completablefuture1.whenComplete((object, throwable) -> {
|
||||
- completablefuture.complete((Object) null);
|
||||
+ completablefuture.complete(null); // Paper - decompile fix
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable {
|
||||
private void a(ChunkCoordIntPair chunkcoordintpair, IOWorker.a ioworker_a) {
|
||||
try {
|
||||
this.e.write(chunkcoordintpair, ioworker_a.a);
|
||||
- ioworker_a.b.complete((Object) null);
|
||||
+ ioworker_a.b.complete(null); // Paper - decompile fix
|
||||
} catch (Exception exception) {
|
||||
IOWorker.LOGGER.error("Failed to store chunk {}", chunkcoordintpair, exception);
|
||||
ioworker_a.b.completeExceptionally(exception);
|
||||
@@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable {
|
||||
private void g() {
|
||||
try {
|
||||
this.e.close();
|
||||
- this.h.complete((Object) null);
|
||||
+ this.h.complete(null); // Paper - decompile fix
|
||||
} catch (Exception exception) {
|
||||
IOWorker.LOGGER.error("Failed to close storage", exception);
|
||||
this.h.completeExceptionally(exception);
|
||||
diff --git a/src/main/java/net/minecraft/server/LootSelectorEntry.java b/src/main/java/net/minecraft/server/LootSelectorEntry.java
|
||||
index 59bb53543..3ed6a1e78 100644
|
||||
--- a/src/main/java/net/minecraft/server/LootSelectorEntry.java
|
||||
|
|
|
@ -400,6 +400,19 @@ index 3b0877080..0dff02352 100644
|
|||
default int h(BlockPosition blockposition) {
|
||||
return this.getType(blockposition).h();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/IOWorker.java b/src/main/java/net/minecraft/server/IOWorker.java
|
||||
index c5658c077..b90baef0f 100644
|
||||
--- a/src/main/java/net/minecraft/server/IOWorker.java
|
||||
+++ b/src/main/java/net/minecraft/server/IOWorker.java
|
||||
@@ -0,0 +0,0 @@ public class IOWorker implements AutoCloseable {
|
||||
private final Thread b;
|
||||
private final AtomicBoolean c = new AtomicBoolean();
|
||||
private final Queue<Runnable> d = Queues.newConcurrentLinkedQueue();
|
||||
- private final RegionFileCache e;
|
||||
+ private final RegionFileCache e; public RegionFileCache getRegionFileCache() { return e; } // Paper - OBFHELPER
|
||||
private final Map<ChunkCoordIntPair, IOWorker.a> f = Maps.newLinkedHashMap();
|
||||
private boolean g = true;
|
||||
private CompletableFuture<Void> h = new CompletableFuture();
|
||||
diff --git a/src/main/java/net/minecraft/server/IWorldReader.java b/src/main/java/net/minecraft/server/IWorldReader.java
|
||||
index ba315131e..cbe2aa4c0 100644
|
||||
--- a/src/main/java/net/minecraft/server/IWorldReader.java
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Prevent consuming the wrong itemstack
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 1b5acf77e..d04ea03bc 100644
|
||||
index aa0118a7c..4690ef840 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
||||
|
|
|
@ -7,7 +7,7 @@ The cache should contain the chunk status when saving. If not it
|
|||
will load it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index 4379434f6..93729eea2 100644
|
||||
index 8e2208422..cbab813d9 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
|
|
@ -5,27 +5,25 @@ Subject: [PATCH] implement optional per player mob spawns
|
|||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
index 3a79cde59..431534f4f 100644
|
||||
index 8de6c4816..e25544f11 100644
|
||||
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
|
||||
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
|
||||
public final Timing miscMobSpawning;
|
||||
public final Timing chunkRangeCheckBig;
|
||||
public final Timing chunkRangeCheckSmall;
|
||||
|
||||
+ public final Timing playerMobDistanceMapUpdate;
|
||||
+
|
||||
public WorldTimingsHandler(World server) {
|
||||
String name = server.worldData.getName() +" - ";
|
||||
|
||||
public final Timing poiUnload;
|
||||
public final Timing chunkUnload;
|
||||
@@ -0,0 +0,0 @@ public class WorldTimingsHandler {
|
||||
miscMobSpawning = Timings.ofSafe(name + "Mob spawning - Misc");
|
||||
chunkRangeCheckBig = Timings.ofSafe(name + "Chunk Tick Range - Big");
|
||||
chunkRangeCheckSmall = Timings.ofSafe(name + "Chunk Tick Range - Small");
|
||||
+
|
||||
+ playerMobDistanceMapUpdate = Timings.ofSafe(name + "Per Player Mob Spawning - Distance Map Update");
|
||||
}
|
||||
|
||||
public static Timing getTickList(WorldServer worldserver, String timingsType) {
|
||||
poiUnload = Timings.ofSafe(name + "Chunk unload - POI");
|
||||
chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk");
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index d0f5b2ab7..f63525d67 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
|
@ -547,7 +545,7 @@ index 000000000..4f13d3ff8
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index f138b112f..109c6ada8 100644
|
||||
index 1f6b1c4f1..cbe4b23e1 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkProviderServer extends IChunkProvider {
|
||||
|
@ -645,7 +643,7 @@ index d49ad0308..2fb04e3e9 100644
|
|||
return this.bb;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
index fc6436c4f..9915c2443 100644
|
||||
index 66bd402e9..041fedcfa 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
|
@ -660,7 +658,7 @@ index fc6436c4f..9915c2443 100644
|
|||
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
this.l = supplier;
|
||||
this.m = new VillagePlace(new File(this.w, "poi"), datafixer);
|
||||
this.m = new VillagePlace(new File(this.w, "poi"), datafixer, this.world); // Paper
|
||||
this.setViewDistance(i);
|
||||
+ this.playerMobDistanceMap = this.world.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
|
||||
+ }
|
||||
|
@ -757,7 +755,7 @@ index e168c528c..56dabbc15 100644
|
|||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 7b89b509a..fd42390d4 100644
|
||||
index a08308a12..4da5c8982 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -0,0 +0,0 @@ public class WorldServer extends World {
|
||||
|
|
Loading…
Add table
Reference in a new issue