From 343f39b2b3750036f3749a16cf06ae39d65e87db Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Sat, 21 Apr 2012 13:49:17 -0500 Subject: [PATCH] Add PathfinderGoalSelector for diff visibility --- .../server/PathfinderGoalSelector.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/main/java/net/minecraft/server/PathfinderGoalSelector.java 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 0000000000..43dc1b9f20 --- /dev/null +++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java @@ -0,0 +1,91 @@ +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(); + + public PathfinderGoalSelector() {} + + public void a(int i, PathfinderGoal pathfindergoal) { + this.a.add(new PathfinderGoalSelectorItem(this, i, pathfindergoal)); + } + + public void a() { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.a.iterator(); + + while (iterator.hasNext()) { + PathfinderGoalSelectorItem pathfindergoalselectoritem = (PathfinderGoalSelectorItem) iterator.next(); + 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); + } + } + + boolean flag1 = false; + + if (flag1 && arraylist.size() > 0) { + System.out.println("Starting: "); + } + + Iterator iterator1; + PathfinderGoalSelectorItem pathfindergoalselectoritem1; + + for (iterator1 = arraylist.iterator(); iterator1.hasNext(); pathfindergoalselectoritem1.a.c()) { + pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator1.next(); + if (flag1) { + System.out.println(pathfindergoalselectoritem1.a.toString() + ", "); + } + } + + if (flag1 && this.b.size() > 0) { + System.out.println("Running: "); + } + + for (iterator1 = this.b.iterator(); iterator1.hasNext(); pathfindergoalselectoritem1.a.e()) { + pathfindergoalselectoritem1 = (PathfinderGoalSelectorItem) iterator1.next(); + if (flag1) { + System.out.println(pathfindergoalselectoritem1.a.toString()); + } + } + } + + private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem) { + 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)) { + return false; + } + } else if (this.b.contains(pathfindergoalselectoritem1) && !pathfindergoalselectoritem1.a.g()) { + return false; + } + } + } + + return true; + } + + private boolean a(PathfinderGoalSelectorItem pathfindergoalselectoritem, PathfinderGoalSelectorItem pathfindergoalselectoritem1) { + return (pathfindergoalselectoritem.a.h() & pathfindergoalselectoritem1.a.h()) == 0; + } +}