Clean up goal check in GoalComposite

We're not going to check if the player has reached their goal literally hundreds of thousands of times consecutively so using a stream will not heavily impact performance.
This commit is contained in:
Brady 2018-08-02 00:31:55 -07:00
parent f0c45260c6
commit e0fe323039
No known key found for this signature in database
GPG Key ID: 73A788379A197567

View File

@ -26,18 +26,9 @@ public class GoalComposite implements Goal {
this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new)); this(blocks.stream().map(GoalBlock::new).toArray(Goal[]::new));
} }
public Goal[] goals() {
return goals;
}
@Override @Override
public boolean isInGoal(BlockPos pos) { public boolean isInGoal(BlockPos pos) {
for (Goal g : goals) { return Arrays.stream(this.goals).anyMatch(goal -> goal.isInGoal(pos));
if (g.isInGoal(pos)) {
return true;
}
}
return false;
} }
@Override @Override
@ -53,4 +44,8 @@ public class GoalComposite implements Goal {
public String toString() { public String toString() {
return "GoalComposite" + Arrays.toString(goals); return "GoalComposite" + Arrays.toString(goals);
} }
public Goal[] goals() {
return goals;
}
} }