mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
586ee2bb11
We were now starting entities at ID 2
48 lines
1.9 KiB
Diff
48 lines
1.9 KiB
Diff
From c2485e31048f64dd588fb07035d07857eee9a4f9 Mon Sep 17 00:00:00 2001
|
|
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
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
index d5c284cdd1..4157e50e4d 100644
|
|
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
@@ -219,6 +219,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);
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 3d5a0f0a03..9211f996c0 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -82,6 +82,15 @@ public class WorldServer extends World {
|
|
return new Throwable(entity + " Added to world at " + new java.util.Date());
|
|
}
|
|
|
|
+ // 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
|
|
+
|
|
// Paper start - Asynchronous IO
|
|
public final com.destroystokyo.paper.io.PaperFileIOThread.ChunkDataController poiDataController = new com.destroystokyo.paper.io.PaperFileIOThread.ChunkDataController() {
|
|
@Override
|
|
--
|
|
2.25.1
|
|
|