Skip to content

Commit

Permalink
Avoid wandering into water if avoids water is set
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 8, 2020
1 parent d87a9e8 commit b63b399
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/citizensnpcs/api/ai/goals/WanderGoal.java
Expand Up @@ -4,6 +4,7 @@

import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -54,6 +55,10 @@ private Location findRandomPosition() {
int z = base.getBlockZ() + random.nextInt(2 * xrange) - xrange;
Block block = base.getWorld().getBlockAt(x, y, z);
if (MinecraftBlockExaminer.canStandOn(block)) {
if ((block.getRelative(BlockFace.UP).isLiquid() || block.getRelative(0, 2, 0).isLiquid())
&& npc.getNavigator().getDefaultParameters().avoidWater()) {
continue;
}
long[] pt = { x, y, z };
if (tree != null && tree.get() != null && !tree.get().queryIntersect(pt, pt).hasNext()) {
continue;
Expand Down

0 comments on commit b63b399

Please sign in to comment.