3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-17 12:00:07 +01:00

Misc Improvements to Async Teleporting and Light patch

Stop light copy was missing a default in the impl.
Should of been extremely low chance of impacting anything though
as the very first copy operation would have fixed it.

Sadly this doesn't fix the issues weve been trying to fix.

Fix player async teleporting adding priority to wrong world for cross world teleports

Also improve teleporting to wait for entity ticking status before teleporting to prevent neighbors loading
Dieser Commit ist enthalten in:
Aikar 2020-07-09 19:24:10 -04:00
Ursprung 6133c83b6f
Commit 8c4787e306
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 401ADFC9891FAAFE
4 geänderte Dateien mit 56 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -3046,7 +3046,7 @@ index 3e1c1253ad5e2fa68fd8a0bac100c2e7536ea080..b6868b6b23a09e8e0dfe7a5e378dca22
completablefuture = (CompletableFuture) this.statusFutures.get(i);
if (completablefuture != null) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 24f3e8a6866bb416f04aca342514fa5dd3d314c8..a10006efc52f093196e7d67a3281a87d4c5df19b 100644
index 24f3e8a6866bb416f04aca342514fa5dd3d314c8..cacf60563826da0219754a67500fdc239b13f0cd 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -64,7 +64,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@ -3076,7 +3076,13 @@ index 24f3e8a6866bb416f04aca342514fa5dd3d314c8..a10006efc52f093196e7d67a3281a87d
this.setViewDistance(i);
}
@@ -204,7 +204,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -199,12 +199,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
@Nullable
- protected PlayerChunk getUpdatingChunk(long i) {
+ public PlayerChunk getUpdatingChunk(long i) { // Paper
return (PlayerChunk) this.updatingChunks.get(i);
}
@Nullable
@ -3998,7 +4004,7 @@ index 4529ccc02f53fadc6ac2df97682b21913487bc22..85b73e65a4c1af052e75473bc239d91d
}
public void removeTicketsForSpawn(int radiusInBlocks, BlockPosition spawn) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 412dc3865dfee606c37c06daefeacc6ed14ced7b..310c4446734a7ebfadf0cbd74d1cfcee20ef3668 100644
index 1970751f89dcba3055c31caa2c6425fa4b13bc28..45999be11cbbd08155ea882b98380178efe514fb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -74,6 +74,7 @@ import net.minecraft.server.GroupDataEntity;
@ -4076,6 +4082,39 @@ index 412dc3865dfee606c37c06daefeacc6ed14ced7b..310c4446734a7ebfadf0cbd74d1cfcee
// Spigot start
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 821417610fdb23791bd83e263977026b9d09e31a..a525a9e29f46c889a10d8c9fb70d8389fc204226 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -495,6 +495,28 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
entity.setHeadRotation(yaw);
}
+ @Override// Paper start
+ public java.util.concurrent.CompletableFuture<Boolean> teleportAsync(Location loc, @javax.annotation.Nonnull org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
+ net.minecraft.server.PlayerChunkMap playerChunkMap = ((CraftWorld) loc.getWorld()).getHandle().getChunkProvider().playerChunkMap;
+ java.util.concurrent.CompletableFuture<Boolean> future = new java.util.concurrent.CompletableFuture<>();
+
+ loc.getWorld().getChunkAtAsyncUrgently(loc).thenCompose(chunk -> {
+ net.minecraft.server.ChunkCoordIntPair pair = new net.minecraft.server.ChunkCoordIntPair(chunk.getX(), chunk.getZ());
+ ((CraftWorld) loc.getWorld()).getHandle().getChunkProvider().addTicketAtLevel(net.minecraft.server.TicketType.POST_TELEPORT, pair, 31, 0);
+ net.minecraft.server.PlayerChunk updatingChunk = playerChunkMap.getUpdatingChunk(pair.pair());
+ if (updatingChunk != null) {
+ return updatingChunk.getEntityTickingFuture();
+ } else {
+ return java.util.concurrent.CompletableFuture.completedFuture(com.mojang.datafixers.util.Either.left(((org.bukkit.craftbukkit.CraftChunk)chunk).getHandle()));
+ }
+ }).thenAccept((chunk) -> future.complete(teleport(loc, cause))).exceptionally(ex -> {
+ future.completeExceptionally(ex);
+ return null;
+ });
+ return future;
+ }
+ // Paper end
+
@Override
public boolean teleport(Location location) {
return teleport(location, TeleportCause.PLUGIN);
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index 07936eeba2a1aa68d52f4183f663ce362c816a54..5bdcdcf9e85b73086722783bff26321d03382bb9 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java

Datei anzeigen

@ -179,7 +179,7 @@ index 0f7f4744d9f9e5174fb38ccc72248397a4b064ea..292d8c742d3be41ba8ad7fb7f1251dc7
}
}
diff --git a/src/main/java/net/minecraft/server/LightEngineStorageSky.java b/src/main/java/net/minecraft/server/LightEngineStorageSky.java
index 75d9065b32731dc635d9d09c48fb9643172381a9..06bc8371fe9de4d23fdd47e5a3919541bb399fd8 100644
index 75d9065b32731dc635d9d09c48fb9643172381a9..7cec18fcfc311d20beca244c0affe5d6c1849e46 100644
--- a/src/main/java/net/minecraft/server/LightEngineStorageSky.java
+++ b/src/main/java/net/minecraft/server/LightEngineStorageSky.java
@@ -17,15 +17,16 @@ public class LightEngineStorageSky extends LightEngineStorage<LightEngineStorage
@ -288,21 +288,23 @@ index 75d9065b32731dc635d9d09c48fb9643172381a9..06bc8371fe9de4d23fdd47e5a3919541
return k == ((LightEngineStorageSky.a) this.f).b || SectionPosition.c(i) >= k;
}
@@ -321,18 +323,20 @@ public class LightEngineStorageSky extends LightEngineStorage<LightEngineStorage
@@ -321,18 +323,21 @@ public class LightEngineStorageSky extends LightEngineStorage<LightEngineStorage
public static final class a extends LightEngineStorageArray<LightEngineStorageSky.a> {
private int b;
- private final Long2IntOpenHashMap c;
+ private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
-
- public a(Long2ObjectOpenHashMap<NibbleArray> long2objectopenhashmap, Long2IntOpenHashMap long2intopenhashmap, int i) {
- super(long2objectopenhashmap);
- this.c = long2intopenhashmap;
- long2intopenhashmap.defaultReturnValue(i);
+ private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
+
+ // Paper start - avoid copying light data
+ public a(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<NibbleArray> data, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData, int i, boolean isVisible) {
+ super(data, isVisible);
+ this.otherData = otherData;
+ otherData.queueDefaultReturnValue(i);
+ // Paper end - avoid copying light data
this.b = i;
}

Datei anzeigen

@ -570,7 +570,7 @@ index a6363b73522f9d27534b6e80f4b3789e84316c49..604e7004b659daed2844ba1a76bf0928
boolean flag1 = this.playerChunkMap.b();
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 5f9ab1b81c1440d9b3003fbbf7d00b135a6b811e..eeed8edfdfde47b5eec7a2f6c9871fcfa1930b63 100644
index 6e0882e7e396f76b451e11c6cc6959e813de0a1f..8fd3c913ac5315a5c1cce002498bfe2ec08aaf42 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -55,6 +55,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@ -882,7 +882,7 @@ index e5751adde516544722b95016f64b2a46c16e77ce..04dea2c9fd9337631a6289c7242338e1
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 6dd64ce8794b8c2b5704556532159135e85a4b6c..ae42793b5a2f5bb06f068d0365378776901a4351 100644
index df315700fb28d682f406f8122e7cc187dbc13273..6a1ebb6daf2fdcb2bd276e36672fbec05d98adef 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -51,6 +51,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
@ -1208,7 +1208,7 @@ index d7b9d9fd3a3b607278a3d72b0b306b0be2aa30ad..6fd852db6bcfbfbf84ec2acf6d23b08a
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
return new TicketType<>(s, comparator, 0L);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 11559f9e4b3f5fda6bfe4f70f963ce4f7967f051..bf2f602bb07aa4c7c0a22ad9be9e77d7fd017191 100644
index b34269cd29fe15408e8811a8ab88b8d0fa43fcd3..4210aa793b497889ca732a51b2eadea08d88bfac 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2520,6 +2520,10 @@ public class CraftWorld implements World {
@ -1223,7 +1223,7 @@ index 11559f9e4b3f5fda6bfe4f70f963ce4f7967f051..bf2f602bb07aa4c7c0a22ad9be9e77d7
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) either.left().orElse(null);
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e3ae90aa7c2c067741540995fbb1c694b663f624..8f2b84a84a8249ae2b48d195eb8c1ffb4464fe0e 100644
index e3ae90aa7c2c067741540995fbb1c694b663f624..b832ece4948323e60fabecdeee5c9051b65c5e8e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -744,6 +744,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -1232,8 +1232,8 @@ index e3ae90aa7c2c067741540995fbb1c694b663f624..8f2b84a84a8249ae2b48d195eb8c1ffb
+ // Paper start
+ @Override
+ public java.util.concurrent.CompletableFuture<Boolean> teleportAsync(Location loc, PlayerTeleportEvent.TeleportCause cause) {
+ getHandle().getWorldServer().getChunkProvider().markAreaHighPriority(new net.minecraft.server.ChunkCoordIntPair(net.minecraft.server.MathHelper.floor(loc.getX()) >> 4, net.minecraft.server.MathHelper.floor(loc.getZ()) >> 4), 28, 3); // Paper - load area high priority
+ public java.util.concurrent.CompletableFuture<Boolean> teleportAsync(Location loc, @javax.annotation.Nonnull PlayerTeleportEvent.TeleportCause cause) {
+ ((CraftWorld)loc.getWorld()).getHandle().getChunkProvider().markAreaHighPriority(new net.minecraft.server.ChunkCoordIntPair(net.minecraft.server.MathHelper.floor(loc.getX()) >> 4, net.minecraft.server.MathHelper.floor(loc.getZ()) >> 4), 28, 3); // Paper - load area high priority
+ return super.teleportAsync(loc, cause);
+ }
+ // Paper end

Datei anzeigen

@ -40,10 +40,10 @@ index fcb3d3adae52fd70e856344a727a344cf78cfce3..9c4b02d776f8b99c6703c8dfc5d9fac0
return this.inLava;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 821417610fdb23791bd83e263977026b9d09e31a..8002a38bcc806a5d79531fe1a9c12b2c5ac6c37b 100644
index a525a9e29f46c889a10d8c9fb70d8389fc204226..d1df4e5799de4bf0a1fcc6940e2498374cd3db9d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1065,5 +1065,33 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -1087,5 +1087,33 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
return getHandle().spawnReason;
}