Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
ce270e1412
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: b2f1908c SPIGOT-5783: Add helpful info to UnknownDependencyException e4f46260 SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot. 529a9a69 SPIGOT-5751: Clarify behaviour of block drop-related API methods CraftBukkit Changes:8ea9b138
Remove outdated build delay.ffc2b251
Revert "#675: Fix redirected CommandNodes sometimes not being properly redirected"cb701f6b
#675: Fix redirected CommandNodes sometimes not being properly redirectedc9d7c16b
SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.fad2494a
#673: Fix Craftworld#isChunkLoaded8637ec00
SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given Spigot Changes: a99063f7 Rebuild patches Fixes #3602
86 Zeilen
3.7 KiB
Diff
86 Zeilen
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Sat, 25 Jan 2020 17:04:35 -0800
|
|
Subject: [PATCH] Optimise getChunkAt calls for loaded chunks
|
|
|
|
bypass the need to get a player chunk, then get the either,
|
|
then unwrap it...
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index 633f12098973857eca04acd2839bb4d453860f1e..e467cd8123dafc46a8c894f1ffa9440de0d45340 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -446,6 +446,12 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
return this.getChunkAt(i, j, chunkstatus, flag);
|
|
}, this.serverThreadQueue).join();
|
|
} else {
|
|
+ // Paper start - optimise for loaded chunks
|
|
+ Chunk ifLoaded = this.getChunkAtIfLoadedMainThread(i, j);
|
|
+ if (ifLoaded != null) {
|
|
+ return ifLoaded;
|
|
+ }
|
|
+ // Paper end
|
|
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
|
|
|
gameprofilerfiller.c("getChunk");
|
|
@@ -496,39 +502,7 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
if (Thread.currentThread() != this.serverThread) {
|
|
return null;
|
|
} else {
|
|
- this.world.getMethodProfiler().c("getChunkNow");
|
|
- long k = ChunkCoordIntPair.pair(i, j);
|
|
-
|
|
- for (int l = 0; l < 4; ++l) {
|
|
- if (k == this.cachePos[l] && this.cacheStatus[l] == ChunkStatus.FULL) {
|
|
- IChunkAccess ichunkaccess = this.cacheChunk[l];
|
|
-
|
|
- return ichunkaccess instanceof Chunk ? (Chunk) ichunkaccess : null;
|
|
- }
|
|
- }
|
|
-
|
|
- PlayerChunk playerchunk = this.getChunk(k);
|
|
-
|
|
- if (playerchunk == null) {
|
|
- return null;
|
|
- } else {
|
|
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
|
-
|
|
- if (either == null) {
|
|
- return null;
|
|
- } else {
|
|
- IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
|
|
-
|
|
- if (ichunkaccess1 != null) {
|
|
- this.a(k, ichunkaccess1, ChunkStatus.FULL);
|
|
- if (ichunkaccess1 instanceof Chunk) {
|
|
- return (Chunk) ichunkaccess1;
|
|
- }
|
|
- }
|
|
-
|
|
- return null;
|
|
- }
|
|
- }
|
|
+ return this.getChunkAtIfLoadedMainThread(i, j); // Paper - optimise for loaded chunks
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index d7ac4c86d170a8d7d816f86ac691c3b5129a20ba..adacff593ee20804b5ddb2df55b66bc6c162dc70 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -266,6 +266,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
|
|
@Override
|
|
public Chunk getChunkAt(int i, int j) {
|
|
+ // Paper start - optimise this for loaded chunks
|
|
+ if (Thread.currentThread() == this.serverThread) {
|
|
+ Chunk ifLoaded = ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedMainThread(i, j);
|
|
+ if (ifLoaded != null) {
|
|
+ return ifLoaded;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
return (Chunk) this.getChunkAt(i, j, ChunkStatus.FULL);
|
|
}
|
|
|