- private static boolean isWithinSpawnSphere(int x, int y, int z, Point center) {
- int x1 = x+1;
- int z1 = z+1;
- int y1 = y+1;
- int closestX = Math.abs(center.getX()-x) < Math.abs(center.getX()-x1) ? x : x1;
- int closestY = Math.abs(center.getY()-y) < Math.abs(center.getY()-y1) ? y : y1;
- int closestZ = Math.abs(center.getZ()-z) < Math.abs(center.getZ()-z1) ? z : z1;
- double distance = center.getDistance(new Point(closestX, closestY, closestZ));
- return distance <= BoundingBoxSpawningSphere.SPAWN_RADIUS && distance >= (BoundingBoxSpawningSphere.SAFE_RADIUS-1);
- }
-
- private static boolean isWithinCircle(int x, int z, Point center) {
- int x1 = x+1;
- int z1 = z+1;
- int closestX = Math.abs(center.getX()-x) < Math.abs(center.getX()-x1) ? x : x1;
- int closestZ = Math.abs(center.getZ()-z) < Math.abs(center.getZ()-z1) ? z : z1;
- double distance = center.getDistance(new Point(closestX, center.getY(), closestZ));
- return distance <= BoundingBoxSpawningSphere.SPAWN_RADIUS;
- }
-
- private static boolean isBiomeHostileSpawnable(WorldClient world, BlockPos pos) {
- Biome biome = world.getBiome(pos);
- return biome.getSpawningChance() > 0 &&
- !biome.getSpawns(EnumCreatureType.MONSTER).isEmpty();
- }
-
- private static boolean isSpawnable(WorldClient world, BlockPos pos, IBlockState spawnBlockState, IBlockState upperBlockState) {
- Block spawnBlock = spawnBlockState.getBlock();
- return spawnBlock != Blocks.AIR &&
- spawnBlock != Blocks.BEDROCK &&
- spawnBlock != Blocks.BARRIER &&
- spawnBlockState.isTopSolid() &&
- !upperBlockState.isBlockNormalCube() &&
- !upperBlockState.canProvidePower() &&
- !upperBlockState.isIn(BlockTags.RAILS) &&
- upperBlockState.getCollisionShape(world, pos).getEnd(EnumFacing.Axis.Y) <= 0 &&
- upperBlockState.getFluidState().isEmpty() &&
- (world.dimension.isNether() || world.getLightFor(EnumLightType.BLOCK, pos) <= 7);