2012-04-21 20:49:17 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
public class PathfinderGoalSelector {
|
|
|
|
|
|
|
|
private ArrayList a = new ArrayList();
|
|
|
|
private ArrayList b = new ArrayList();
|
2012-04-21 20:47:29 +02:00
|
|
|
private ArrayList arraylist = new ArrayList(); // CraftBukkit - create list for object reuse
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
public PathfinderGoalSelector() {}
|
|
|
|
|
|
|
|
public void a(int i, PathfinderGoal pathfindergoal) {
|
|
|
|
this.a.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a() {
|
2012-04-21 20:47:29 +02:00
|
|
|
//ArrayList arraylist = new ArrayList(); // CraftBukkit
|
|
|
|
arraylist.clear(); // CraftBukkit - prepare reused list
|
2012-04-21 20:49:17 +02:00
|
|
|
|
2012-04-21 20:47:29 +02:00
|
|
|
// CraftBukkit start - don't use iterators for private fields
|
|
|
|
for (int i = 0; i < this.a.size(); i++) {
|
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem = (PathfinderGoalSelectorItem) this.a.get(i);
|
2012-04-21 20:49:17 +02:00
|
|
|
boolean flag = this.b.contains(pathfindergoalselectoritem);
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
if (this.a(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.b()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pathfindergoalselectoritem.a.d();
|
|
|
|
this.b.remove(pathfindergoalselectoritem);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.a(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) {
|
|
|
|
arraylist.add(pathfindergoalselectoritem);
|
|
|
|
this.b.add(pathfindergoalselectoritem);
|
|
|
|
}
|
|
|
|
}
|
2012-04-21 20:47:29 +02:00
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
boolean flag1 = false;
|
|
|
|
|
|
|
|
if (flag1 && arraylist.size() > 0) {
|
|
|
|
System.out.println("Starting: ");
|
|
|
|
}
|
|
|
|
|
|
|
|
Iterator iterator1;
|
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem1;
|
|
|
|
|
2012-04-21 20:47:29 +02:00
|
|
|
//CraftBukkit start - don't use iterators for private fields
|
|
|
|
for (int i = 0; i < arraylist.size(); i++) {
|
|
|
|
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) arraylist.get(i);
|
|
|
|
pathfindergoalselectoritem1.a.c();
|
2012-04-21 20:49:17 +02:00
|
|
|
if (flag1) {
|
|
|
|
System.out.println(pathfindergoalselectoritem1.a.toString() + ", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag1 && this.b.size() > 0) {
|
|
|
|
System.out.println("Running: ");
|
|
|
|
}
|
|
|
|
|
2012-04-21 20:47:29 +02:00
|
|
|
for (int i = 0; i < this.b.size(); i++) {
|
|
|
|
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.b.get(i);
|
|
|
|
pathfindergoalselectoritem1.a.e();
|
2012-04-21 20:49:17 +02:00
|
|
|
if (flag1) {
|
|
|
|
System.out.println(pathfindergoalselectoritem1.a.toString());
|
|
|
|
}
|
|
|
|
}
|
2012-04-21 20:47:29 +02:00
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
|
2012-04-21 20:47:29 +02:00
|
|
|
// CraftBukkit start - don't use iterators for private fields
|
|
|
|
for (int i = 0; i < this.a.size(); i++) {
|
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.a.get(i);
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) {
|
|
|
|
if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) {
|
|
|
|
if (this.b.contains(pathfindergoalselectoritem1) && !this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else if (this.b.contains(pathfindergoalselectoritem1) && !pathfindergoalselectoritem1.a.g()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-04-21 20:47:29 +02:00
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) {
|
|
|
|
return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0;
|
|
|
|
}
|
|
|
|
}
|