Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Calculates a random location (based on player location) in certain radius
- *
- * @param player - target
- * @param radius - certain radius
- * @return a random location
- */
- private Location getRandomLocationAroundPlayer(Player player, int radius) {
- ThreadLocalRandom random = ThreadLocalRandom.current();
- Location output = player.getLocation().clone();
- int randomX = (random.nextBoolean() ? 1 : -1) * random.nextInt(radius);
- int randomZ = (random.nextBoolean() ? 1 : -1) * random.nextInt(radius);
- return output.add(randomX, 0.0D, randomZ);
- }
- /**
- * Checks if a place around given location is clear for entity model
- *
- * @param location - certain location
- * @return true if place is clear of false
- */
- private boolean aroundIsClear(Location location) {
- BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH,
- BlockFace.WEST, BlockFace.UP };
- for (BlockFace blockFace : faces) {
- Block relative = location.getBlock().getRelative(blockFace);
- if (relative.getType() != Material.AIR)
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement