From 855c2b2a49f9b090dd6aa8db3e2c0e09d351c108 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 30 Dec 2021 00:59:31 +0200 Subject: [PATCH] Fixed null exception in the dynamic target goal --- .../minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java index edc1d3a7..f4c4dc0e 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java @@ -21,7 +21,7 @@ public class DynamicTargetGoal extends Goal { private int interval; - private Optional target; + private Optional target = Optional.empty(); @Nullable private Predicate test; @@ -37,6 +37,9 @@ public class DynamicTargetGoal extends Goal { } public Optional getTarget() { + if (test == null) { + return target.filter(Entity::isAlive); + } return target.filter(test).filter(Entity::isAlive); }