From a04b23f633bad35c8246231e8b64192fa8b63a35 Mon Sep 17 00:00:00 2001 From: Alvsch <94403567+Alvsch@users.noreply.github.com> Date: Sat, 7 Dec 2024 13:10:37 +0100 Subject: [PATCH] Added compile time BlockState (#347) * added block_state! macro * Update block_state! macro --- pumpkin-macros/src/block_state.rs | 93 +++ pumpkin-macros/src/lib.rs | 6 + pumpkin-world/src/lib.rs | 4 +- .../src/world_gen/aquifer_sampler.rs | 636 +++++++++--------- pumpkin-world/src/world_gen/chunk_noise.rs | 14 +- .../implementation/overworld/biome/mod.rs | 6 +- .../implementation/overworld/biome/plains.rs | 41 +- .../src/world_gen/implementation/superflat.rs | 6 +- pumpkin-world/src/world_gen/noise/router.rs | 4 +- pumpkin-world/src/world_gen/ore_sampler.rs | 36 +- pumpkin-world/src/world_gen/proto_chunk.rs | 6 +- 11 files changed, 465 insertions(+), 387 deletions(-) create mode 100644 pumpkin-macros/src/block_state.rs diff --git a/pumpkin-macros/src/block_state.rs b/pumpkin-macros/src/block_state.rs new file mode 100644 index 000000000..18b9eff3e --- /dev/null +++ b/pumpkin-macros/src/block_state.rs @@ -0,0 +1,93 @@ +use std::{collections::HashMap, sync::LazyLock}; + +use quote::quote; +use serde::Deserialize; + +static BLOCKS: LazyLock = LazyLock::new(|| { + serde_json::from_str(include_str!("../../assets/blocks.json")) + .expect("Could not parse blocks.json registry.") +}); + +static STATE_BY_REGISTRY_ID: LazyLock> = LazyLock::new(|| { + let mut map = HashMap::new(); + for block in &BLOCKS.blocks { + map.insert(block.name.clone(), block.clone()); + } + map +}); + +pub(crate) fn block_state_impl(item: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input_string = item.to_string(); + let registry_id = input_string.trim_matches('"'); + + let state = STATE_BY_REGISTRY_ID + .get(registry_id) + .expect("Invalid registry id"); + + let default_state_id = state.default_state_id; + let block_id = state.id; + + if std::env::var("CARGO_PKG_NAME").unwrap() == "pumpkin-world" { + quote! { + crate::block::BlockState { + state_id: #default_state_id, + block_id: #block_id, + } + } + .into() + } else { + quote! { + pumpkin_world::block::BlockState { + state_id: #default_state_id, + block_id: #block_id, + } + } + .into() + } +} + +#[expect(dead_code)] +#[derive(Deserialize, Clone, Debug)] +struct TopLevel { + block_entity_types: Vec, + shapes: Vec, + pub blocks: Vec, +} + +#[expect(dead_code)] +#[derive(Deserialize, Clone, Debug)] +struct Block { + pub id: u16, + pub item_id: u16, + pub hardness: f32, + pub wall_variant_id: Option, + pub translation_key: String, + pub name: String, + pub properties: Vec, + pub default_state_id: u16, + pub states: Vec, +} +#[expect(dead_code)] +#[derive(Deserialize, Clone, Debug)] +pub struct Property { + name: String, + values: Vec, +} +#[expect(dead_code)] +#[derive(Deserialize, Clone, Debug)] +pub struct State { + pub id: u16, + pub air: bool, + pub luminance: u8, + pub burnable: bool, + pub opacity: Option, + pub replaceable: bool, + pub collision_shapes: Vec, + pub block_entity_type: Option, +} +#[expect(dead_code)] +#[derive(Deserialize, Clone, Debug)] +struct Shape { + min: [f32; 3], + max: [f32; 3], +} diff --git a/pumpkin-macros/src/lib.rs b/pumpkin-macros/src/lib.rs index 43546eddf..75f5167ff 100644 --- a/pumpkin-macros/src/lib.rs +++ b/pumpkin-macros/src/lib.rs @@ -84,3 +84,9 @@ mod particle; pub fn particle(item: TokenStream) -> TokenStream { particle::particle_impl(item) } + +mod block_state; +#[proc_macro] +pub fn block_state(item: TokenStream) -> TokenStream { + block_state::block_state_impl(item) +} diff --git a/pumpkin-world/src/lib.rs b/pumpkin-world/src/lib.rs index bc3e9dee1..d1d6284c6 100644 --- a/pumpkin-world/src/lib.rs +++ b/pumpkin-world/src/lib.rs @@ -46,8 +46,8 @@ pub fn bench_create_chunk_noise_overworld() { let config = NoiseConfig::new(0, &OVERWORLD_NOISE_ROUTER); let generation_shape = GenerationShape::SURFACE; let sampler = FluidLevelSampler::Chunk(StandardChunkFluidLevelSampler::new( - FluidLevel::new(63, *WATER_BLOCK), - FluidLevel::new(-54, *LAVA_BLOCK), + FluidLevel::new(63, WATER_BLOCK), + FluidLevel::new(-54, LAVA_BLOCK), )); ChunkNoiseGenerator::new( diff --git a/pumpkin-world/src/world_gen/aquifer_sampler.rs b/pumpkin-world/src/world_gen/aquifer_sampler.rs index 83f210085..ebe4d6ac9 100644 --- a/pumpkin-world/src/world_gen/aquifer_sampler.rs +++ b/pumpkin-world/src/world_gen/aquifer_sampler.rs @@ -430,7 +430,7 @@ impl WorldAquiferSampler { .sample_mut(&NoisePos::Unblended(UnblendedNoisePos::new(x, y, z)), env); if sample.abs() > 0.3f64 { - return *LAVA_BLOCK; + return LAVA_BLOCK; } } @@ -477,7 +477,7 @@ impl WorldAquiferSampler { let fluid_level = self.fluid_level.get_fluid_level(i, j, k); if fluid_level.get_block_state(j).of_block(LAVA_BLOCK.block_id) { - Some(*LAVA_BLOCK) + Some(LAVA_BLOCK) } else { let scaled_x = floor_div(i - 5, 16); let scaled_y = floor_div(j + 1, 12); @@ -688,8 +688,8 @@ mod test { let chunk_pos = Vector2::new(7, 4); let config = NoiseConfig::new(0, &OVERWORLD_NOISE_ROUTER); let sampler = FluidLevelSampler::Chunk(StandardChunkFluidLevelSampler::new( - FluidLevel::new(63, *WATER_BLOCK), - FluidLevel::new(-54, *LAVA_BLOCK), + FluidLevel::new(63, WATER_BLOCK), + FluidLevel::new(-54, LAVA_BLOCK), )); let noise = ChunkNoiseGenerator::new( 16 / shape.horizontal_cell_block_count(), @@ -721,134 +721,134 @@ mod test { #[test] fn test_get_fluid_block_state() { let (mut aquifer, _, env) = create_aquifer(); - let level = FluidLevel::new(0, *WATER_BLOCK); + let level = FluidLevel::new(0, WATER_BLOCK); let values = [ - ((-100, -100, -100), *WATER_BLOCK), - ((-100, -100, -50), *LAVA_BLOCK), - ((-100, -100, 0), *WATER_BLOCK), - ((-100, -100, 50), *WATER_BLOCK), - ((-100, -100, 100), *WATER_BLOCK), - ((-100, -50, -100), *WATER_BLOCK), - ((-100, -50, -50), *LAVA_BLOCK), - ((-100, -50, 0), *LAVA_BLOCK), - ((-100, -50, 50), *LAVA_BLOCK), - ((-100, -50, 100), *WATER_BLOCK), - ((-100, 0, -100), *WATER_BLOCK), - ((-100, 0, -50), *WATER_BLOCK), - ((-100, 0, 0), *WATER_BLOCK), - ((-100, 0, 50), *WATER_BLOCK), - ((-100, 0, 100), *WATER_BLOCK), - ((-100, 50, -100), *WATER_BLOCK), - ((-100, 50, -50), *WATER_BLOCK), - ((-100, 50, 0), *WATER_BLOCK), - ((-100, 50, 50), *WATER_BLOCK), - ((-100, 50, 100), *WATER_BLOCK), - ((-100, 100, -100), *WATER_BLOCK), - ((-100, 100, -50), *WATER_BLOCK), - ((-100, 100, 0), *WATER_BLOCK), - ((-100, 100, 50), *WATER_BLOCK), - ((-100, 100, 100), *WATER_BLOCK), - ((-50, -100, -100), *WATER_BLOCK), - ((-50, -100, -50), *WATER_BLOCK), - ((-50, -100, 0), *LAVA_BLOCK), - ((-50, -100, 50), *LAVA_BLOCK), - ((-50, -100, 100), *WATER_BLOCK), - ((-50, -50, -100), *WATER_BLOCK), - ((-50, -50, -50), *WATER_BLOCK), - ((-50, -50, 0), *WATER_BLOCK), - ((-50, -50, 50), *WATER_BLOCK), - ((-50, -50, 100), *WATER_BLOCK), - ((-50, 0, -100), *LAVA_BLOCK), - ((-50, 0, -50), *WATER_BLOCK), - ((-50, 0, 0), *WATER_BLOCK), - ((-50, 0, 50), *WATER_BLOCK), - ((-50, 0, 100), *WATER_BLOCK), - ((-50, 50, -100), *WATER_BLOCK), - ((-50, 50, -50), *WATER_BLOCK), - ((-50, 50, 0), *LAVA_BLOCK), - ((-50, 50, 50), *LAVA_BLOCK), - ((-50, 50, 100), *WATER_BLOCK), - ((-50, 100, -100), *WATER_BLOCK), - ((-50, 100, -50), *WATER_BLOCK), - ((-50, 100, 0), *LAVA_BLOCK), - ((-50, 100, 50), *LAVA_BLOCK), - ((-50, 100, 100), *LAVA_BLOCK), - ((0, -100, -100), *WATER_BLOCK), - ((0, -100, -50), *LAVA_BLOCK), - ((0, -100, 0), *LAVA_BLOCK), - ((0, -100, 50), *LAVA_BLOCK), - ((0, -100, 100), *WATER_BLOCK), - ((0, -50, -100), *WATER_BLOCK), - ((0, -50, -50), *WATER_BLOCK), - ((0, -50, 0), *WATER_BLOCK), - ((0, -50, 50), *WATER_BLOCK), - ((0, -50, 100), *WATER_BLOCK), - ((0, 0, -100), *LAVA_BLOCK), - ((0, 0, -50), *LAVA_BLOCK), - ((0, 0, 0), *WATER_BLOCK), - ((0, 0, 50), *WATER_BLOCK), - ((0, 0, 100), *WATER_BLOCK), - ((0, 50, -100), *WATER_BLOCK), - ((0, 50, -50), *WATER_BLOCK), - ((0, 50, 0), *WATER_BLOCK), - ((0, 50, 50), *WATER_BLOCK), - ((0, 50, 100), *WATER_BLOCK), - ((0, 100, -100), *WATER_BLOCK), - ((0, 100, -50), *LAVA_BLOCK), - ((0, 100, 0), *WATER_BLOCK), - ((0, 100, 50), *WATER_BLOCK), - ((0, 100, 100), *WATER_BLOCK), - ((50, -100, -100), *WATER_BLOCK), - ((50, -100, -50), *LAVA_BLOCK), - ((50, -100, 0), *LAVA_BLOCK), - ((50, -100, 50), *LAVA_BLOCK), - ((50, -100, 100), *WATER_BLOCK), - ((50, -50, -100), *WATER_BLOCK), - ((50, -50, -50), *WATER_BLOCK), - ((50, -50, 0), *WATER_BLOCK), - ((50, -50, 50), *WATER_BLOCK), - ((50, -50, 100), *WATER_BLOCK), - ((50, 0, -100), *LAVA_BLOCK), - ((50, 0, -50), *LAVA_BLOCK), - ((50, 0, 0), *WATER_BLOCK), - ((50, 0, 50), *WATER_BLOCK), - ((50, 0, 100), *WATER_BLOCK), - ((50, 50, -100), *WATER_BLOCK), - ((50, 50, -50), *WATER_BLOCK), - ((50, 50, 0), *WATER_BLOCK), - ((50, 50, 50), *WATER_BLOCK), - ((50, 50, 100), *WATER_BLOCK), - ((50, 100, -100), *WATER_BLOCK), - ((50, 100, -50), *LAVA_BLOCK), - ((50, 100, 0), *WATER_BLOCK), - ((50, 100, 50), *WATER_BLOCK), - ((50, 100, 100), *WATER_BLOCK), - ((100, -100, -100), *WATER_BLOCK), - ((100, -100, -50), *LAVA_BLOCK), - ((100, -100, 0), *WATER_BLOCK), - ((100, -100, 50), *WATER_BLOCK), - ((100, -100, 100), *WATER_BLOCK), - ((100, -50, -100), *LAVA_BLOCK), - ((100, -50, -50), *LAVA_BLOCK), - ((100, -50, 0), *LAVA_BLOCK), - ((100, -50, 50), *LAVA_BLOCK), - ((100, -50, 100), *LAVA_BLOCK), - ((100, 0, -100), *WATER_BLOCK), - ((100, 0, -50), *LAVA_BLOCK), - ((100, 0, 0), *WATER_BLOCK), - ((100, 0, 50), *WATER_BLOCK), - ((100, 0, 100), *LAVA_BLOCK), - ((100, 50, -100), *WATER_BLOCK), - ((100, 50, -50), *WATER_BLOCK), - ((100, 50, 0), *WATER_BLOCK), - ((100, 50, 50), *WATER_BLOCK), - ((100, 50, 100), *WATER_BLOCK), - ((100, 100, -100), *LAVA_BLOCK), - ((100, 100, -50), *LAVA_BLOCK), - ((100, 100, 0), *WATER_BLOCK), - ((100, 100, 50), *WATER_BLOCK), - ((100, 100, 100), *WATER_BLOCK), + ((-100, -100, -100), WATER_BLOCK), + ((-100, -100, -50), LAVA_BLOCK), + ((-100, -100, 0), WATER_BLOCK), + ((-100, -100, 50), WATER_BLOCK), + ((-100, -100, 100), WATER_BLOCK), + ((-100, -50, -100), WATER_BLOCK), + ((-100, -50, -50), LAVA_BLOCK), + ((-100, -50, 0), LAVA_BLOCK), + ((-100, -50, 50), LAVA_BLOCK), + ((-100, -50, 100), WATER_BLOCK), + ((-100, 0, -100), WATER_BLOCK), + ((-100, 0, -50), WATER_BLOCK), + ((-100, 0, 0), WATER_BLOCK), + ((-100, 0, 50), WATER_BLOCK), + ((-100, 0, 100), WATER_BLOCK), + ((-100, 50, -100), WATER_BLOCK), + ((-100, 50, -50), WATER_BLOCK), + ((-100, 50, 0), WATER_BLOCK), + ((-100, 50, 50), WATER_BLOCK), + ((-100, 50, 100), WATER_BLOCK), + ((-100, 100, -100), WATER_BLOCK), + ((-100, 100, -50), WATER_BLOCK), + ((-100, 100, 0), WATER_BLOCK), + ((-100, 100, 50), WATER_BLOCK), + ((-100, 100, 100), WATER_BLOCK), + ((-50, -100, -100), WATER_BLOCK), + ((-50, -100, -50), WATER_BLOCK), + ((-50, -100, 0), LAVA_BLOCK), + ((-50, -100, 50), LAVA_BLOCK), + ((-50, -100, 100), WATER_BLOCK), + ((-50, -50, -100), WATER_BLOCK), + ((-50, -50, -50), WATER_BLOCK), + ((-50, -50, 0), WATER_BLOCK), + ((-50, -50, 50), WATER_BLOCK), + ((-50, -50, 100), WATER_BLOCK), + ((-50, 0, -100), LAVA_BLOCK), + ((-50, 0, -50), WATER_BLOCK), + ((-50, 0, 0), WATER_BLOCK), + ((-50, 0, 50), WATER_BLOCK), + ((-50, 0, 100), WATER_BLOCK), + ((-50, 50, -100), WATER_BLOCK), + ((-50, 50, -50), WATER_BLOCK), + ((-50, 50, 0), LAVA_BLOCK), + ((-50, 50, 50), LAVA_BLOCK), + ((-50, 50, 100), WATER_BLOCK), + ((-50, 100, -100), WATER_BLOCK), + ((-50, 100, -50), WATER_BLOCK), + ((-50, 100, 0), LAVA_BLOCK), + ((-50, 100, 50), LAVA_BLOCK), + ((-50, 100, 100), LAVA_BLOCK), + ((0, -100, -100), WATER_BLOCK), + ((0, -100, -50), LAVA_BLOCK), + ((0, -100, 0), LAVA_BLOCK), + ((0, -100, 50), LAVA_BLOCK), + ((0, -100, 100), WATER_BLOCK), + ((0, -50, -100), WATER_BLOCK), + ((0, -50, -50), WATER_BLOCK), + ((0, -50, 0), WATER_BLOCK), + ((0, -50, 50), WATER_BLOCK), + ((0, -50, 100), WATER_BLOCK), + ((0, 0, -100), LAVA_BLOCK), + ((0, 0, -50), LAVA_BLOCK), + ((0, 0, 0), WATER_BLOCK), + ((0, 0, 50), WATER_BLOCK), + ((0, 0, 100), WATER_BLOCK), + ((0, 50, -100), WATER_BLOCK), + ((0, 50, -50), WATER_BLOCK), + ((0, 50, 0), WATER_BLOCK), + ((0, 50, 50), WATER_BLOCK), + ((0, 50, 100), WATER_BLOCK), + ((0, 100, -100), WATER_BLOCK), + ((0, 100, -50), LAVA_BLOCK), + ((0, 100, 0), WATER_BLOCK), + ((0, 100, 50), WATER_BLOCK), + ((0, 100, 100), WATER_BLOCK), + ((50, -100, -100), WATER_BLOCK), + ((50, -100, -50), LAVA_BLOCK), + ((50, -100, 0), LAVA_BLOCK), + ((50, -100, 50), LAVA_BLOCK), + ((50, -100, 100), WATER_BLOCK), + ((50, -50, -100), WATER_BLOCK), + ((50, -50, -50), WATER_BLOCK), + ((50, -50, 0), WATER_BLOCK), + ((50, -50, 50), WATER_BLOCK), + ((50, -50, 100), WATER_BLOCK), + ((50, 0, -100), LAVA_BLOCK), + ((50, 0, -50), LAVA_BLOCK), + ((50, 0, 0), WATER_BLOCK), + ((50, 0, 50), WATER_BLOCK), + ((50, 0, 100), WATER_BLOCK), + ((50, 50, -100), WATER_BLOCK), + ((50, 50, -50), WATER_BLOCK), + ((50, 50, 0), WATER_BLOCK), + ((50, 50, 50), WATER_BLOCK), + ((50, 50, 100), WATER_BLOCK), + ((50, 100, -100), WATER_BLOCK), + ((50, 100, -50), LAVA_BLOCK), + ((50, 100, 0), WATER_BLOCK), + ((50, 100, 50), WATER_BLOCK), + ((50, 100, 100), WATER_BLOCK), + ((100, -100, -100), WATER_BLOCK), + ((100, -100, -50), LAVA_BLOCK), + ((100, -100, 0), WATER_BLOCK), + ((100, -100, 50), WATER_BLOCK), + ((100, -100, 100), WATER_BLOCK), + ((100, -50, -100), LAVA_BLOCK), + ((100, -50, -50), LAVA_BLOCK), + ((100, -50, 0), LAVA_BLOCK), + ((100, -50, 50), LAVA_BLOCK), + ((100, -50, 100), LAVA_BLOCK), + ((100, 0, -100), WATER_BLOCK), + ((100, 0, -50), LAVA_BLOCK), + ((100, 0, 0), WATER_BLOCK), + ((100, 0, 50), WATER_BLOCK), + ((100, 0, 100), LAVA_BLOCK), + ((100, 50, -100), WATER_BLOCK), + ((100, 50, -50), WATER_BLOCK), + ((100, 50, 0), WATER_BLOCK), + ((100, 50, 50), WATER_BLOCK), + ((100, 50, 100), WATER_BLOCK), + ((100, 100, -100), LAVA_BLOCK), + ((100, 100, -50), LAVA_BLOCK), + ((100, 100, 0), WATER_BLOCK), + ((100, 100, 50), WATER_BLOCK), + ((100, 100, 100), WATER_BLOCK), ]; for ((x, y, z), result) in values { @@ -1001,7 +1001,7 @@ mod test { #[test] fn test_get_fluid_block_y() { let (mut aquifer, _, env) = create_aquifer(); - let level = FluidLevel::new(0, *WATER_BLOCK); + let level = FluidLevel::new(0, WATER_BLOCK); let values = [ ((-100, -100, -100), -32512), ((-100, -100, -50), -32512), @@ -1277,131 +1277,131 @@ mod test { fn test_get_fluid_level() { let (mut aquifer, mut funcs, env) = create_aquifer(); let values = [ - ((-100, -100, -100), (-32512, *LAVA_BLOCK)), - ((-100, -100, -50), (-32512, *LAVA_BLOCK)), - ((-100, -100, 0), (-32512, *LAVA_BLOCK)), - ((-100, -100, 50), (-32512, *LAVA_BLOCK)), - ((-100, -100, 100), (-32512, *LAVA_BLOCK)), - ((-100, -50, -100), (-32512, *WATER_BLOCK)), - ((-100, -50, -50), (-63, *LAVA_BLOCK)), - ((-100, -50, 0), (-63, *LAVA_BLOCK)), - ((-100, -50, 50), (-63, *LAVA_BLOCK)), - ((-100, -50, 100), (-32512, *WATER_BLOCK)), - ((-100, 0, -100), (-32512, *WATER_BLOCK)), - ((-100, 0, -50), (-32512, *WATER_BLOCK)), - ((-100, 0, 0), (-32512, *WATER_BLOCK)), - ((-100, 0, 50), (-32512, *WATER_BLOCK)), - ((-100, 0, 100), (-32512, *WATER_BLOCK)), - ((-100, 50, -100), (-32512, *WATER_BLOCK)), - ((-100, 50, -50), (63, *WATER_BLOCK)), - ((-100, 50, 0), (63, *WATER_BLOCK)), - ((-100, 50, 50), (-32512, *WATER_BLOCK)), - ((-100, 50, 100), (63, *WATER_BLOCK)), - ((-100, 100, -100), (63, *WATER_BLOCK)), - ((-100, 100, -50), (63, *WATER_BLOCK)), - ((-100, 100, 0), (63, *WATER_BLOCK)), - ((-100, 100, 50), (63, *WATER_BLOCK)), - ((-100, 100, 100), (63, *WATER_BLOCK)), - ((-50, -100, -100), (-32512, *LAVA_BLOCK)), - ((-50, -100, -50), (-32512, *LAVA_BLOCK)), - ((-50, -100, 0), (-32512, *LAVA_BLOCK)), - ((-50, -100, 50), (-32512, *LAVA_BLOCK)), - ((-50, -100, 100), (-32512, *LAVA_BLOCK)), - ((-50, -50, -100), (-32512, *WATER_BLOCK)), - ((-50, -50, -50), (-32512, *WATER_BLOCK)), - ((-50, -50, 0), (-32512, *WATER_BLOCK)), - ((-50, -50, 50), (-32512, *WATER_BLOCK)), - ((-50, -50, 100), (-32512, *WATER_BLOCK)), - ((-50, 0, -100), (-32512, *WATER_BLOCK)), - ((-50, 0, -50), (-32512, *WATER_BLOCK)), - ((-50, 0, 0), (-32512, *WATER_BLOCK)), - ((-50, 0, 50), (-32512, *WATER_BLOCK)), - ((-50, 0, 100), (-32512, *WATER_BLOCK)), - ((-50, 50, -100), (-32512, *WATER_BLOCK)), - ((-50, 50, -50), (63, *WATER_BLOCK)), - ((-50, 50, 0), (63, *WATER_BLOCK)), - ((-50, 50, 50), (-32512, *WATER_BLOCK)), - ((-50, 50, 100), (63, *WATER_BLOCK)), - ((-50, 100, -100), (63, *WATER_BLOCK)), - ((-50, 100, -50), (63, *WATER_BLOCK)), - ((-50, 100, 0), (63, *WATER_BLOCK)), - ((-50, 100, 50), (63, *WATER_BLOCK)), - ((-50, 100, 100), (63, *WATER_BLOCK)), - ((0, -100, -100), (-32512, *LAVA_BLOCK)), - ((0, -100, -50), (-32512, *LAVA_BLOCK)), - ((0, -100, 0), (-32512, *LAVA_BLOCK)), - ((0, -100, 50), (-32512, *LAVA_BLOCK)), - ((0, -100, 100), (-32512, *LAVA_BLOCK)), - ((0, -50, -100), (-32512, *WATER_BLOCK)), - ((0, -50, -50), (-32512, *WATER_BLOCK)), - ((0, -50, 0), (-32512, *WATER_BLOCK)), - ((0, -50, 50), (-32512, *WATER_BLOCK)), - ((0, -50, 100), (-32512, *WATER_BLOCK)), - ((0, 0, -100), (-32512, *WATER_BLOCK)), - ((0, 0, -50), (-32512, *WATER_BLOCK)), - ((0, 0, 0), (-32512, *WATER_BLOCK)), - ((0, 0, 50), (-32512, *WATER_BLOCK)), - ((0, 0, 100), (-32512, *WATER_BLOCK)), - ((0, 50, -100), (-32512, *WATER_BLOCK)), - ((0, 50, -50), (63, *WATER_BLOCK)), - ((0, 50, 0), (63, *WATER_BLOCK)), - ((0, 50, 50), (-32512, *WATER_BLOCK)), - ((0, 50, 100), (-32512, *WATER_BLOCK)), - ((0, 100, -100), (63, *WATER_BLOCK)), - ((0, 100, -50), (63, *WATER_BLOCK)), - ((0, 100, 0), (63, *WATER_BLOCK)), - ((0, 100, 50), (63, *WATER_BLOCK)), - ((0, 100, 100), (63, *WATER_BLOCK)), - ((50, -100, -100), (-32512, *LAVA_BLOCK)), - ((50, -100, -50), (-32512, *LAVA_BLOCK)), - ((50, -100, 0), (-32512, *LAVA_BLOCK)), - ((50, -100, 50), (-32512, *LAVA_BLOCK)), - ((50, -100, 100), (-100, *LAVA_BLOCK)), - ((50, -50, -100), (-32512, *WATER_BLOCK)), - ((50, -50, -50), (-32512, *WATER_BLOCK)), - ((50, -50, 0), (-32512, *WATER_BLOCK)), - ((50, -50, 50), (-32512, *WATER_BLOCK)), - ((50, -50, 100), (-60, *WATER_BLOCK)), - ((50, 0, -100), (-32512, *WATER_BLOCK)), - ((50, 0, -50), (-32512, *WATER_BLOCK)), - ((50, 0, 0), (-32512, *WATER_BLOCK)), - ((50, 0, 50), (-32512, *WATER_BLOCK)), - ((50, 0, 100), (-32512, *WATER_BLOCK)), - ((50, 50, -100), (-32512, *WATER_BLOCK)), - ((50, 50, -50), (63, *WATER_BLOCK)), - ((50, 50, 0), (63, *WATER_BLOCK)), - ((50, 50, 50), (63, *WATER_BLOCK)), - ((50, 50, 100), (-32512, *WATER_BLOCK)), - ((50, 100, -100), (-32512, *WATER_BLOCK)), - ((50, 100, -50), (63, *WATER_BLOCK)), - ((50, 100, 0), (63, *WATER_BLOCK)), - ((50, 100, 50), (63, *WATER_BLOCK)), - ((50, 100, 100), (63, *WATER_BLOCK)), - ((100, -100, -100), (-32512, *LAVA_BLOCK)), - ((100, -100, -50), (-32512, *LAVA_BLOCK)), - ((100, -100, 0), (-32512, *LAVA_BLOCK)), - ((100, -100, 50), (-103, *LAVA_BLOCK)), - ((100, -100, 100), (-100, *LAVA_BLOCK)), - ((100, -50, -100), (-32512, *WATER_BLOCK)), - ((100, -50, -50), (-32512, *WATER_BLOCK)), - ((100, -50, 0), (-32512, *WATER_BLOCK)), - ((100, -50, 50), (-32512, *WATER_BLOCK)), - ((100, -50, 100), (-60, *LAVA_BLOCK)), - ((100, 0, -100), (-32512, *WATER_BLOCK)), - ((100, 0, -50), (-32512, *WATER_BLOCK)), - ((100, 0, 0), (-32512, *WATER_BLOCK)), - ((100, 0, 50), (-32512, *WATER_BLOCK)), - ((100, 0, 100), (-32512, *WATER_BLOCK)), - ((100, 50, -100), (63, *WATER_BLOCK)), - ((100, 50, -50), (63, *WATER_BLOCK)), - ((100, 50, 0), (63, *WATER_BLOCK)), - ((100, 50, 50), (63, *WATER_BLOCK)), - ((100, 50, 100), (-32512, *WATER_BLOCK)), - ((100, 100, -100), (63, *WATER_BLOCK)), - ((100, 100, -50), (63, *WATER_BLOCK)), - ((100, 100, 0), (63, *WATER_BLOCK)), - ((100, 100, 50), (63, *WATER_BLOCK)), - ((100, 100, 100), (63, *WATER_BLOCK)), + ((-100, -100, -100), (-32512, LAVA_BLOCK)), + ((-100, -100, -50), (-32512, LAVA_BLOCK)), + ((-100, -100, 0), (-32512, LAVA_BLOCK)), + ((-100, -100, 50), (-32512, LAVA_BLOCK)), + ((-100, -100, 100), (-32512, LAVA_BLOCK)), + ((-100, -50, -100), (-32512, WATER_BLOCK)), + ((-100, -50, -50), (-63, LAVA_BLOCK)), + ((-100, -50, 0), (-63, LAVA_BLOCK)), + ((-100, -50, 50), (-63, LAVA_BLOCK)), + ((-100, -50, 100), (-32512, WATER_BLOCK)), + ((-100, 0, -100), (-32512, WATER_BLOCK)), + ((-100, 0, -50), (-32512, WATER_BLOCK)), + ((-100, 0, 0), (-32512, WATER_BLOCK)), + ((-100, 0, 50), (-32512, WATER_BLOCK)), + ((-100, 0, 100), (-32512, WATER_BLOCK)), + ((-100, 50, -100), (-32512, WATER_BLOCK)), + ((-100, 50, -50), (63, WATER_BLOCK)), + ((-100, 50, 0), (63, WATER_BLOCK)), + ((-100, 50, 50), (-32512, WATER_BLOCK)), + ((-100, 50, 100), (63, WATER_BLOCK)), + ((-100, 100, -100), (63, WATER_BLOCK)), + ((-100, 100, -50), (63, WATER_BLOCK)), + ((-100, 100, 0), (63, WATER_BLOCK)), + ((-100, 100, 50), (63, WATER_BLOCK)), + ((-100, 100, 100), (63, WATER_BLOCK)), + ((-50, -100, -100), (-32512, LAVA_BLOCK)), + ((-50, -100, -50), (-32512, LAVA_BLOCK)), + ((-50, -100, 0), (-32512, LAVA_BLOCK)), + ((-50, -100, 50), (-32512, LAVA_BLOCK)), + ((-50, -100, 100), (-32512, LAVA_BLOCK)), + ((-50, -50, -100), (-32512, WATER_BLOCK)), + ((-50, -50, -50), (-32512, WATER_BLOCK)), + ((-50, -50, 0), (-32512, WATER_BLOCK)), + ((-50, -50, 50), (-32512, WATER_BLOCK)), + ((-50, -50, 100), (-32512, WATER_BLOCK)), + ((-50, 0, -100), (-32512, WATER_BLOCK)), + ((-50, 0, -50), (-32512, WATER_BLOCK)), + ((-50, 0, 0), (-32512, WATER_BLOCK)), + ((-50, 0, 50), (-32512, WATER_BLOCK)), + ((-50, 0, 100), (-32512, WATER_BLOCK)), + ((-50, 50, -100), (-32512, WATER_BLOCK)), + ((-50, 50, -50), (63, WATER_BLOCK)), + ((-50, 50, 0), (63, WATER_BLOCK)), + ((-50, 50, 50), (-32512, WATER_BLOCK)), + ((-50, 50, 100), (63, WATER_BLOCK)), + ((-50, 100, -100), (63, WATER_BLOCK)), + ((-50, 100, -50), (63, WATER_BLOCK)), + ((-50, 100, 0), (63, WATER_BLOCK)), + ((-50, 100, 50), (63, WATER_BLOCK)), + ((-50, 100, 100), (63, WATER_BLOCK)), + ((0, -100, -100), (-32512, LAVA_BLOCK)), + ((0, -100, -50), (-32512, LAVA_BLOCK)), + ((0, -100, 0), (-32512, LAVA_BLOCK)), + ((0, -100, 50), (-32512, LAVA_BLOCK)), + ((0, -100, 100), (-32512, LAVA_BLOCK)), + ((0, -50, -100), (-32512, WATER_BLOCK)), + ((0, -50, -50), (-32512, WATER_BLOCK)), + ((0, -50, 0), (-32512, WATER_BLOCK)), + ((0, -50, 50), (-32512, WATER_BLOCK)), + ((0, -50, 100), (-32512, WATER_BLOCK)), + ((0, 0, -100), (-32512, WATER_BLOCK)), + ((0, 0, -50), (-32512, WATER_BLOCK)), + ((0, 0, 0), (-32512, WATER_BLOCK)), + ((0, 0, 50), (-32512, WATER_BLOCK)), + ((0, 0, 100), (-32512, WATER_BLOCK)), + ((0, 50, -100), (-32512, WATER_BLOCK)), + ((0, 50, -50), (63, WATER_BLOCK)), + ((0, 50, 0), (63, WATER_BLOCK)), + ((0, 50, 50), (-32512, WATER_BLOCK)), + ((0, 50, 100), (-32512, WATER_BLOCK)), + ((0, 100, -100), (63, WATER_BLOCK)), + ((0, 100, -50), (63, WATER_BLOCK)), + ((0, 100, 0), (63, WATER_BLOCK)), + ((0, 100, 50), (63, WATER_BLOCK)), + ((0, 100, 100), (63, WATER_BLOCK)), + ((50, -100, -100), (-32512, LAVA_BLOCK)), + ((50, -100, -50), (-32512, LAVA_BLOCK)), + ((50, -100, 0), (-32512, LAVA_BLOCK)), + ((50, -100, 50), (-32512, LAVA_BLOCK)), + ((50, -100, 100), (-100, LAVA_BLOCK)), + ((50, -50, -100), (-32512, WATER_BLOCK)), + ((50, -50, -50), (-32512, WATER_BLOCK)), + ((50, -50, 0), (-32512, WATER_BLOCK)), + ((50, -50, 50), (-32512, WATER_BLOCK)), + ((50, -50, 100), (-60, WATER_BLOCK)), + ((50, 0, -100), (-32512, WATER_BLOCK)), + ((50, 0, -50), (-32512, WATER_BLOCK)), + ((50, 0, 0), (-32512, WATER_BLOCK)), + ((50, 0, 50), (-32512, WATER_BLOCK)), + ((50, 0, 100), (-32512, WATER_BLOCK)), + ((50, 50, -100), (-32512, WATER_BLOCK)), + ((50, 50, -50), (63, WATER_BLOCK)), + ((50, 50, 0), (63, WATER_BLOCK)), + ((50, 50, 50), (63, WATER_BLOCK)), + ((50, 50, 100), (-32512, WATER_BLOCK)), + ((50, 100, -100), (-32512, WATER_BLOCK)), + ((50, 100, -50), (63, WATER_BLOCK)), + ((50, 100, 0), (63, WATER_BLOCK)), + ((50, 100, 50), (63, WATER_BLOCK)), + ((50, 100, 100), (63, WATER_BLOCK)), + ((100, -100, -100), (-32512, LAVA_BLOCK)), + ((100, -100, -50), (-32512, LAVA_BLOCK)), + ((100, -100, 0), (-32512, LAVA_BLOCK)), + ((100, -100, 50), (-103, LAVA_BLOCK)), + ((100, -100, 100), (-100, LAVA_BLOCK)), + ((100, -50, -100), (-32512, WATER_BLOCK)), + ((100, -50, -50), (-32512, WATER_BLOCK)), + ((100, -50, 0), (-32512, WATER_BLOCK)), + ((100, -50, 50), (-32512, WATER_BLOCK)), + ((100, -50, 100), (-60, LAVA_BLOCK)), + ((100, 0, -100), (-32512, WATER_BLOCK)), + ((100, 0, -50), (-32512, WATER_BLOCK)), + ((100, 0, 0), (-32512, WATER_BLOCK)), + ((100, 0, 50), (-32512, WATER_BLOCK)), + ((100, 0, 100), (-32512, WATER_BLOCK)), + ((100, 50, -100), (63, WATER_BLOCK)), + ((100, 50, -50), (63, WATER_BLOCK)), + ((100, 50, 0), (63, WATER_BLOCK)), + ((100, 50, 50), (63, WATER_BLOCK)), + ((100, 50, 100), (-32512, WATER_BLOCK)), + ((100, 100, -100), (63, WATER_BLOCK)), + ((100, 100, -50), (63, WATER_BLOCK)), + ((100, 100, 0), (63, WATER_BLOCK)), + ((100, 100, 50), (63, WATER_BLOCK)), + ((100, 100, 100), (63, WATER_BLOCK)), ]; for ((x, y, z), (y1, state)) in values { @@ -1544,8 +1544,8 @@ mod test { ]; for ((x, y, z, h1, h2), result) in values { - let level1 = FluidLevel::new(h1, *WATER_BLOCK); - let level2 = FluidLevel::new(h2, *WATER_BLOCK); + let level1 = FluidLevel::new(h1, WATER_BLOCK); + let level2 = FluidLevel::new(h2, WATER_BLOCK); let pos = &NoisePos::Unblended(UnblendedNoisePos::new(x, y, z)); let sample = aquifer.barrier_noise.sample_mut(pos, &env); assert_eq!( @@ -1655,8 +1655,8 @@ mod test { ((114, -20, 70, 0.11121282163190734), None), ((114, -20, 72, 0.11433776346079558), None), ((114, -20, 74, 0.11770444723497474), None), - ((114, 0, 64, -0.0026209759846139574), Some(*WATER_BLOCK)), - ((114, 0, 66, -0.0011869543056835608), Some(*WATER_BLOCK)), + ((114, 0, 64, -0.0026209759846139574), Some(WATER_BLOCK)), + ((114, 0, 66, -0.0011869543056835608), Some(WATER_BLOCK)), ((114, 0, 68, 3.9347454816496854E-4), None), ((114, 0, 70, 0.002068623223791626), None), ((114, 0, 72, 0.0038193250297024243), None), @@ -1721,9 +1721,9 @@ mod test { ((116, -20, 70, 0.11589560860382501), None), ((116, -20, 72, 0.11889599517563405), None), ((116, -20, 74, 0.12214992807094607), None), - ((116, 0, 64, -0.003764380972543319), Some(*WATER_BLOCK)), - ((116, 0, 66, -0.002339168705169207), Some(*WATER_BLOCK)), - ((116, 0, 68, -7.530784033722614E-4), Some(*WATER_BLOCK)), + ((116, 0, 64, -0.003764380972543319), Some(WATER_BLOCK)), + ((116, 0, 66, -0.002339168705169207), Some(WATER_BLOCK)), + ((116, 0, 68, -7.530784033722614E-4), Some(WATER_BLOCK)), ((116, 0, 70, 9.517226455286942E-4), None), ((116, 0, 72, 0.0027605740566328273), None), ((116, 0, 74, 0.0046712919320928475), None), @@ -1787,10 +1787,10 @@ mod test { ((118, -20, 70, 0.12038440430256446), None), ((118, -20, 72, 0.12325317705242089), None), ((118, -20, 74, 0.12637678353248477), None), - ((118, 0, 64, -0.00501589634392619), Some(*WATER_BLOCK)), - ((118, 0, 66, -0.003601631485605401), Some(*WATER_BLOCK)), - ((118, 0, 68, -0.0020166185756455924), Some(*WATER_BLOCK)), - ((118, 0, 70, -2.901294172670075E-4), Some(*WATER_BLOCK)), + ((118, 0, 64, -0.00501589634392619), Some(WATER_BLOCK)), + ((118, 0, 66, -0.003601631485605401), Some(WATER_BLOCK)), + ((118, 0, 68, -0.0020166185756455924), Some(WATER_BLOCK)), + ((118, 0, 70, -2.901294172670075E-4), Some(WATER_BLOCK)), ((118, 0, 72, 0.0015704124446037308), None), ((118, 0, 74, 0.0035605198020311826), None), ((118, 20, 64, 0.040232966220497414), None), @@ -1853,10 +1853,10 @@ mod test { ((120, -20, 70, 0.12469970986670785), None), ((120, -20, 72, 0.1274266324562779), None), ((120, -20, 74, 0.13039812171785095), None), - ((120, 0, 64, -0.006329576321547214), Some(*WATER_BLOCK)), - ((120, 0, 66, -0.004930192503238298), Some(*WATER_BLOCK)), - ((120, 0, 68, -0.003355964670343278), Some(*WATER_BLOCK)), - ((120, 0, 70, -0.0016206542469077872), Some(*WATER_BLOCK)), + ((120, 0, 64, -0.006329576321547214), Some(WATER_BLOCK)), + ((120, 0, 66, -0.004930192503238298), Some(WATER_BLOCK)), + ((120, 0, 68, -0.003355964670343278), Some(WATER_BLOCK)), + ((120, 0, 70, -0.0016206542469077872), Some(WATER_BLOCK)), ((120, 0, 72, 2.77535008128212E-4), None), ((120, 0, 74, 0.002332419553726638), None), ((120, 20, 64, 0.04783863627983937), None), @@ -1871,12 +1871,12 @@ mod test { ((120, 40, 70, -0.020228945291907708), Some(BlockState::AIR)), ((120, 40, 72, -0.01664436674077766), Some(BlockState::AIR)), ((120, 40, 74, -0.013001583733654043), Some(BlockState::AIR)), - ((120, 60, 64, -0.010805185122555435), Some(*WATER_BLOCK)), - ((120, 60, 66, -0.011684313707812422), Some(*WATER_BLOCK)), - ((120, 60, 68, -0.007705484690135335), Some(*WATER_BLOCK)), - ((120, 60, 70, -0.012326309226980426), Some(*WATER_BLOCK)), - ((120, 60, 72, -0.019043795741958334), Some(*WATER_BLOCK)), - ((120, 60, 74, -0.023185441889689514), Some(*WATER_BLOCK)), + ((120, 60, 64, -0.010805185122555435), Some(WATER_BLOCK)), + ((120, 60, 66, -0.011684313707812422), Some(WATER_BLOCK)), + ((120, 60, 68, -0.007705484690135335), Some(WATER_BLOCK)), + ((120, 60, 70, -0.012326309226980426), Some(WATER_BLOCK)), + ((120, 60, 72, -0.019043795741958334), Some(WATER_BLOCK)), + ((120, 60, 74, -0.023185441889689514), Some(WATER_BLOCK)), ((120, 80, 64, -0.3611328625547435), Some(BlockState::AIR)), ((120, 80, 66, -0.3586517592327399), Some(BlockState::AIR)), ((120, 80, 68, -0.3524534485283812), Some(BlockState::AIR)), @@ -1919,11 +1919,11 @@ mod test { ((122, -20, 70, 0.12884021810202248), None), ((122, -20, 72, 0.13141636494496137), None), ((122, -20, 74, 0.13421609155559988), None), - ((122, 0, 64, -0.007667256303541582), Some(*WATER_BLOCK)), - ((122, 0, 66, -0.006288822820341533), Some(*WATER_BLOCK)), - ((122, 0, 68, -0.004737470102527975), Some(*WATER_BLOCK)), - ((122, 0, 70, -0.0030099389619020873), Some(*WATER_BLOCK)), - ((122, 0, 72, -0.0010942861750551764), Some(*WATER_BLOCK)), + ((122, 0, 64, -0.007667256303541582), Some(WATER_BLOCK)), + ((122, 0, 66, -0.006288822820341533), Some(WATER_BLOCK)), + ((122, 0, 68, -0.004737470102527975), Some(WATER_BLOCK)), + ((122, 0, 70, -0.0030099389619020873), Some(WATER_BLOCK)), + ((122, 0, 72, -0.0010942861750551764), Some(WATER_BLOCK)), ((122, 0, 74, 0.001001992078975999), None), ((122, 20, 64, 0.05535892661135848), None), ((122, 20, 66, 0.05444413322973901), None), @@ -1937,12 +1937,12 @@ mod test { ((122, 40, 70, -0.022658183924480487), Some(BlockState::AIR)), ((122, 40, 72, -0.02460705550987633), Some(BlockState::AIR)), ((122, 40, 74, -0.02133677750482264), None), - ((122, 60, 64, -0.02580014098083049), Some(*WATER_BLOCK)), - ((122, 60, 66, -0.027410062228040422), Some(*WATER_BLOCK)), - ((122, 60, 68, -0.02425659570836858), Some(*WATER_BLOCK)), - ((122, 60, 70, -0.03261718168256943), Some(*WATER_BLOCK)), - ((122, 60, 72, -0.04369665936638442), Some(*WATER_BLOCK)), - ((122, 60, 74, -0.04490159197647781), Some(*WATER_BLOCK)), + ((122, 60, 64, -0.02580014098083049), Some(WATER_BLOCK)), + ((122, 60, 66, -0.027410062228040422), Some(WATER_BLOCK)), + ((122, 60, 68, -0.02425659570836858), Some(WATER_BLOCK)), + ((122, 60, 70, -0.03261718168256943), Some(WATER_BLOCK)), + ((122, 60, 72, -0.04369665936638442), Some(WATER_BLOCK)), + ((122, 60, 74, -0.04490159197647781), Some(WATER_BLOCK)), ((122, 80, 64, -0.37247525946547166), Some(BlockState::AIR)), ((122, 80, 66, -0.3727266378002749), Some(BlockState::AIR)), ((122, 80, 68, -0.36804742745663505), Some(BlockState::AIR)), @@ -1985,11 +1985,11 @@ mod test { ((124, -20, 70, 0.1327707947453995), None), ((124, -20, 72, 0.13519345838131658), None), ((124, -20, 74, 0.13781110986582973), None), - ((124, 0, 64, -0.009009809178163559), Some(*WATER_BLOCK)), - ((124, 0, 66, -0.007660237459532607), Some(*WATER_BLOCK)), - ((124, 0, 68, -0.0061446463166489424), Some(*WATER_BLOCK)), - ((124, 0, 70, -0.004442459854201204), Some(*WATER_BLOCK)), - ((124, 0, 72, -0.0025318494505197223), Some(*WATER_BLOCK)), + ((124, 0, 64, -0.009009809178163559), Some(WATER_BLOCK)), + ((124, 0, 66, -0.007660237459532607), Some(WATER_BLOCK)), + ((124, 0, 68, -0.0061446463166489424), Some(WATER_BLOCK)), + ((124, 0, 70, -0.004442459854201204), Some(WATER_BLOCK)), + ((124, 0, 72, -0.0025318494505197223), Some(WATER_BLOCK)), ((124, 0, 74, -4.216225767843497E-4), None), ((124, 20, 64, 0.06277697412858188), None), ((124, 20, 66, 0.06182400117210263), None), @@ -2000,15 +2000,15 @@ mod test { ((124, 40, 64, -0.004596793013348681), None), ((124, 40, 66, -0.007881293688553023), None), ((124, 40, 68, -0.010851313478373932), None), - ((124, 40, 70, -0.013513605008223933), Some(*WATER_BLOCK)), - ((124, 40, 72, -0.015880866729427373), Some(*WATER_BLOCK)), - ((124, 40, 74, -0.017978317799117856), Some(*WATER_BLOCK)), - ((124, 60, 64, -0.033729060298063454), Some(*WATER_BLOCK)), - ((124, 60, 66, -0.04062740064249005), Some(*WATER_BLOCK)), - ((124, 60, 68, -0.03660634922712756), Some(*WATER_BLOCK)), - ((124, 60, 70, -0.04106936165998065), Some(*WATER_BLOCK)), - ((124, 60, 72, -0.048715160337165046), Some(*WATER_BLOCK)), - ((124, 60, 74, -0.053817378732386144), Some(*WATER_BLOCK)), + ((124, 40, 70, -0.013513605008223933), Some(WATER_BLOCK)), + ((124, 40, 72, -0.015880866729427373), Some(WATER_BLOCK)), + ((124, 40, 74, -0.017978317799117856), Some(WATER_BLOCK)), + ((124, 60, 64, -0.033729060298063454), Some(WATER_BLOCK)), + ((124, 60, 66, -0.04062740064249005), Some(WATER_BLOCK)), + ((124, 60, 68, -0.03660634922712756), Some(WATER_BLOCK)), + ((124, 60, 70, -0.04106936165998065), Some(WATER_BLOCK)), + ((124, 60, 72, -0.048715160337165046), Some(WATER_BLOCK)), + ((124, 60, 74, -0.053817378732386144), Some(WATER_BLOCK)), ((124, 80, 64, -0.378513110274629), Some(BlockState::AIR)), ((124, 80, 66, -0.37887533037235366), Some(BlockState::AIR)), ((124, 80, 68, -0.3755672366866089), Some(BlockState::AIR)), @@ -2051,12 +2051,12 @@ mod test { ((126, -20, 70, 0.13641807828631622), None), ((126, -20, 72, 0.13869641277763253), None), ((126, -20, 74, 0.1411390651002113), None), - ((126, 0, 64, -0.010355206926252296), Some(*WATER_BLOCK)), - ((126, 0, 66, -0.009043874021560911), Some(*WATER_BLOCK)), - ((126, 0, 68, -0.007576245457331987), Some(*WATER_BLOCK)), - ((126, 0, 70, -0.005915269354878528), Some(*WATER_BLOCK)), - ((126, 0, 72, -0.0040306175772153365), Some(*WATER_BLOCK)), - ((126, 0, 74, -0.0019328609472880898), Some(*WATER_BLOCK)), + ((126, 0, 64, -0.010355206926252296), Some(WATER_BLOCK)), + ((126, 0, 66, -0.009043874021560911), Some(WATER_BLOCK)), + ((126, 0, 68, -0.007576245457331987), Some(WATER_BLOCK)), + ((126, 0, 70, -0.005915269354878528), Some(WATER_BLOCK)), + ((126, 0, 72, -0.0040306175772153365), Some(WATER_BLOCK)), + ((126, 0, 74, -0.0019328609472880898), Some(WATER_BLOCK)), ((126, 20, 64, 0.0700499260773044), None), ((126, 20, 66, 0.06908003164862005), None), ((126, 20, 68, 0.0681425614589177), None), @@ -2065,16 +2065,16 @@ mod test { ((126, 20, 74, 0.06551116407146489), None), ((126, 40, 64, 0.004497597038868666), None), ((126, 40, 66, 0.0013502912778844962), None), - ((126, 40, 68, -0.0015191728313191184), Some(*WATER_BLOCK)), - ((126, 40, 70, -0.0041188588354404134), Some(*WATER_BLOCK)), - ((126, 40, 72, -0.006463772144671846), Some(*WATER_BLOCK)), - ((126, 40, 74, -0.008581034519921562), Some(*WATER_BLOCK)), - ((126, 60, 64, -0.03471424652823008), Some(*WATER_BLOCK)), - ((126, 60, 66, -0.04732045558891548), Some(*WATER_BLOCK)), - ((126, 60, 68, -0.04568337003176991), Some(*WATER_BLOCK)), - ((126, 60, 70, -0.0428377824231183), Some(*WATER_BLOCK)), - ((126, 60, 72, -0.04738820166968918), Some(*WATER_BLOCK)), - ((126, 60, 74, -0.05663750895047857), Some(*WATER_BLOCK)), + ((126, 40, 68, -0.0015191728313191184), Some(WATER_BLOCK)), + ((126, 40, 70, -0.0041188588354404134), Some(WATER_BLOCK)), + ((126, 40, 72, -0.006463772144671846), Some(WATER_BLOCK)), + ((126, 40, 74, -0.008581034519921562), Some(WATER_BLOCK)), + ((126, 60, 64, -0.03471424652823008), Some(WATER_BLOCK)), + ((126, 60, 66, -0.04732045558891548), Some(WATER_BLOCK)), + ((126, 60, 68, -0.04568337003176991), Some(WATER_BLOCK)), + ((126, 60, 70, -0.0428377824231183), Some(WATER_BLOCK)), + ((126, 60, 72, -0.04738820166968918), Some(WATER_BLOCK)), + ((126, 60, 74, -0.05663750895047857), Some(WATER_BLOCK)), ((126, 80, 64, -0.37931742687180287), Some(BlockState::AIR)), ((126, 80, 66, -0.38265481838544235), Some(BlockState::AIR)), ((126, 80, 68, -0.3808041835281554), Some(BlockState::AIR)), diff --git a/pumpkin-world/src/world_gen/chunk_noise.rs b/pumpkin-world/src/world_gen/chunk_noise.rs index 7e64e7393..5ff2bb270 100644 --- a/pumpkin-world/src/world_gen/chunk_noise.rs +++ b/pumpkin-world/src/world_gen/chunk_noise.rs @@ -1,8 +1,8 @@ use std::{collections::HashMap, hash::Hash, mem, num::Wrapping, ops::AddAssign, sync::Arc}; -use lazy_static::lazy_static; use num_traits::Zero; use pumpkin_core::math::{floor_div, vector2::Vector2, vector3::Vector3}; +use pumpkin_macros::block_state; use crate::{ block::BlockState, @@ -41,11 +41,9 @@ use super::{ positions::chunk_pos, }; -lazy_static! { - pub static ref STONE_BLOCK: BlockState = BlockState::new("stone").unwrap(); - pub static ref LAVA_BLOCK: BlockState = BlockState::new("lava").unwrap(); - pub static ref WATER_BLOCK: BlockState = BlockState::new("water").unwrap(); -} +pub const STONE_BLOCK: BlockState = block_state!("stone"); +pub const LAVA_BLOCK: BlockState = block_state!("lava"); +pub const WATER_BLOCK: BlockState = block_state!("water"); pub struct ChunkCacheOnceFunction> { delegate: R, @@ -1397,8 +1395,8 @@ mod test { let chunk_pos = Vector2::new(7, 4); let config = NoiseConfig::new(0, &OVERWORLD_NOISE_ROUTER); let sampler = FluidLevelSampler::Chunk(StandardChunkFluidLevelSampler::new( - FluidLevel::new(63, *WATER_BLOCK), - FluidLevel::new(-54, *LAVA_BLOCK), + FluidLevel::new(63, WATER_BLOCK), + FluidLevel::new(-54, LAVA_BLOCK), )); let mut noise = ChunkNoiseGenerator::new( 16 / shape.horizontal_cell_block_count(), diff --git a/pumpkin-world/src/world_gen/implementation/overworld/biome/mod.rs b/pumpkin-world/src/world_gen/implementation/overworld/biome/mod.rs index 85376842c..e5ec59c36 100644 --- a/pumpkin-world/src/world_gen/implementation/overworld/biome/mod.rs +++ b/pumpkin-world/src/world_gen/implementation/overworld/biome/mod.rs @@ -1,5 +1,7 @@ use std::ops::Add; +use pumpkin_macros::block_state; + use crate::{block::BlockState, coordinates::ChunkRelativeBlockCoordinates}; pub mod plains; @@ -25,7 +27,7 @@ pub fn generate_tree( y: (chunk_relative_coordinates.y.add(y as i16)).into(), z: z.add(dz as u8).into(), }; - tree_blocks.push((block_coordinates, BlockState::new("oak_log").unwrap())); + tree_blocks.push((block_coordinates, block_state!("oak_log"))); } } } @@ -40,7 +42,7 @@ pub fn generate_tree( y: (chunk_relative_coordinates.y.add(y as i16)).into(), z: z.add(dz as u8).into(), }; - tree_blocks.push((block_coordinates, BlockState::new("oak_leaves").unwrap())); + tree_blocks.push((block_coordinates, block_state!("oak_leaves"))); } } } diff --git a/pumpkin-world/src/world_gen/implementation/overworld/biome/plains.rs b/pumpkin-world/src/world_gen/implementation/overworld/biome/plains.rs index 8af21b62e..dde27c9c9 100644 --- a/pumpkin-world/src/world_gen/implementation/overworld/biome/plains.rs +++ b/pumpkin-world/src/world_gen/implementation/overworld/biome/plains.rs @@ -1,10 +1,10 @@ use noise::Perlin; use pumpkin_core::math::vector2::Vector2; +use pumpkin_macros::block_state; use rand::Rng; use crate::{ biome::Biome, - block::BlockState, chunk::ChunkBlocks, coordinates::{BlockCoordinates, ChunkRelativeBlockCoordinates, XZBlockCoordinates}, world_gen::{ @@ -55,16 +55,13 @@ impl PerlinTerrainGenerator for PlainsTerrainGenerator { let y = *at.y; if y == -64 { - blocks.set_block(coordinates, BlockState::new("bedrock").unwrap().state_id); + blocks.set_block(coordinates, block_state!("bedrock").state_id); } else if y >= -63 && y <= begin_stone_height { - blocks.set_block(coordinates, BlockState::new("stone").unwrap().state_id); + blocks.set_block(coordinates, block_state!("stone").state_id); } else if y >= begin_stone_height && y < begin_dirt_height { - blocks.set_block(coordinates, BlockState::new("dirt").unwrap().state_id); + blocks.set_block(coordinates, block_state!("dirt").state_id); } else if y == chunk_height - 2 { - blocks.set_block( - coordinates, - BlockState::new("grass_block").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("grass_block").state_id); } else if y == chunk_height - 1 { // TODO: generate flowers and grass let grass: u8 = rand::thread_rng().gen_range(0..7); @@ -73,40 +70,24 @@ impl PerlinTerrainGenerator for PlainsTerrainGenerator { if flower == 6 { match rand::thread_rng().gen_range(0..4) { 0 => { - blocks.set_block( - coordinates, - BlockState::new("dandelion").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("dandelion").state_id); } 1 => { - blocks.set_block( - coordinates, - BlockState::new("oxeye_daisy").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("oxeye_daisy").state_id); } 2 => { - blocks.set_block( - coordinates, - BlockState::new("cornflower").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("cornflower").state_id); } 3 => { - blocks - .set_block(coordinates, BlockState::new("poppy").unwrap().state_id); + blocks.set_block(coordinates, block_state!("poppy").state_id); } _ => { - blocks.set_block( - coordinates, - BlockState::new("azure_bluet").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("azure_bluet").state_id); } } } else { // TODO: Tall grass, Tall grass data called `half`, There is `upper` and `lower` - blocks.set_block( - coordinates, - BlockState::new("short_grass").unwrap().state_id, - ); + blocks.set_block(coordinates, block_state!("short_grass").state_id); } } } diff --git a/pumpkin-world/src/world_gen/implementation/superflat.rs b/pumpkin-world/src/world_gen/implementation/superflat.rs index 07fdc422a..2ec9fdad6 100644 --- a/pumpkin-world/src/world_gen/implementation/superflat.rs +++ b/pumpkin-world/src/world_gen/implementation/superflat.rs @@ -54,9 +54,9 @@ impl TerrainGenerator for SuperflatTerrainGenerator { /* fn generate_block(&self, at: BlockCoordinates, _: Biome) -> BlockState { match *at.y { - -64 => BlockState::new("bedrock").unwrap(), - -63..=-62 => BlockState::new("dirt").unwrap(), - -61 => BlockState::new("grass_block").unwrap(), + -64 => block_state!("bedrock"), + -63..=-62 => block_state!("dirt"), + -61 => block_state!("grass_block"), _ => BlockState::AIR, } } diff --git a/pumpkin-world/src/world_gen/noise/router.rs b/pumpkin-world/src/world_gen/noise/router.rs index 189556943..0627d8c6b 100644 --- a/pumpkin-world/src/world_gen/noise/router.rs +++ b/pumpkin-world/src/world_gen/noise/router.rs @@ -294,8 +294,8 @@ impl BaseRouter { )) .min(CAVES_NOODLE_OVERWORLD.clone()); - let i = *vein_type::MIN_Y; - let j = *vein_type::MAX_Y; + let i = vein_type::MIN_Y; + let j = vein_type::MAX_Y; let ore_veininess = vertical_range_choice( Y.clone(), NoiseFunction::new( diff --git a/pumpkin-world/src/world_gen/ore_sampler.rs b/pumpkin-world/src/world_gen/ore_sampler.rs index b381c4f64..36f6867b5 100644 --- a/pumpkin-world/src/world_gen/ore_sampler.rs +++ b/pumpkin-world/src/world_gen/ore_sampler.rs @@ -88,26 +88,24 @@ pub struct VeinType { // One of the victims of removing compile time blocks pub mod vein_type { - use lazy_static::lazy_static; + use pumpkin_macros::block_state; use super::*; - lazy_static! { - pub static ref COPPER: VeinType = VeinType { - ore: BlockState::new("copper_ore").unwrap(), - raw_ore: BlockState::new("raw_copper_block").unwrap(), - stone: BlockState::new("granite").unwrap(), - min_y: 0, - max_y: 50, - }; - pub static ref IRON: VeinType = VeinType { - ore: BlockState::new("deepslate_iron_ore").unwrap(), - raw_ore: BlockState::new("raw_iron_block").unwrap(), - stone: BlockState::new("tuff").unwrap(), - min_y: -60, - max_y: -8, - }; - pub static ref MIN_Y: i32 = IRON.min_y; - pub static ref MAX_Y: i32 = COPPER.max_y; - } + pub const COPPER: VeinType = VeinType { + ore: block_state!("copper_ore"), + raw_ore: block_state!("raw_copper_block"), + stone: block_state!("granite"), + min_y: 0, + max_y: 50, + }; + pub const IRON: VeinType = VeinType { + ore: block_state!("deepslate_iron_ore"), + raw_ore: block_state!("raw_iron_block"), + stone: block_state!("tuff"), + min_y: -60, + max_y: -8, + }; + pub const MIN_Y: i32 = IRON.min_y; + pub const MAX_Y: i32 = COPPER.max_y; } diff --git a/pumpkin-world/src/world_gen/proto_chunk.rs b/pumpkin-world/src/world_gen/proto_chunk.rs index ba0918afa..366df514c 100644 --- a/pumpkin-world/src/world_gen/proto_chunk.rs +++ b/pumpkin-world/src/world_gen/proto_chunk.rs @@ -66,8 +66,8 @@ impl ProtoChunk { // TODO: Customize these let sampler = FluidLevelSampler::Chunk(StandardChunkFluidLevelSampler::new( - FluidLevel::new(63, *WATER_BLOCK), - FluidLevel::new(-54, *LAVA_BLOCK), + FluidLevel::new(63, WATER_BLOCK), + FluidLevel::new(-54, LAVA_BLOCK), )); let height = generation_shape.height() as usize; @@ -163,7 +163,7 @@ impl ProtoChunk { // TODO: Change default block let block_state = - self.sampler.sample_block_state().unwrap_or(*STONE_BLOCK); + self.sampler.sample_block_state().unwrap_or(STONE_BLOCK); //log::debug!("Sampled block state in {:?}", inst.elapsed()); let local_pos = Vector3 {