aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index 609041b..5f4e621 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,7 +11,7 @@ use image::ImageBuffer;
use log::debug;
use std::{collections::HashMap, fs::File, path::Path};
-const SEG_SIZE: isize = 64;
+const SEG_SIZE: isize = 128;
fn main() {
env_logger::builder()
@@ -27,21 +27,25 @@ fn main() {
for y in -64..256 {
for z in 0..SEG_SIZE {
let solid = |x: isize, y: isize, z: isize| {
- if x >= 0 && z >= 0 && x < SEG_SIZE && z < SEG_SIZE && y >= -64 && y < 256 {
- dim.block(x, y, z)
- .map(|b| {
- !matches!(
- b.name(),
- "minecraft:air" | "minecraft:water" | "minecraft:cave_air"
- )
- })
- .unwrap_or(false)
- } else {
- false
- }
+ dim.block(x, y, z)
+ .map(|b| {
+ !matches!(
+ b.name(),
+ "minecraft:air" | "minecraft:water" | "minecraft:cave_air"
+ )
+ })
+ .unwrap_or(false)
};
let visible =
|b: &Block| !matches!(b.name(), "minecraft:air" | "minecraft:cave_air");
+ let ray_visible = || {
+ for i in 1..100 {
+ if solid(x - i, y + i, z - i) {
+ return false;
+ }
+ }
+ true
+ };
if visible(&dim.block(x, y, z).unwrap())
&& !(solid(x + 1, y, z)
@@ -50,6 +54,7 @@ fn main() {
&& solid(x, y - 1, z)
&& solid(x, y, z + 1)
&& solid(x, y, z - 1))
+ && ray_visible()
{
visible_blocks.push((x, y, z))
}