2019-01-01 04:15:55 +01:00
|
|
|
From 39148659a11dc6f6d5ec7bb3fb4397c25b8e991a Mon Sep 17 00:00:00 2001
|
2018-07-31 06:27:45 +02:00
|
|
|
From: willies952002 <admin@domnian.com>
|
|
|
|
Date: Mon, 30 Jul 2018 02:42:49 -0400
|
|
|
|
Subject: [PATCH] World EntityHuman Lookup Optimizations
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2019-01-01 04:15:55 +01:00
|
|
|
index 2e6b00541..0d112016f 100644
|
2018-07-31 06:27:45 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -76,6 +76,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
private final List<TileEntity> c = Lists.newArrayList();
|
2018-08-26 20:11:49 +02:00
|
|
|
private final Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper
|
2018-07-31 06:27:45 +02:00
|
|
|
public final List<EntityHuman> players = Lists.newArrayList();
|
|
|
|
+ public final Map<String, EntityHuman> playersByName = Maps.newHashMap(); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
public final List<Entity> k = Lists.newArrayList();
|
2019-01-01 04:15:55 +01:00
|
|
|
protected final IntHashMap<Entity> entitiesById = new IntHashMap<>();
|
2018-08-26 20:11:49 +02:00
|
|
|
private final long F = 16777215L;
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -1025,6 +1026,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
EntityHuman entityhuman = (EntityHuman) entity;
|
|
|
|
|
|
|
|
this.players.add(entityhuman);
|
|
|
|
+ this.playersByName.put(entityhuman.getName(), entityhuman);
|
|
|
|
+ // Paper end
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -1067,6 +1070,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
// Spigot start
|
2018-12-17 06:18:06 +01:00
|
|
|
for ( WorldPersistentData worldData : worldMaps.worldMap.values() )
|
2018-07-31 06:27:45 +02:00
|
|
|
{
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -1100,6 +1104,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -2670,6 +2675,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public EntityHuman a(String s) {
|
|
|
|
+ // Paper start - World EntityHuman Lookup Optimizations
|
|
|
|
+ /*
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -2679,10 +2686,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
+ */
|
|
|
|
+ return this.playersByName.get(s);
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public EntityHuman b(UUID uuid) {
|
|
|
|
+ // Paper start - World EntityHuman Lookup Optimizations
|
|
|
|
+ /*
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
|
|
|
|
|
2019-01-01 04:15:55 +01:00
|
|
|
@@ -2692,6 +2704,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 06:27:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
+ */
|
|
|
|
+ Entity entity = ((WorldServer)this).entitiesByUUID.get(uuid);
|
|
|
|
+ return entity instanceof EntityHuman ? (EntityHuman) entity : null;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void checkSession() throws ExceptionWorldConflict {
|
|
|
|
--
|
2019-01-01 04:15:55 +01:00
|
|
|
2.20.1
|
2018-07-31 06:27:45 +02:00
|
|
|
|