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

View File

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