2012-04-21 20:49:17 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
2012-04-23 16:47:05 +02:00
|
|
|
import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
public class PathfinderGoalSelector {
|
|
|
|
|
2012-04-25 05:18:27 +02:00
|
|
|
// CraftBukkit start - use UnsafeList
|
2012-04-23 16:47:05 +02:00
|
|
|
private UnsafeList a = new UnsafeList(16);
|
|
|
|
private UnsafeList b = new UnsafeList(16);
|
|
|
|
// CraftBukkit end
|
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-23 16:47:05 +02:00
|
|
|
//ArrayList arraylist = new ArrayList(); // CraftBukkit - removed usage
|
2012-04-21 20:49:17 +02:00
|
|
|
|
2012-04-25 05:18:27 +02:00
|
|
|
// CraftBukkit start - don't use iterators for private fields
|
2012-04-21 20:47:29 +02:00
|
|
|
for (int i = 0; i < this.a.size(); i++) {
|
2012-04-23 16:47:05 +02:00
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem = (PathfinderGoalSelectorItem) this.a.unsafeGet(i); // CraftBukkit - use unsafeGet
|
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()) {
|
2012-04-23 16:47:05 +02:00
|
|
|
// CraftBukkit start - call method now
|
|
|
|
// arraylist.add(pathfindergoalselectoritem);
|
|
|
|
pathfindergoalselectoritem.a.c();
|
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
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;
|
|
|
|
|
2012-04-23 16:47:05 +02:00
|
|
|
// CraftBukkit start - removed usage of arraylist
|
|
|
|
/*if (flag1 && arraylist.size() > 0) {
|
2012-04-21 20:49:17 +02:00
|
|
|
System.out.println("Starting: ");
|
2012-04-23 16:47:05 +02:00
|
|
|
}*/
|
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
Iterator iterator1;
|
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem1;
|
|
|
|
|
2012-04-23 16:47:05 +02:00
|
|
|
// CraftBukkit start - removed usage of arraylist
|
|
|
|
/*for (iterator1 = arraylist.iterator(); iterator1.hasNext(); pathfindergoalselectoritem1.a.c()) {
|
|
|
|
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator1.next();
|
2012-04-21 20:49:17 +02:00
|
|
|
if (flag1) {
|
|
|
|
System.out.println(pathfindergoalselectoritem1.a.toString() + ", ");
|
|
|
|
}
|
2012-04-23 16:47:05 +02:00
|
|
|
}*/
|
|
|
|
// CraftBukkit end
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
if (flag1 && this.b.size() > 0) {
|
|
|
|
System.out.println("Running: ");
|
|
|
|
}
|
|
|
|
|
2012-04-23 16:47:05 +02:00
|
|
|
// CraftBukkit start - don't use iterators for private fields
|
2012-04-21 20:47:29 +02:00
|
|
|
for (int i = 0; i < this.b.size(); i++) {
|
2012-04-23 16:47:05 +02:00
|
|
|
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.b.unsafeGet(i); // CraftBukkit - use unsafeGet
|
2012-04-21 20:47:29 +02:00
|
|
|
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++) {
|
2012-04-23 16:47:05 +02:00
|
|
|
PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.a.unsafeGet(i); // CraftBukkit - use unsafeGet
|
2012-04-21 20:49:17 +02:00
|
|
|
|
|
|
|
if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) {
|
|
|
|
if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) {
|
2012-04-23 16:47:05 +02:00
|
|
|
if (!this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1) && this.b.contains(pathfindergoalselectoritem1)) { // CraftBukkit - switch order
|
2012-04-21 20:49:17 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-04-23 16:47:05 +02:00
|
|
|
} else if (!pathfindergoalselectoritem1.a.g() && this.b.contains(pathfindergoalselectoritem1)) { // CraftBukkit - switch order
|
2012-04-21 20:49:17 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|