mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 06:26:43 +01:00
Fixed null exception in the dynamic target goal
This commit is contained in:
parent
d03c0586cf
commit
855c2b2a49
1 changed files with 4 additions and 1 deletions
|
@ -21,7 +21,7 @@ public class DynamicTargetGoal extends Goal {
|
|||
|
||||
private int interval;
|
||||
|
||||
private Optional<Entity> target;
|
||||
private Optional<Entity> target = Optional.empty();
|
||||
|
||||
@Nullable
|
||||
private Predicate<Entity> test;
|
||||
|
@ -37,6 +37,9 @@ public class DynamicTargetGoal extends Goal {
|
|||
}
|
||||
|
||||
public Optional<Entity> getTarget() {
|
||||
if (test == null) {
|
||||
return target.filter(Entity::isAlive);
|
||||
}
|
||||
return target.filter(test).filter(Entity::isAlive);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue