2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-01-12 06:36:31 +00:00
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
Date: Sat, 11 Jan 2020 21:50:56 -0800
|
|
|
|
Subject: [PATCH] Optimise IEntityAccess#getPlayerByUUID
|
|
|
|
|
|
|
|
Use the world entity map instead of iterating over all players
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-05-02 19:37:24 +00:00
|
|
|
index 71967bc86c2c2ad6bcafc80a5f8ab31c33f022e6..07b2f7f13044ace4db48274da8309c37aaa2d2c4 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -289,6 +289,15 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2020-01-12 06:36:31 +00:00
|
|
|
}
|
2020-06-25 23:38:24 +00:00
|
|
|
// Paper end
|
2020-01-12 06:36:31 +00:00
|
|
|
|
|
|
|
+ // Paper start - optimise getPlayerByUUID
|
|
|
|
+ @Nullable
|
|
|
|
+ @Override
|
|
|
|
+ public EntityHuman getPlayerByUUID(UUID uuid) {
|
|
|
|
+ Entity player = this.entitiesByUUID.get(uuid);
|
|
|
|
+ return (player instanceof EntityHuman) ? (EntityHuman)player : null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2020-06-25 23:38:24 +00:00
|
|
|
// Add env and gen to constructor, WorldData -> WorldDataServer
|
2020-08-25 02:22:08 +00:00
|
|
|
public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
|
|
|
|
super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env, executor); // Paper pass executor
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/IEntityAccess.java b/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
|
|
index 8fdc4b22e8c99d653bd213fe64339c133b46b4e9..1ff9e771788a4ab52129070e355ca48df2949470 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/IEntityAccess.java
|
|
|
|
@@ -277,6 +277,12 @@ public interface IEntityAccess {
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
default EntityHuman b(UUID uuid) {
|
|
|
|
+ // Paper start - allow WorldServer to override
|
|
|
|
+ return this.getPlayerByUUID(uuid);
|
|
|
|
+ }
|
|
|
|
+ @Nullable
|
|
|
|
+ default EntityHuman getPlayerByUUID(UUID uuid) {
|
|
|
|
+ // Paper end
|
|
|
|
for (int i = 0; i < this.getPlayers().size(); ++i) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.getPlayers().get(i);
|
|
|
|
|