From bb122e7f7e2f06e545f11197fde07ed4dfb19680 Mon Sep 17 00:00:00 2001 From: Pug <81167232+MerchantPug@users.noreply.github.com> Date: Tue, 2 Jan 2024 11:11:04 +1100 Subject: [PATCH] Fix crash with NearbyBobbersSensor. --- CHANGELOG.md | 3 ++- .../entity/sensor/NearbyBobbersSensor.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ddbc9d..56d0e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ ### Bugfixes -- Fixed crash when penguins decide to leave a boat. \ No newline at end of file +- Fixed crash when penguins decide to leave a boat. +- Fixed penguins noticing fishing bobbers whilst their boat is moving. \ No newline at end of file diff --git a/common/src/main/java/dev/greenhouseteam/rapscallionsandrockhoppers/entity/sensor/NearbyBobbersSensor.java b/common/src/main/java/dev/greenhouseteam/rapscallionsandrockhoppers/entity/sensor/NearbyBobbersSensor.java index 8359d1b..13cb2d3 100644 --- a/common/src/main/java/dev/greenhouseteam/rapscallionsandrockhoppers/entity/sensor/NearbyBobbersSensor.java +++ b/common/src/main/java/dev/greenhouseteam/rapscallionsandrockhoppers/entity/sensor/NearbyBobbersSensor.java @@ -20,8 +20,6 @@ import java.util.List; public class NearbyBobbersSensor extends PredicateSensor { - - private boolean hasSetUpPreviousBoatPos; private Vec3 previousBoatPos; @Nullable @@ -47,16 +45,17 @@ public NearbyBobbersSensor setRadius(double xz, double y) { @Override protected void doTick(ServerLevel level, Penguin penguin) { if (BrainUtils.hasMemory(penguin, RockhoppersMemoryModuleTypes.BOAT_TO_FOLLOW) && penguin.getBoatToFollow() != null) { - if (!this.hasSetUpPreviousBoatPos) { - previousBoatPos = penguin.getBoatToFollow().position(); - this.hasSetUpPreviousBoatPos = true; + if (this.previousBoatPos == null) { + this.previousBoatPos = penguin.getBoatToFollow().position(); } boolean bl = previousBoatPos.subtract(penguin.getBoatToFollow().position()).horizontalDistance() > 0.075; previousBoatPos = penguin.getBoatToFollow().position(); - if (bl) + if (bl) { BrainUtils.clearMemory(penguin, RockhoppersMemoryModuleTypes.NEAREST_BOBBERS); - } else if (this.hasSetUpPreviousBoatPos) { - this.hasSetUpPreviousBoatPos = false; + return; + } + } else if (this.previousBoatPos != null) { + this.previousBoatPos = null; } if (radius == null) {