Use indirect collections in entitytracker
This commit is contained in:
parent
596a7b993b
commit
ecbd546280
@ -8,15 +8,26 @@
|
|||||||
|
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@
|
@@ -45,8 +46,8 @@
|
||||||
|
{
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
private final WorldServer theWorld;
|
private final WorldServer theWorld;
|
||||||
private Set trackedEntities = new HashSet();
|
- private Set trackedEntities = new HashSet();
|
||||||
- private IntHashMap trackedEntityIDs = new IntHashMap();
|
- private IntHashMap trackedEntityIDs = new IntHashMap();
|
||||||
|
+ private Set<EntityTrackerEntry> trackedEntities = new pw.prok.imagine.collections.IndirectSet<EntityTrackerEntry>();
|
||||||
+ public IntHashMap trackedEntityIDs = new IntHashMap(); // CraftBukkit - private -> public
|
+ public IntHashMap trackedEntityIDs = new IntHashMap(); // CraftBukkit - private -> public
|
||||||
private int entityViewDistance;
|
private int entityViewDistance;
|
||||||
private static final String __OBFID = "CL_00001431";
|
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 @@
|
@@ -184,6 +185,7 @@
|
||||||
|
|
||||||
public void addEntityToTracker(Entity p_72785_1_, int p_72785_2_, final int p_72785_3_, boolean p_72785_4_)
|
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)
|
if (p_72785_2_ > this.entityViewDistance)
|
||||||
{
|
{
|
||||||
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_);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user