mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-23 00:21:31 +01:00
Make wander goal more random
This commit is contained in:
parent
b546afa368
commit
ecae2dbe8a
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -72,6 +74,20 @@ public class WanderWaypointProvider
|
||||
}
|
||||
}
|
||||
if (closestCentre != null) {
|
||||
Location randomLocation = MinecraftBlockExaminer.findRandomValidLocation(npc.getEntity().getLocation(),
|
||||
xrange, yrange, new Function<Block, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(Block block) {
|
||||
if ((block.getRelative(BlockFace.UP).isLiquid() || block.getRelative(0, 2, 0).isLiquid())
|
||||
&& npc.getNavigator().getDefaultParameters().avoidWater()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, Util.getFastRandom());
|
||||
if (randomLocation != null) {
|
||||
return randomLocation;
|
||||
}
|
||||
// TODO: should find closest edge block that is valid
|
||||
return MinecraftBlockExaminer.findValidLocation(closestCentre, xrange, yrange);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user