Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ores generation in quarries #337

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions src/block_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ impl Block {
126 => "coarse_dirt",
127 => "iron_ore",
128 => "coal_ore",
129 => "gold_ore",
130 => "copper_ore",
131 => "clay",
_ => panic!("Invalid id"),
}
}
Expand Down Expand Up @@ -411,6 +414,9 @@ pub const RAIL_SOUTH_WEST: Block = Block::new(125);
pub const COARSE_DIRT: Block = Block::new(126);
pub const IRON_ORE: Block = Block::new(127);
pub const COAL_ORE: Block = Block::new(128);
pub const GOLD_ORE: Block = Block::new(129);
pub const COPPER_ORE: Block = Block::new(130);
pub const CLAY: Block = Block::new(131);

// Variations for building corners
pub fn building_corner_variations() -> Vec<Block> {
Expand Down
24 changes: 20 additions & 4 deletions src/element_processing/landuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ pub fn generate_landuse(
"military" => GRAY_CONCRETE,
"railway" => GRAVEL,
"landfill" => {
// Gravel if man_made = spoil_heap, coarse dirt else
let manmade = element.tags.get("man_made").unwrap_or(&binding);
if manmade == "spoil_heap" {
// Gravel if man_made = spoil_heap or heap, coarse dirt else
let manmade_tag = element.tags.get("man_made").unwrap_or(&binding);
if manmade_tag == "spoil_heap" || manmade_tag == "heap" {
GRAVEL
} else {
COARSE_DIRT
}
}
"quarry" => STONE, // TODO: add ores
"quarry" => STONE,
_ => {
if args.winter {
SNOW_BLOCK
Expand Down Expand Up @@ -349,6 +349,22 @@ pub fn generate_landuse(
}
}
}
"quarry" => {
if let Some(resource) = element.tags.get("resource") {
let ore_block = match resource.as_str() {
"iron_ore" => IRON_ORE,
"coal" => COAL_ORE,
"copper" => COPPER_ORE,
"gold" => GOLD_ORE,
"clay" | "kaolinite" => CLAY,
_ => STONE,
};
let random_choice: i32 = rng.gen_range(0..100 + ground_level); // with more depth there's more resources
if random_choice < 5 {
editor.set_block(ore_block, x, ground_level, z, Some(&[STONE]), None);
}
}
}
_ => {}
}
}
Expand Down
Loading