1use steel_registry :: RegistryExt ; use steel_registry :: blocks :: block_state_ext :: BlockStateExt ; use std :: simd :: f64x4 ; use std :: simd :: Select ; use std :: simd :: cmp :: SimdPartialOrd ; use std :: simd :: num :: SimdFloat ; use steel_worldgen :: density :: spline_eval ; use steel_worldgen :: density :: RarityValueMapper ; use steel_math :: { clamp , map_clamped } ; use steel_worldgen :: noise :: NormalNoise ; use steel_worldgen :: random :: { PositionalRandom , RandomSplitter } ; # [doc = r" All noise generators needed by this dimension's density functions."] # [doc = r""] # [doc = r" Created at runtime from a seed via the `create` method."] pub struct NetherNoises { pub n_nether__temperature : NormalNoise , pub n_nether__vegetation : NormalNoise , pub blended_noise : steel_worldgen :: noise :: BlendedNoise , } impl NetherNoises { # [doc = r" Create all noise generators from a world seed, positional splitter, and noise parameters."] pub fn create (seed : u64 , splitter : & RandomSplitter , params : & rustc_hash :: FxHashMap < String , steel_worldgen :: density :: NoiseParameters > ,) -> Self { let _ = seed ; Self { n_nether__temperature : { let p = params . get ("minecraft:nether/temperature") . expect (concat ! ("missing noise params: " , "minecraft:nether/temperature")) ; NormalNoise :: create (splitter , "minecraft:nether/temperature" , p . first_octave , & p . amplitudes) } , n_nether__vegetation : { let p = params . get ("minecraft:nether/vegetation") . expect (concat ! ("missing noise params: " , "minecraft:nether/vegetation")) ; NormalNoise :: create (splitter , "minecraft:nether/vegetation" , p . first_octave , & p . amplitudes) } , blended_noise : { let mut rng = steel_worldgen :: random :: RandomSource :: Legacy (steel_worldgen :: random :: legacy_random :: LegacyRandom :: from_seed (seed)) ; steel_worldgen :: noise :: BlendedNoise :: new (& mut rng , 0.25 , 0.375 , 80.0 , 60.0 , 8.0 ,) } , } } } # [doc = r" Column-level cache for flat-cached (xz-only) density function results."] # [doc = r""] # [doc = r" Supports two modes matching vanilla's `NoiseChunk.FlatCache`:"] # [doc = r" - **Grid mode** (`init_grid()` called): Pre-computes a 2D grid of all"] # [doc = r" in-chunk quart positions. `ensure()` does O(1) grid lookups for"] # [doc = r" in-bounds positions, falls back to on-the-fly for out-of-bounds."] # [doc = r" - **No-grid mode** (default): Single-entry lazy cache that recomputes"] # [doc = r" when quart-quantized coordinates change. Used by climate samplers."] # [derive (Clone)] pub struct NetherColumnCache { # [doc = r" Raw x block coordinate (for non-flat router functions)."] pub x : i32 , # [doc = r" Raw z block coordinate (for non-flat router functions)."] pub z : i32 , # [doc = r" Effective x used to evaluate flat-cached values."] qx : i32 , # [doc = r" Effective z used to evaluate flat-cached values."] qz : i32 , valid : bool , grid_first_quart_x : i32 , grid_first_quart_z : i32 , has_grid : bool , pub router_barrier : f64 , pub router_continentalness : f64 , pub router_depth : f64 , pub router_erosion : f64 , pub router_fluid_level_floodedness : f64 , pub router_fluid_level_spread : f64 , pub router_lava : f64 , pub router_preliminary_surface_level : f64 , pub router_ridges : f64 , pub router_temperature : f64 , pub router_vegetation : f64 , pub router_vein_gap : f64 , pub router_vein_ridged : f64 , pub router_vein_toggle : f64 , grid_router_barrier : [f64 ; 25] , grid_router_continentalness : [f64 ; 25] , grid_router_depth : [f64 ; 25] , grid_router_erosion : [f64 ; 25] , grid_router_fluid_level_floodedness : [f64 ; 25] , grid_router_fluid_level_spread : [f64 ; 25] , grid_router_lava : [f64 ; 25] , grid_router_preliminary_surface_level : [f64 ; 25] , grid_router_ridges : [f64 ; 25] , grid_router_temperature : [f64 ; 25] , grid_router_vegetation : [f64 ; 25] , grid_router_vein_gap : [f64 ; 25] , grid_router_vein_ridged : [f64 ; 25] , grid_router_vein_toggle : [f64 ; 25] , } impl NetherColumnCache { # [doc = r" Grid side length (quart positions per axis)."] const GRID_SIDE : i32 = 5 ; # [doc = r" Create a new column cache without a pre-computed grid."] # [must_use] pub fn new () -> Self { Self { x : 0 , z : 0 , qx : i32 :: MIN , qz : i32 :: MIN , valid : false , grid_first_quart_x : 0 , grid_first_quart_z : 0 , has_grid : false , router_barrier : 0.0 , router_continentalness : 0.0 , router_depth : 0.0 , router_erosion : 0.0 , router_fluid_level_floodedness : 0.0 , router_fluid_level_spread : 0.0 , router_lava : 0.0 , router_preliminary_surface_level : 0.0 , router_ridges : 0.0 , router_temperature : 0.0 , router_vegetation : 0.0 , router_vein_gap : 0.0 , router_vein_ridged : 0.0 , router_vein_toggle : 0.0 , grid_router_barrier : [0.0 ; 25] , grid_router_continentalness : [0.0 ; 25] , grid_router_depth : [0.0 ; 25] , grid_router_erosion : [0.0 ; 25] , grid_router_fluid_level_floodedness : [0.0 ; 25] , grid_router_fluid_level_spread : [0.0 ; 25] , grid_router_lava : [0.0 ; 25] , grid_router_preliminary_surface_level : [0.0 ; 25] , grid_router_ridges : [0.0 ; 25] , grid_router_temperature : [0.0 ; 25] , grid_router_vegetation : [0.0 ; 25] , grid_router_vein_gap : [0.0 ; 25] , grid_router_vein_ridged : [0.0 ; 25] , grid_router_vein_toggle : [0.0 ; 25] , } } # [doc = r" Pre-compute flat-cached values for all quart positions in a chunk."] # [doc = r""] # [doc = r" After this call, `ensure()` for in-bounds positions copies from"] # [doc = r" the grid (O(1)). Out-of-bounds positions fall back to on-the-fly"] # [doc = r" evaluation at raw (non-quantized) coordinates."] pub fn init_grid (& mut self , chunk_block_x : i32 , chunk_block_z : i32 , noises : & NetherNoises) { self . grid_first_quart_x = chunk_block_x >> 2 ; self . grid_first_quart_z = chunk_block_z >> 2 ; self . has_grid = true ; self . valid = false ; for rel_z in 0 .. Self :: GRID_SIDE { for rel_x in 0 .. Self :: GRID_SIDE { let x = ((self . grid_first_quart_x + rel_x) << 2) as f64 ; let z = ((self . grid_first_quart_z + rel_z) << 2) as f64 ; let idx = (rel_z * Self :: GRID_SIDE + rel_x) as usize ; let val = compute_router_barrier (noises , & * self , x , z) ; self . router_barrier = val ; let val = compute_router_continentalness (noises , & * self , x , z) ; self . router_continentalness = val ; let val = compute_router_depth (noises , & * self , x , z) ; self . router_depth = val ; let val = compute_router_erosion (noises , & * self , x , z) ; self . router_erosion = val ; let val = compute_router_fluid_level_floodedness (noises , & * self , x , z) ; self . router_fluid_level_floodedness = val ; let val = compute_router_fluid_level_spread (noises , & * self , x , z) ; self . router_fluid_level_spread = val ; let val = compute_router_lava (noises , & * self , x , z) ; self . router_lava = val ; let val = compute_router_preliminary_surface_level (noises , & * self , x , z) ; self . router_preliminary_surface_level = val ; let val = compute_router_ridges (noises , & * self , x , z) ; self . router_ridges = val ; let val = compute_router_temperature (noises , & * self , x , z) ; self . router_temperature = val ; let val = compute_router_vegetation (noises , & * self , x , z) ; self . router_vegetation = val ; let val = compute_router_vein_gap (noises , & * self , x , z) ; self . router_vein_gap = val ; let val = compute_router_vein_ridged (noises , & * self , x , z) ; self . router_vein_ridged = val ; let val = compute_router_vein_toggle (noises , & * self , x , z) ; self . router_vein_toggle = val ; self . grid_router_barrier [idx] = self . router_barrier ; self . grid_router_continentalness [idx] = self . router_continentalness ; self . grid_router_depth [idx] = self . router_depth ; self . grid_router_erosion [idx] = self . router_erosion ; self . grid_router_fluid_level_floodedness [idx] = self . router_fluid_level_floodedness ; self . grid_router_fluid_level_spread [idx] = self . router_fluid_level_spread ; self . grid_router_lava [idx] = self . router_lava ; self . grid_router_preliminary_surface_level [idx] = self . router_preliminary_surface_level ; self . grid_router_ridges [idx] = self . router_ridges ; self . grid_router_temperature [idx] = self . router_temperature ; self . grid_router_vegetation [idx] = self . router_vegetation ; self . grid_router_vein_gap [idx] = self . router_vein_gap ; self . grid_router_vein_ridged [idx] = self . router_vein_ridged ; self . grid_router_vein_toggle [idx] = self . router_vein_toggle ; } } } # [doc = r" Ensure the cache is populated for the given `(x, z)` block coordinates."] # [doc = r""] # [doc = r" With a grid: in-bounds positions load from the pre-computed grid,"] # [doc = r" out-of-bounds positions compute at raw (non-quantized) coordinates."] # [doc = r" Without a grid: always quantizes and lazy-computes (single-entry cache)."] pub fn ensure (& mut self , x : i32 , z : i32 , noises : & NetherNoises) { self . x = x ; self . z = z ; let quart_x = x >> 2 ; let quart_z = z >> 2 ; if self . has_grid { let rel_x = quart_x - self . grid_first_quart_x ; let rel_z = quart_z - self . grid_first_quart_z ; if rel_x >= 0 && rel_z >= 0 && rel_x < Self :: GRID_SIDE && rel_z < Self :: GRID_SIDE { let eval_x = quart_x << 2 ; let eval_z = quart_z << 2 ; if self . valid && self . qx == eval_x && self . qz == eval_z { return ; } let idx = (rel_z * Self :: GRID_SIDE + rel_x) as usize ; self . router_barrier = self . grid_router_barrier [idx] ; self . router_continentalness = self . grid_router_continentalness [idx] ; self . router_depth = self . grid_router_depth [idx] ; self . router_erosion = self . grid_router_erosion [idx] ; self . router_fluid_level_floodedness = self . grid_router_fluid_level_floodedness [idx] ; self . router_fluid_level_spread = self . grid_router_fluid_level_spread [idx] ; self . router_lava = self . grid_router_lava [idx] ; self . router_preliminary_surface_level = self . grid_router_preliminary_surface_level [idx] ; self . router_ridges = self . grid_router_ridges [idx] ; self . router_temperature = self . grid_router_temperature [idx] ; self . router_vegetation = self . grid_router_vegetation [idx] ; self . router_vein_gap = self . grid_router_vein_gap [idx] ; self . router_vein_ridged = self . grid_router_vein_ridged [idx] ; self . router_vein_toggle = self . grid_router_vein_toggle [idx] ; self . qx = eval_x ; self . qz = eval_z ; self . valid = true ; return ; } if self . valid && self . qx == x && self . qz == z { return ; } self . qx = x ; self . qz = z ; let x = x as f64 ; let z = z as f64 ; let val = compute_router_barrier (noises , & * self , x , z) ; self . router_barrier = val ; let val = compute_router_continentalness (noises , & * self , x , z) ; self . router_continentalness = val ; let val = compute_router_depth (noises , & * self , x , z) ; self . router_depth = val ; let val = compute_router_erosion (noises , & * self , x , z) ; self . router_erosion = val ; let val = compute_router_fluid_level_floodedness (noises , & * self , x , z) ; self . router_fluid_level_floodedness = val ; let val = compute_router_fluid_level_spread (noises , & * self , x , z) ; self . router_fluid_level_spread = val ; let val = compute_router_lava (noises , & * self , x , z) ; self . router_lava = val ; let val = compute_router_preliminary_surface_level (noises , & * self , x , z) ; self . router_preliminary_surface_level = val ; let val = compute_router_ridges (noises , & * self , x , z) ; self . router_ridges = val ; let val = compute_router_temperature (noises , & * self , x , z) ; self . router_temperature = val ; let val = compute_router_vegetation (noises , & * self , x , z) ; self . router_vegetation = val ; let val = compute_router_vein_gap (noises , & * self , x , z) ; self . router_vein_gap = val ; let val = compute_router_vein_ridged (noises , & * self , x , z) ; self . router_vein_ridged = val ; let val = compute_router_vein_toggle (noises , & * self , x , z) ; self . router_vein_toggle = val ; self . valid = true ; return ; } let eval_x = quart_x << 2 ; let eval_z = quart_z << 2 ; if self . valid && self . qx == eval_x && self . qz == eval_z { return ; } self . qx = eval_x ; self . qz = eval_z ; let x = eval_x as f64 ; let z = eval_z as f64 ; let val = compute_router_barrier (noises , & * self , x , z) ; self . router_barrier = val ; let val = compute_router_continentalness (noises , & * self , x , z) ; self . router_continentalness = val ; let val = compute_router_depth (noises , & * self , x , z) ; self . router_depth = val ; let val = compute_router_erosion (noises , & * self , x , z) ; self . router_erosion = val ; let val = compute_router_fluid_level_floodedness (noises , & * self , x , z) ; self . router_fluid_level_floodedness = val ; let val = compute_router_fluid_level_spread (noises , & * self , x , z) ; self . router_fluid_level_spread = val ; let val = compute_router_lava (noises , & * self , x , z) ; self . router_lava = val ; let val = compute_router_preliminary_surface_level (noises , & * self , x , z) ; self . router_preliminary_surface_level = val ; let val = compute_router_ridges (noises , & * self , x , z) ; self . router_ridges = val ; let val = compute_router_temperature (noises , & * self , x , z) ; self . router_temperature = val ; let val = compute_router_vegetation (noises , & * self , x , z) ; self . router_vegetation = val ; let val = compute_router_vein_gap (noises , & * self , x , z) ; self . router_vein_gap = val ; let val = compute_router_vein_ridged (noises , & * self , x , z) ; self . router_vein_ridged = val ; let val = compute_router_vein_toggle (noises , & * self , x , z) ; self . router_vein_toggle = val ; self . valid = true ; } } # [doc = "`minecraft:nether/base_3d_noise`"] # [inline] fn compute_nether__base_3d_noise (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { noises . blended_noise . compute (x , y , z) } # [doc = "`minecraft:nether/base_3d_noise` (SIMD form, batches 4 Y values)"] # [allow (dead_code)] # [inline] fn compute_nether__base_3d_noise_4x (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , ys : f64x4 , z : f64) -> f64x4 { { let __ys_arr = ys . to_array () ; let __r0 = { # [allow (clippy :: cast_possible_truncation)] let y = __ys_arr [0] ; noises . blended_noise . compute (x , y , z) } ; let __r1 = { # [allow (clippy :: cast_possible_truncation)] let y = __ys_arr [1] ; noises . blended_noise . compute (x , y , z) } ; let __r2 = { # [allow (clippy :: cast_possible_truncation)] let y = __ys_arr [2] ; noises . blended_noise . compute (x , y , z) } ; let __r3 = { # [allow (clippy :: cast_possible_truncation)] let y = __ys_arr [3] ; noises . blended_noise . compute (x , y , z) } ; f64x4 :: from_array ([__r0 , __r1 , __r2 , __r3]) } } # [inline] fn compute_router_barrier (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `barrier`"] # [inline] pub fn router_barrier (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_barrier } # [inline] fn compute_router_continentalness (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `continentalness`"] # [inline] pub fn router_continentalness (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_continentalness } # [inline] fn compute_router_depth (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `depth`"] # [inline] pub fn router_depth (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_depth } # [inline] fn compute_router_erosion (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `erosion`"] # [inline] pub fn router_erosion (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_erosion } # [doc = "Noise router entry: `final_density`"] # [inline] pub fn router_final_density (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { let x = cache . x as f64 ; let z = cache . z as f64 ; { let c = clamp (((0.64) * (((2.5) + (((map_clamped (y , - 8.0 , 24.0 , 0.0 , 1.0)) * (((- 2.5) + (((0.9375) + (((map_clamped (y , 104.0 , 128.0 , 1.0 , 0.0)) * (((- 0.9375) + (compute_nether__base_3d_noise (noises , cache , x , y , z))))))))))))))) , - 1.0 , 1.0) ; c / 2.0 - c * c * c / 24.0 } } # [inline] fn compute_router_fluid_level_floodedness (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `fluid_level_floodedness`"] # [inline] pub fn router_fluid_level_floodedness (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_fluid_level_floodedness } # [inline] fn compute_router_fluid_level_spread (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `fluid_level_spread`"] # [inline] pub fn router_fluid_level_spread (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_fluid_level_spread } # [inline] fn compute_router_lava (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `lava`"] # [inline] pub fn router_lava (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_lava } # [inline] fn compute_router_preliminary_surface_level (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `preliminary_surface_level`"] # [inline] pub fn router_preliminary_surface_level (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_preliminary_surface_level } # [inline] fn compute_router_ridges (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `ridges`"] # [inline] pub fn router_ridges (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_ridges } # [inline] fn compute_router_temperature (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { { let dx = 0.0 ; let dz = 0.0 ; noises . n_nether__temperature . get_value_xz (x * 0.25 + dx , z * 0.25 + dz ,) } } # [doc = "Noise router entry: `temperature`"] # [inline] pub fn router_temperature (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_temperature } # [inline] fn compute_router_vegetation (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { { let dx = 0.0 ; let dz = 0.0 ; noises . n_nether__vegetation . get_value_xz (x * 0.25 + dx , z * 0.25 + dz ,) } } # [doc = "Noise router entry: `vegetation`"] # [inline] pub fn router_vegetation (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_vegetation } # [inline] fn compute_router_vein_gap (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `vein_gap`"] # [inline] pub fn router_vein_gap (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_vein_gap } # [inline] fn compute_router_vein_ridged (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `vein_ridged`"] # [inline] pub fn router_vein_ridged (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_vein_ridged } # [inline] fn compute_router_vein_toggle (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , z : f64) -> f64 { 0.0 } # [doc = "Noise router entry: `vein_toggle`"] # [inline] pub fn router_vein_toggle (noises : & NetherNoises , cache : & NetherColumnCache , x : f64 , y : f64 , z : f64) -> f64 { cache . router_vein_toggle } # [doc = r" Total number of independently interpolated channels across all"] # [doc = r" router entries (final_density + vein_toggle + vein_ridged)."] pub const INTERPOLATED_COUNT : usize = 1 ; # [doc = r" Whether vein functions have interpolation channels."] pub const VEIN_INTERP_ENABLED : bool = false ; # [doc = r" Evaluate the inner functions of all `Interpolated` markers at a cell corner."] # [doc = r""] # [doc = r" `out` must have length `INTERPOLATED_COUNT`."] # [expect (unused_variables , reason = "generated function has a fixed signature; blended_noise_value is unused in dimensions without blended noise")] pub fn fill_cell_corner_densities (noises : & NetherNoises , cache : & NetherColumnCache , x : i32 , y : i32 , z : i32 , blended_noise_value : f64 , out : & mut [f64] ,) { let x = cache . x as f64 ; let z = cache . z as f64 ; let y = y as f64 ; out [0] = ((0.64) * (((2.5) + (((map_clamped (y , - 8.0 , 24.0 , 0.0 , 1.0)) * (((- 2.5) + (((0.9375) + (((map_clamped (y , 104.0 , 128.0 , 1.0 , 0.0)) * (((- 0.9375) + (blended_noise_value)))))))))))))) ; } # [doc = r" SIMD form of [`fill_cell_corner_densities`] that batches 4"] # [doc = r" cell-corner Y values at fixed `(x, z)`."] # [doc = r""] # [doc = r" `out` layout: lane-major SoA. Lane `i`'s `INTERPOLATED_COUNT`"] # [doc = r" channels live at `out[i * INTERPOLATED_COUNT..(i + 1) * INTERPOLATED_COUNT]`."] # [doc = r" `out` must have length `4 * INTERPOLATED_COUNT`."] # [doc = r""] # [doc = r" Per-lane semantics are bit-identical to four scalar"] # [doc = r" [`fill_cell_corner_densities`] calls at the same Y values."] # [expect (unused_variables , reason = "generated function has a fixed signature; not all dimensions use every parameter")] pub fn fill_cell_corner_densities_4x (noises : & NetherNoises , cache : & NetherColumnCache , x : i32 , ys : f64x4 , z : i32 , blended_noise_value_v : f64x4 , out : & mut [f64] ,) { let x = cache . x as f64 ; let z = cache . z as f64 ; { let __r = ((f64x4 :: splat (0.64)) * (((f64x4 :: splat (2.5)) + ((({ let __t = (ys - f64x4 :: splat (- 8.0)) / f64x4 :: splat (24.0 - - 8.0) ; let __min = f64x4 :: splat (0.0) ; let __max = f64x4 :: splat (1.0) ; let __lerped = __min + __t * (__max - __min) ; let __below = __t . simd_lt (f64x4 :: splat (0.0)) ; let __above = __t . simd_gt (f64x4 :: splat (1.0)) ; let __r = __above . select (__max , __lerped) ; __below . select (__min , __r) }) * (((f64x4 :: splat (- 2.5)) + (((f64x4 :: splat (0.9375)) + ((({ let __t = (ys - f64x4 :: splat (104.0)) / f64x4 :: splat (128.0 - 104.0) ; let __min = f64x4 :: splat (1.0) ; let __max = f64x4 :: splat (0.0) ; let __lerped = __min + __t * (__max - __min) ; let __below = __t . simd_lt (f64x4 :: splat (0.0)) ; let __above = __t . simd_gt (f64x4 :: splat (1.0)) ; let __r = __above . select (__max , __lerped) ; __below . select (__min , __r) }) * (((f64x4 :: splat (- 0.9375)) + (blended_noise_value_v)))))))))))))) ; out [0] = __r [0] ; out [0 + INTERPOLATED_COUNT] = __r [1] ; out [0 + 2 * INTERPOLATED_COUNT] = __r [2] ; out [0 + 3 * INTERPOLATED_COUNT] = __r [3] ; } } # [doc = r" Combine interpolated values for `final_density`."] # [expect (unused_variables , reason = "generated function has a fixed signature; not all parameters are used in every dimension")] pub fn combine_interpolated (noises : & NetherNoises , cache : & NetherColumnCache , interpolated : & [f64] , _x : i32 , y : i32 , _z : i32 ,) -> f64 { let x = cache . x as f64 ; let z = cache . z as f64 ; let y = y as f64 ; { let c = clamp (interpolated [0] , - 1.0 , 1.0) ; c / 2.0 - c * c * c / 24.0 } } # [doc = r" Combine interpolated values for `vein_toggle`."] # [expect (unused_variables , reason = "generated function has a fixed signature; not all parameters are used in every dimension")] pub fn combine_vein_toggle (noises : & NetherNoises , cache : & NetherColumnCache , interpolated : & [f64] , _x : i32 , y : i32 , _z : i32 ,) -> f64 { let x = cache . x as f64 ; let z = cache . z as f64 ; let y = y as f64 ; 0.0 } # [doc = r" Combine interpolated values for `vein_ridged`."] # [expect (unused_variables , reason = "generated function has a fixed signature; not all parameters are used in every dimension")] pub fn combine_vein_ridged (noises : & NetherNoises , cache : & NetherColumnCache , interpolated : & [f64] , _x : i32 , y : i32 , _z : i32 ,) -> f64 { let x = cache . x as f64 ; let z = cache . z as f64 ; let y = y as f64 ; 0.0 } # [doc = r" Noise settings for this dimension, parsed from the datapack."] pub struct NetherNoiseSettings ; impl NetherNoiseSettings { # [doc = r" Minimum Y coordinate for this dimension."] pub const MIN_Y : i32 = 0i32 ; # [doc = r" Total height of the world in blocks."] pub const HEIGHT : i32 = 128i32 ; # [doc = r" Sea level Y coordinate."] pub const SEA_LEVEL : i32 = 32i32 ; # [doc = r" Cell width in blocks (XZ)."] pub const CELL_WIDTH : i32 = 4i32 ; # [doc = r" Cell height in blocks (Y)."] pub const CELL_HEIGHT : i32 = 8i32 ; # [doc = r" Whether aquifers are enabled."] pub const AQUIFERS_ENABLED : bool = false ; # [doc = r" Whether ore veins are enabled."] pub const ORE_VEINS_ENABLED : bool = false ; # [doc = r" Whether this dimension uses Java's LCG random (true) or Xoroshiro (false)."] pub const LEGACY_RANDOM_SOURCE : bool = true ; # [doc = r" Get the default block state ID for this dimension."] # [inline] pub fn default_block_id () -> steel_utils :: BlockStateId { steel_registry :: REGISTRY . blocks . get_default_state_id (& steel_registry :: vanilla_blocks :: NETHERRACK) } # [doc = r" Get the default fluid state ID for this dimension."] # [inline] pub fn default_fluid_id () -> steel_utils :: BlockStateId { steel_registry :: REGISTRY . blocks . get_default_state_id (& steel_registry :: vanilla_blocks :: LAVA) } } impl steel_worldgen :: density :: NoiseSettings for NetherNoiseSettings { const MIN_Y : i32 = 0i32 ; const HEIGHT : i32 = 128i32 ; const SEA_LEVEL : i32 = 32i32 ; const CELL_WIDTH : i32 = 4i32 ; const CELL_HEIGHT : i32 = 8i32 ; const AQUIFERS_ENABLED : bool = false ; const ORE_VEINS_ENABLED : bool = false ; const LEGACY_RANDOM_SOURCE : bool = true ; # [inline] fn default_block_id () -> steel_utils :: BlockStateId { NetherNoiseSettings :: default_block_id () } # [inline] fn default_fluid_id () -> steel_utils :: BlockStateId { NetherNoiseSettings :: default_fluid_id () } } impl Default for NetherColumnCache { fn default () -> Self { Self :: new () } } impl steel_worldgen :: density :: ColumnCache for NetherColumnCache { type Noises = NetherNoises ; # [inline] fn ensure (& mut self , x : i32 , z : i32 , noises : & Self :: Noises) { NetherColumnCache :: ensure (self , x , z , noises) } # [inline] fn init_grid (& mut self , chunk_block_x : i32 , chunk_block_z : i32 , noises : & Self :: Noises) { NetherColumnCache :: init_grid (self , chunk_block_x , chunk_block_z , noises) } } impl steel_worldgen :: density :: DimensionNoises for NetherNoises { type ColumnCache = NetherColumnCache ; type Settings = NetherNoiseSettings ; fn create (seed : u64 , splitter : & steel_utils :: random :: RandomSplitter , params : & rustc_hash :: FxHashMap < String , steel_worldgen :: density :: NoiseParameters > ,) -> Self { NetherNoises :: create (seed , splitter , params) } # [inline] fn router_final_density (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_final_density (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_depth (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_depth (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_barrier (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_barrier (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_fluid_level_floodedness (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_fluid_level_floodedness (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_fluid_level_spread (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_fluid_level_spread (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_lava (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_lava (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_vein_toggle (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_vein_toggle (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_vein_ridged (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_vein_ridged (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_vein_gap (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_vein_gap (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_erosion (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_erosion (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_continentalness (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_continentalness (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_temperature (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_temperature (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_vegetation (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_vegetation (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_ridges (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_ridges (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn router_preliminary_surface_level (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32) -> f64 { router_preliminary_surface_level (self , cache , x as f64 , y as f64 , z as f64) } # [inline] fn interpolated_count () -> usize { INTERPOLATED_COUNT } fn vein_interp_enabled () -> bool { VEIN_INTERP_ENABLED } # [inline] fn compute_noise_column (& self , x : i32 , block_ys : & [i32] , z : i32 , out : & mut [f64]) { self . blended_noise . compute_column (x , block_ys , z , out) ; } # [inline] fn fill_cell_corner_densities (& self , cache : & mut Self :: ColumnCache , x : i32 , y : i32 , z : i32 , blended_noise_value : f64 , out : & mut [f64]) { fill_cell_corner_densities (self , cache , x , y , z , blended_noise_value , out) } # [inline] fn fill_cell_corner_densities_4x (& self , cache : & mut Self :: ColumnCache , x : i32 , ys : std :: simd :: f64x4 , z : i32 , blended_noise_values : std :: simd :: f64x4 , out : & mut [f64] ,) { fill_cell_corner_densities_4x (self , cache , x , ys , z , blended_noise_values , out) } # [inline] fn combine_interpolated (& self , cache : & mut Self :: ColumnCache , interpolated : & [f64] , x : i32 , y : i32 , z : i32) -> f64 { combine_interpolated (self , cache , interpolated , x , y , z) } # [inline] fn combine_vein_toggle (& self , cache : & mut Self :: ColumnCache , interpolated : & [f64] , x : i32 , y : i32 , z : i32) -> f64 { combine_vein_toggle (self , cache , interpolated , x , y , z) } # [inline] fn combine_vein_ridged (& self , cache : & mut Self :: ColumnCache , interpolated : & [f64] , x : i32 , y : i32 , z : i32) -> f64 { combine_vein_ridged (self , cache , interpolated , x , y , z) } fn surface_noise_ids () -> & 'static [& 'static str] { & ["minecraft:patch" , "minecraft:nether_state_selector" , "minecraft:netherrack" , "minecraft:nether_wart" , "minecraft:soul_sand_layer" , "minecraft:gravel_layer"] } fn surface_gradient_ids () -> & 'static [& 'static str] { & ["minecraft:bedrock_floor" , "minecraft:bedrock_roof"] } fn surface_rule_block_states () -> & 'static [steel_utils :: BlockStateId] { { static BLOCK_STATES : std :: sync :: OnceLock < Box < [steel_utils :: BlockStateId] >> = std :: sync :: OnceLock :: new () ; BLOCK_STATES . get_or_init (|| { Box :: from ([steel_registry :: vanilla_blocks :: BEDROCK . default_state () , steel_registry :: vanilla_blocks :: NETHERRACK . default_state () , steel_registry :: vanilla_blocks :: BASALT . default_state () , steel_registry :: vanilla_blocks :: GRAVEL . default_state () , steel_registry :: vanilla_blocks :: BLACKSTONE . default_state () , steel_registry :: vanilla_blocks :: SOUL_SAND . default_state () , steel_registry :: vanilla_blocks :: SOUL_SOIL . default_state () , steel_registry :: vanilla_blocks :: LAVA . default_state () , steel_registry :: vanilla_blocks :: WARPED_WART_BLOCK . default_state () , steel_registry :: vanilla_blocks :: WARPED_NYLIUM . default_state () , steel_registry :: vanilla_blocks :: NETHER_WART_BLOCK . default_state () , steel_registry :: vanilla_blocks :: CRIMSON_NYLIUM . default_state ()]) }) } } fn surface_rule_uses_biome () -> bool { true } fn surface_rule_uses_preliminary_surface () -> bool { false } fn surface_rule_uses_surface_secondary () -> bool { false } fn surface_rule_uses_steep () -> bool { false } fn try_apply_surface_rule (ctx : & mut steel_worldgen :: surface :: SurfaceRuleContext < '_ > ,) -> Option < steel_utils :: BlockStateId > { Self :: apply_surface_rule_impl (ctx) } } impl NetherNoises { # [doc = r" Apply this dimension's surface rule at the current context position."] # [allow (clippy :: collapsible_if , clippy :: needless_return , clippy :: erasing_op , unused_comparisons)] fn apply_surface_rule_impl (ctx : & mut steel_worldgen :: surface :: SurfaceRuleContext < '_ > ,) -> Option < steel_utils :: BlockStateId > { if ctx . system . vertical_gradient (0usize , ctx . block_x , ctx . block_y , ctx . block_z , 0i32 , 5i32) { return Some (ctx . block_state (0usize)) ; } if ! (ctx . system . vertical_gradient (1usize , ctx . block_x , ctx . block_y , ctx . block_z , 122i32 , 127i32)) { return Some (ctx . block_state (0usize)) ; } if ctx . block_y >= 122i32 + ctx . surface_depth * 0i32 { return Some (ctx . block_state (1usize)) ; } if ctx . known_biome_id () . is_some_and (| biome_id | biome_id == steel_registry :: RegistryEntry :: id (& * steel_registry :: vanilla_biomes :: BASALT_DELTAS) as u16) { if ctx . stone_depth_below <= 1 + 0i32 + ctx . surface_depth { return Some (ctx . block_state (2usize)) ; } if ctx . stone_depth_above <= 1 + 0i32 + ctx . surface_depth { if { let v = ctx . condition_noise (0usize) ; v >= - 0.012f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { if ctx . block_y + ctx . stone_depth_above >= 30i32 + ctx . surface_depth * 0i32 { if ! (ctx . block_y + ctx . stone_depth_above >= 35i32 + ctx . surface_depth * 0i32) { return Some (ctx . block_state (3usize)) ; } } } if { let v = ctx . condition_noise (1usize) ; v >= 0f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { return Some (ctx . block_state (2usize)) ; } return Some (ctx . block_state (4usize)) ; } } if ctx . known_biome_id () . is_some_and (| biome_id | biome_id == steel_registry :: RegistryEntry :: id (& * steel_registry :: vanilla_biomes :: SOUL_SAND_VALLEY) as u16) { if ctx . stone_depth_below <= 1 + 0i32 + ctx . surface_depth { if { let v = ctx . condition_noise (1usize) ; v >= 0f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { return Some (ctx . block_state (5usize)) ; } return Some (ctx . block_state (6usize)) ; } if ctx . stone_depth_above <= 1 + 0i32 + ctx . surface_depth { if { let v = ctx . condition_noise (0usize) ; v >= - 0.012f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { if ctx . block_y + ctx . stone_depth_above >= 30i32 + ctx . surface_depth * 0i32 { if ! (ctx . block_y + ctx . stone_depth_above >= 35i32 + ctx . surface_depth * 0i32) { return Some (ctx . block_state (3usize)) ; } } } if { let v = ctx . condition_noise (1usize) ; v >= 0f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { return Some (ctx . block_state (5usize)) ; } return Some (ctx . block_state (6usize)) ; } } if ctx . stone_depth_above <= 1 + 0i32 { if ! (ctx . block_y >= 32i32 + ctx . surface_depth * 0i32) { if ctx . surface_depth <= 0 { return Some (ctx . block_state (7usize)) ; } } if ctx . known_biome_id () . is_some_and (| biome_id | biome_id == steel_registry :: RegistryEntry :: id (& * steel_registry :: vanilla_biomes :: WARPED_FOREST) as u16) { if ! ({ let v = ctx . condition_noise (2usize) ; v >= 0.54f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 }) { if ctx . block_y >= 31i32 + ctx . surface_depth * 0i32 { if { let v = ctx . condition_noise (3usize) ; v >= 1.17f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { return Some (ctx . block_state (8usize)) ; } return Some (ctx . block_state (9usize)) ; } } } if ctx . known_biome_id () . is_some_and (| biome_id | biome_id == steel_registry :: RegistryEntry :: id (& * steel_registry :: vanilla_biomes :: CRIMSON_FOREST) as u16) { if ! ({ let v = ctx . condition_noise (2usize) ; v >= 0.54f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 }) { if ctx . block_y >= 31i32 + ctx . surface_depth * 0i32 { if { let v = ctx . condition_noise (3usize) ; v >= 1.17f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { return Some (ctx . block_state (10usize)) ; } return Some (ctx . block_state (11usize)) ; } } } } if ctx . known_biome_id () . is_some_and (| biome_id | biome_id == steel_registry :: RegistryEntry :: id (& * steel_registry :: vanilla_biomes :: NETHER_WASTES) as u16) { if ctx . stone_depth_above <= 1 + 0i32 + ctx . surface_depth { if { let v = ctx . condition_noise (4usize) ; v >= - 0.012f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { if ! (ctx . surface_depth <= 0) { if ctx . block_y + ctx . stone_depth_above >= 30i32 + ctx . surface_depth * 0i32 { if ! (ctx . block_y + ctx . stone_depth_above >= 35i32 + ctx . surface_depth * 0i32) { return Some (ctx . block_state (5usize)) ; } } } return Some (ctx . block_state (1usize)) ; } } if ctx . stone_depth_above <= 1 + 0i32 { if ctx . block_y >= 31i32 + ctx . surface_depth * 0i32 { if ! (ctx . block_y + ctx . stone_depth_above >= 35i32 + ctx . surface_depth * 0i32) { if { let v = ctx . condition_noise (5usize) ; v >= - 0.012f64 && v <= 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f64 } { if ctx . block_y >= 32i32 + ctx . surface_depth * 0i32 { return Some (ctx . block_state (3usize)) ; } if ! (ctx . surface_depth <= 0) { return Some (ctx . block_state (3usize)) ; } } } } } } return Some (ctx . block_state (1usize)) ; None } }