Paper/Spigot-Server-Patches/0317-World-EntityHuman-Lookup-Optimizations.patch
Aikar b62dfa0bf9
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
39ce5d3a SPIGOT-4399: ItemMeta.equals broken with AttributeModifiers

CraftBukkit Changes:
1cf8b5dc SPIGOT-4400: Populators running on existing chunks
116cb9a1 SPIGOT-4399: Add attribute modifier equality test
5ee1c18a SPIGOT-4398: Set ASM7_EXPERIMENTAL flag
2018-09-28 19:31:59 -04:00

83 lines
3.5 KiB
Diff

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