From ecbd5462806b73ac56b96db73b8f80bb486a1046 Mon Sep 17 00:00:00 2001 From: Prototik Date: Mon, 8 Jun 2015 16:09:51 +0700 Subject: [PATCH] Use indirect collections in entitytracker --- .../minecraft/entity/EntityTracker.java.patch | 70 ++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/patches/net/minecraft/entity/EntityTracker.java.patch b/patches/net/minecraft/entity/EntityTracker.java.patch index 7381990..b3535bb 100644 --- a/patches/net/minecraft/entity/EntityTracker.java.patch +++ b/patches/net/minecraft/entity/EntityTracker.java.patch @@ -8,15 +8,26 @@ import cpw.mods.fml.common.registry.EntityRegistry; -@@ -46,7 +47,7 @@ +@@ -45,8 +46,8 @@ + { private static final Logger logger = LogManager.getLogger(); private final WorldServer theWorld; - private Set trackedEntities = new HashSet(); +- private Set trackedEntities = new HashSet(); - private IntHashMap trackedEntityIDs = new IntHashMap(); ++ private Set trackedEntities = new pw.prok.imagine.collections.IndirectSet(); + public IntHashMap trackedEntityIDs = new IntHashMap(); // CraftBukkit - private -> public private int entityViewDistance; private static final String __OBFID = "CL_00001431"; +@@ -73,7 +74,7 @@ + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + +- if (entitytrackerentry.myEntity != entityplayermp) ++ if (entitytrackerentry != null && entitytrackerentry.myEntity != entityplayermp) + { + entitytrackerentry.tryStartWachingThis(entityplayermp); + } @@ -184,6 +185,7 @@ public void addEntityToTracker(Entity p_72785_1_, int p_72785_2_, final int p_72785_3_, boolean p_72785_4_) @@ -25,3 +36,58 @@ if (p_72785_2_ > this.entityViewDistance) { p_72785_2_ = this.entityViewDistance; +@@ -246,6 +248,7 @@ + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); ++ if (entitytrackerentry != null) + entitytrackerentry.removeFromWatchingList(entityplayermp); + } + } +@@ -267,12 +270,14 @@ + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); ++ if (entitytrackerentry != null) { + entitytrackerentry.sendLocationToAllClients(this.theWorld.playerEntities); + + if (entitytrackerentry.playerEntitiesUpdated && entitytrackerentry.myEntity instanceof EntityPlayerMP) + { + arraylist.add((EntityPlayerMP)entitytrackerentry.myEntity); + } ++ } + } + + for (int i = 0; i < arraylist.size(); ++i) +@@ -284,12 +289,13 @@ + { + EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry)iterator1.next(); + +- if (entitytrackerentry1.myEntity != entityplayermp) ++ if (entitytrackerentry1 != null && entitytrackerentry1.myEntity != entityplayermp) + { + entitytrackerentry1.tryStartWachingThis(entityplayermp); + } + } + } ++ ((pw.prok.imagine.collections.Indirect) trackedEntities).compat(theWorld.getTotalWorldTime() % 100 == 0); + } + + public void func_151247_a(Entity p_151247_1_, Packet p_151247_2_) +@@ -319,6 +325,7 @@ + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); ++ if (entitytrackerentry != null) + entitytrackerentry.removePlayerFromTracker(p_72787_1_); + } + } +@@ -331,7 +338,7 @@ + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + +- if (entitytrackerentry.myEntity != p_85172_1_ && entitytrackerentry.myEntity.chunkCoordX == p_85172_2_.xPosition && entitytrackerentry.myEntity.chunkCoordZ == p_85172_2_.zPosition) ++ if (entitytrackerentry != null && entitytrackerentry.myEntity != p_85172_1_ && entitytrackerentry.myEntity.chunkCoordX == p_85172_2_.xPosition && entitytrackerentry.myEntity.chunkCoordZ == p_85172_2_.zPosition) + { + entitytrackerentry.tryStartWachingThis(p_85172_1_); + }