Target more sync loads (#2476)

This commit is contained in:
Spottedleaf 2019-09-01 15:17:51 -07:00 committed by Zach
parent 5272f3c2ef
commit b2758246c8
2 changed files with 42 additions and 8 deletions

View File

@ -1,4 +1,4 @@
From 3526d3feddbcac38820cbafe5036fb52a46c236a Mon Sep 17 00:00:00 2001
From 3c196746587129644488f1cddf9abdcc10438cb3 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Fri, 19 Jul 2019 03:29:14 -0700
Subject: [PATCH] Reduce sync loads
@ -280,9 +280,26 @@ index 69f3159ce..17f04fb81 100644
this.serverThreadQueue.awaitTasks(completablefuture::isDone);
com.destroystokyo.paper.io.chunk.ChunkTaskManager.popChunkWait(); // Paper - async chunk debug
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b81b37445..d3a0ed52b 100644
index b81b37445..9d29fc8ca 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1195,14 +1195,14 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
}
public boolean n(BlockPosition blockposition) {
- return isOutsideWorld(blockposition) ? false : this.chunkProvider.b(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ return isOutsideWorld(blockposition) ? false : this.isLoaded(blockposition); // Paper - reduce sync loads
}
public boolean a(BlockPosition blockposition, Entity entity) {
if (isOutsideWorld(blockposition)) {
return false;
} else {
- IChunkAccess ichunkaccess = this.getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4, ChunkStatus.FULL, false);
+ IChunkAccess ichunkaccess = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); // Paper - reduce sync loads
return ichunkaccess == null ? false : ichunkaccess.getType(blockposition).a((IBlockAccess) this, blockposition, entity);
}
@@ -1249,7 +1249,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
for (int i1 = i; i1 <= j; ++i1) {
@ -310,6 +327,23 @@ index b81b37445..d3a0ed52b 100644
if (chunk != null) {
chunk.a(oclass, axisalignedbb, list, predicate);
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 0c1f4e6e1..845575f52 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -150,6 +150,12 @@ public class WorldServer extends World {
};
public final com.destroystokyo.paper.io.chunk.ChunkTaskManager asyncChunkTaskManager;
// Paper end
+ // Paper start
+ @Override
+ public boolean isChunkLoaded(int x, int z) {
+ return this.getChunkProvider().getChunkAtIfCachedImmediately(x, z) != null;
+ }
+ // Paper end
// Add env and gen to constructor
public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
--
2.23.0
2.22.1

View File

@ -1,4 +1,4 @@
From 685da5100db38159cdf751d13fc229a9676e304b Mon Sep 17 00:00:00 2001
From 838de9697614e9960cc0adf901811992c98cb71f Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Mon, 19 Aug 2019 01:27:58 +0500
Subject: [PATCH] implement optional per player mob spawns
@ -757,10 +757,10 @@ index c6ea37ffb..9d4a96ae4 100644
@Nullable
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 0c1f4e6e1..4ffcb15af 100644
index 845575f52..ee3789b38 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -958,7 +958,20 @@ public class WorldServer extends World {
@@ -964,7 +964,20 @@ public class WorldServer extends World {
}
public Object2IntMap<EnumCreatureType> l() {
@ -782,7 +782,7 @@ index 0c1f4e6e1..4ffcb15af 100644
ObjectIterator objectiterator = this.entitiesById.values().iterator();
while (objectiterator.hasNext()) {
@@ -983,11 +996,16 @@ public class WorldServer extends World {
@@ -989,11 +1002,16 @@ public class WorldServer extends World {
continue;
}
// Paper end
@ -802,5 +802,5 @@ index 0c1f4e6e1..4ffcb15af 100644
@Override
--
2.23.0
2.22.1