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:
parent
f0c45260c6
commit
e0fe323039
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user