blob: d35f1647179453e7910425015237664a71492d0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
package net.minecraft.server;
//import java.util.ArrayList; // CraftBukkit
import java.util.Iterator;
import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
public class PathfinderGoalSelector {
// CraftBukkit start - use UnsafeList
private UnsafeList a = new UnsafeList(16);
private UnsafeList b = new UnsafeList(16);
// CraftBukkit end
public PathfinderGoalSelector() {}
public void a(int i, PathfinderGoal pathfindergoal) {
this.a.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal));
}
public void a() {
//ArrayList arraylist = new ArrayList(); // CraftBukkit - removed usage
// CraftBukkit start - don't use iterators for private fields
for (int i = 0; i < this.a.size(); i++) {
PathfinderGoalSelectorItem pathfindergoalselectoritem = (PathfinderGoalSelectorItem) this.a.unsafeGet(i);
// CraftBukkit end
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()) {
// CraftBukkit start - call method now
// arraylist.add(pathfindergoalselectoritem);
pathfindergoalselectoritem.a.c();
// CraftBukkit end
this.b.add(pathfindergoalselectoritem);
}
}
boolean flag1 = false;
/* CraftBukkit start - removed usage of arraylist
if (flag1 && arraylist.size() > 0) {
System.out.println("Starting: ");
}
// CraftBukkit end */
Iterator iterator1;
PathfinderGoalSelectorItem pathfindergoalselectoritem1;
/* CraftBukkit start - removed usage of arraylist
for (iterator1 = arraylist.iterator(); iterator1.hasNext(); pathfindergoalselectoritem1.a.c()) {
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator1.next();
if (flag1) {
System.out.println(pathfindergoalselectoritem1.a.toString() + ", ");
}
}
// CraftBukkit end */
if (flag1 && this.b.size() > 0) {
System.out.println("Running: ");
}
// CraftBukkit start - don't use iterators for private fields
for (int i = 0; i < this.b.size(); i++) {
pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.b.unsafeGet(i); // CraftBukkit - use unsafeGet
pathfindergoalselectoritem1.a.e();
if (flag1) {
System.out.println(pathfindergoalselectoritem1.a.toString());
}
}
// CraftBukkit end
}
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) {
// CraftBukkit start - don't use iterators for private fields
for (int i = 0; i < this.a.size(); i++) {
PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) this.a.unsafeGet(i); // CraftBukkit - use unsafeGet
if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) {
if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) {
if (!this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1) && this.b.contains(pathfindergoalselectoritem1)) { // CraftBukkit - switch order
return false;
}
} else if (!pathfindergoalselectoritem1.a.g() && this.b.contains(pathfindergoalselectoritem1)) { // CraftBukkit - switch order
return false;
}
}
}
// CraftBukkit end
return true;
}
private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) {
return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0;
}
}
|