Avoid unnecessary iteration

This commit is contained in:
bm01 2012-06-15 02:46:41 +02:00
parent 68bf93d1ac
commit 032472dcb3
2 changed files with 4 additions and 16 deletions

View File

@ -24,16 +24,6 @@ public class Archery {
public static final int DAZE_MAX_BONUS_LEVEL = 1000; public static final int DAZE_MAX_BONUS_LEVEL = 1000;
public static final int DAZE_MODIFIER = 4; public static final int DAZE_MODIFIER = 4;
protected static boolean arrowTrackerContains(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity() == livingEntity) {
return true;
}
}
return false;
}
protected static void incrementTrackerValue(LivingEntity livingEntity) { protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) { for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity() == livingEntity) { if (trackedEntity.getLivingEntity() == livingEntity) {
@ -41,6 +31,9 @@ public class Archery {
return; return;
} }
} }
//If the entity isn't tracked yet
addToTracker(livingEntity);
} }
protected static void addToTracker(LivingEntity livingEntity) { protected static void addToTracker(LivingEntity livingEntity) {

View File

@ -22,11 +22,6 @@ public class ArrowTrackingEventHandler {
} }
protected void addToTracker() { protected void addToTracker() {
if (Archery.arrowTrackerContains(entity)) { Archery.incrementTrackerValue(entity);
Archery.incrementTrackerValue(entity);
}
else {
Archery.addToTracker(entity);
}
} }
} }