diff options
author | Mike Primm <mike@primmhome.com> | 2012-08-10 00:21:24 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-08-19 09:19:28 -0500 |
commit | 852602e430f94a1ce627afd8de1599f2e804d788 (patch) | |
tree | 9f8884bd136be29175612c3bf3e4be8903c7ed6c /src/main/java/net/minecraft/server/PathfinderGoalSelector.java | |
parent | b44fc8ed28a75db889a96ea26bafd299a10b4e8f (diff) | |
download | craftbukkit-852602e430f94a1ce627afd8de1599f2e804d788.tar craftbukkit-852602e430f94a1ce627afd8de1599f2e804d788.tar.gz craftbukkit-852602e430f94a1ce627afd8de1599f2e804d788.tar.lz craftbukkit-852602e430f94a1ce627afd8de1599f2e804d788.tar.xz craftbukkit-852602e430f94a1ce627afd8de1599f2e804d788.zip |
Add files from mc-dev for diff visibility
Diffstat (limited to 'src/main/java/net/minecraft/server/PathfinderGoalSelector.java')
-rw-r--r-- | src/main/java/net/minecraft/server/PathfinderGoalSelector.java | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java new file mode 100644 index 00000000..dc16a625 --- /dev/null +++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java @@ -0,0 +1,120 @@ +package net.minecraft.server; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class PathfinderGoalSelector { + + private List a = new ArrayList(); + private List b = new ArrayList(); + private final MethodProfiler c; + private int d = 0; + private int e = 3; + + public PathfinderGoalSelector(MethodProfiler methodprofiler) { + this.c = methodprofiler; + } + + public void a(int i, PathfinderGoal pathfindergoal) { + this.a.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal)); + } + + public void a() { + ArrayList arraylist = new ArrayList(); + Iterator iterator; + PathfinderGoalSelectorItem pathfindergoalselectoritem; + + if (this.d++ % this.e == 0) { + iterator = this.a.iterator(); + + while (iterator.hasNext()) { + pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); + boolean flag = this.b.contains(pathfindergoalselectoritem); + + if (flag) { + if (this.b(pathfindergoalselectoritem) && this.a(pathfindergoalselectoritem)) { + continue; + } + + pathfindergoalselectoritem.a.c(); + this.b.remove(pathfindergoalselectoritem); + } + + if (this.b(pathfindergoalselectoritem) && pathfindergoalselectoritem.a.a()) { + arraylist.add(pathfindergoalselectoritem); + this.b.add(pathfindergoalselectoritem); + } + } + } else { + iterator = this.b.iterator(); + + while (iterator.hasNext()) { + pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); + if (!pathfindergoalselectoritem.a.b()) { + pathfindergoalselectoritem.a.c(); + iterator.remove(); + } + } + } + + this.c.a("goalStart"); + iterator = arraylist.iterator(); + + while (iterator.hasNext()) { + pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); + this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); + pathfindergoalselectoritem.a.e(); + this.c.b(); + } + + this.c.b(); + this.c.a("goalTick"); + iterator = this.b.iterator(); + + while (iterator.hasNext()) { + pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); + this.c.a(pathfindergoalselectoritem.a.getClass().getSimpleName()); + pathfindergoalselectoritem.a.d(); + this.c.b(); + } + + this.c.b(); + } + + private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) { + this.c.a("canContinue"); + boolean flag = pathfindergoalselectoritem.a.b(); + + this.c.b(); + return flag; + } + + private boolean b(PathfinderGoalSelectorItem pathfindergoalselectoritem) { + this.c.a("canUse"); + Iterator iterator = this.a.iterator(); + + while (iterator.hasNext()) { + PathfinderGoalSelectorItem pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator.next(); + + if (pathfindergoalselectoritem1 != pathfindergoalselectoritem) { + if (pathfindergoalselectoritem.b >= pathfindergoalselectoritem1.b) { + if (this.b.contains(pathfindergoalselectoritem1) && !this.a(pathfindergoalselectoritem, pathfindergoalselectoritem1)) { + this.c.b(); + return false; + } + } else if (this.b.contains(pathfindergoalselectoritem1) && !pathfindergoalselectoritem1.a.g()) { + this.c.b(); + return false; + } + } + } + + this.c.b(); + return true; + } + + private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) { + return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0; + } +} |