diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java index 6d620b2d..3f99af34 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomLayout.java @@ -317,7 +317,7 @@ public class RoomLayout { return this.findPath(oldTile, newTile, goalLocation, roomUnit, true); } - return new LinkedList<>(); + return null; } private RoomTile findTile(List tiles, short x, short y) { diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 47489f78..a876a4d4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -177,6 +177,9 @@ public class RoomUnit { } Deque peekPath = room.getLayout().findPath(this.currentLocation, this.path.peek(), this.goalLocation, this); + + if (peekPath == null) peekPath = new LinkedList<>(); + if (peekPath.size() >= 3) { if (path.isEmpty()) return true; @@ -543,10 +546,9 @@ public class RoomUnit { public void findPath() { - if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) - { - - this.path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.x, this.goalLocation.y) || this.canOverrideTile(this.goalLocation))) { + Deque path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this); + if (path != null) this.path = path; } }