Skip to content

Commit

Permalink
Fix crash with NearbyBobbersSensor.
Browse files Browse the repository at this point in the history
  • Loading branch information
MerchantPug committed Jan 2, 2024
1 parent b2dabe2 commit bb122e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Bugfixes
- Fixed crash when penguins decide to leave a boat.
- Fixed crash when penguins decide to leave a boat.
- Fixed penguins noticing fishing bobbers whilst their boat is moving.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.util.List;

public class NearbyBobbersSensor extends PredicateSensor<FishingHook, Penguin> {

private boolean hasSetUpPreviousBoatPos;
private Vec3 previousBoatPos;

@Nullable
Expand All @@ -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) {
Expand Down

0 comments on commit bb122e7

Please sign in to comment.