2018-09-27 02:35:42 +00:00
|
|
|
From b4a0ee91b6438d5bd1f2d92aee64a4a6fded636c Mon Sep 17 00:00:00 2001
|
2018-07-31 04:27:45 +00: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
|
2018-09-18 01:50:02 +00:00
|
|
|
index b18ea7154f..aa94e399af 100644
|
2018-07-31 04:27:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-08-26 18:11:49 +00:00
|
|
|
@@ -81,6 +81,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00:00
|
|
|
private final List<TileEntity> c = Lists.newArrayList();
|
2018-08-26 18:11:49 +00:00
|
|
|
private final Set<TileEntity> tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); // Paper
|
2018-07-31 04:27:45 +00: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();
|
|
|
|
protected final IntHashMap<Entity> entitiesById = new IntHashMap();
|
2018-08-26 18:11:49 +00:00
|
|
|
private final long F = 16777215L;
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -1095,6 +1096,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00:00
|
|
|
EntityHuman entityhuman = (EntityHuman) entity;
|
|
|
|
|
|
|
|
this.players.add(entityhuman);
|
|
|
|
+ this.playersByName.put(entityhuman.getName(), entityhuman);
|
|
|
|
+ // Paper end
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -1137,6 +1140,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
// Spigot start
|
2018-08-26 18:11:49 +00:00
|
|
|
for ( WorldPersistentData worldData : worldMaps.a.values() )
|
2018-07-31 04:27:45 +00:00
|
|
|
{
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -1170,6 +1174,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00:00
|
|
|
entity.die();
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
this.players.remove(entity);
|
|
|
|
+ this.playersByName.remove(entity.getName()); // Paper - World EntityHuman Lookup Optimizations
|
|
|
|
this.everyoneSleeping();
|
|
|
|
}
|
|
|
|
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -2719,6 +2724,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00: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);
|
|
|
|
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -2728,10 +2735,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00: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);
|
|
|
|
|
2018-09-18 01:50:02 +00:00
|
|
|
@@ -2741,6 +2753,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
2018-07-31 04:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
+ */
|
|
|
|
+ Entity entity = ((WorldServer)this).entitiesByUUID.get(uuid);
|
|
|
|
+ return entity instanceof EntityHuman ? (EntityHuman) entity : null;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void checkSession() throws ExceptionWorldConflict {
|
|
|
|
--
|
2018-09-15 16:10:26 +00:00
|
|
|
2.19.0
|
2018-07-31 04:27:45 +00:00
|
|
|
|