diff --git a/pumpkin-world/src/chunk_system/generation_cache.rs b/pumpkin-world/src/chunk_system/generation_cache.rs index 5c1e79b4b..4570585c4 100644 --- a/pumpkin-world/src/chunk_system/generation_cache.rs +++ b/pumpkin-world/src/chunk_system/generation_cache.rs @@ -360,8 +360,6 @@ impl Cache { self.chunks[mid].get_proto_chunk_mut().set_structure_starts( random_config, settings, - &dimension, - noise_router, global_structure_cache, ); } diff --git a/pumpkin-world/src/generation/proto_chunk.rs b/pumpkin-world/src/generation/proto_chunk.rs index 070bfe914..ffaa28c6f 100644 --- a/pumpkin-world/src/generation/proto_chunk.rs +++ b/pumpkin-world/src/generation/proto_chunk.rs @@ -764,24 +764,15 @@ impl ProtoChunk { noise_sampler.interpolate_z(local_z as f64 * delta_x_z_step); let block_z = block_z_base + local_z; - // The `cell_offset` calculations are still a good idea for clarity and correctness - // but let's confirm the values. - // block_x = start_block_x + cell_x*H + local_x - // sample_start_x = start_cell_x*H + cell_x*H = (start_cell_x+cell_x)*H - // These can be simplified. - let cell_offset_x = local_x; - let cell_offset_y = block_y - sample_start_y; - let cell_offset_z = local_z; - let block_state = noise_sampler .sample_block_state( ore_random_deriver, sample_start_x, sample_start_y, sample_start_z, - cell_offset_x, - cell_offset_y, - cell_offset_z, + local_x, + block_y - sample_start_y, + local_z, surface_height_estimate_sampler, ) .unwrap_or(self.default_block); @@ -1132,32 +1123,11 @@ impl ProtoChunk { &mut self, random_config: &GlobalRandomConfig, settings: &GenerationSettings, - dimension: &Dimension, // <-- Added Parameter - noise_router: &ProtoNoiseRouters, // <-- Added Parameter global_cache: &GlobalStructureCache, ) { let seed = random_config.seed; let calculator = StructurePlacementCalculator::new(seed as i64); - // Initialize mathematical biome tools for ConcentricRings snapping - let active_supplier = if *dimension == Dimension::THE_END { - ActiveSupplier::End(TheEndBiomeSupplier) - } else if *dimension == Dimension::THE_NETHER { - ActiveSupplier::Nether(MultiNoiseBiomeSupplier::NETHER) - } else { - ActiveSupplier::Overworld(MultiNoiseBiomeSupplier::OVERWORLD) - }; - - let base_supplier: &dyn BiomeSupplier = match &active_supplier { - ActiveSupplier::End(s) => s, - ActiveSupplier::Nether(s) => s, - ActiveSupplier::Overworld(s) => s, - }; - let biome_supplier = Blender::NO_BLEND.get_biome_supplier(base_supplier); - let multi_noise_config = MultiNoiseSamplerBuilderOptions::new(0, 0, 0); - let mut multi_noise_sampler = - MultiNoiseSampler::generate(&noise_router.multi_noise, &multi_noise_config); - for set in StructureSet::ALL { let allowed_biomes = Self::get_allowed_biomes(set); @@ -1167,8 +1137,7 @@ impl ProtoChunk { self.x, self.z, global_cache, - &biome_supplier, - &mut multi_noise_sampler, + self, &allowed_biomes, ) { continue; @@ -1305,8 +1274,7 @@ impl ProtoChunk { let strongholds = global_cache.get_or_calculate_strongholds( seed, rings, - &biome_supplier, - &mut multi_noise_sampler, + self, &allowed_biomes, ); for &(cx, cz) in strongholds { diff --git a/pumpkin-world/src/generation/structure/placement.rs b/pumpkin-world/src/generation/structure/placement.rs index bb6fb86f1..dc7d82d9f 100644 --- a/pumpkin-world/src/generation/structure/placement.rs +++ b/pumpkin-world/src/generation/structure/placement.rs @@ -12,8 +12,7 @@ use pumpkin_util::{ use std::f64::consts::PI; use std::sync::OnceLock; -use crate::biome::BiomeSupplier; -use crate::generation::noise::router::multi_noise_sampler::MultiNoiseSampler; +use crate::ProtoChunk; /// A thread-safe global cache for structures that require world-wide placement calculations /// rather than localized chunk-based math (e.g., Strongholds using Concentric Rings). /// @@ -45,8 +44,7 @@ impl GlobalStructureCache { &self, seed: i64, placement: &ConcentricRingsStructurePlacement, - biome_supplier: &dyn BiomeSupplier, - multi_noise_sampler: &mut MultiNoiseSampler, + biome_supplier: &ProtoChunk, allowed_biomes: &[u16], ) -> &[(i32, i32)] { self.stronghold_chunks.get_or_init(|| { @@ -100,12 +98,7 @@ impl GlobalStructureCache { let test_x = center_block_x + dx; let test_z = center_block_z + dz; - let biome_x = crate::generation::biome_coords::from_block(test_x); - let biome_y = crate::generation::biome_coords::from_block(0); - let biome_z = crate::generation::biome_coords::from_block(test_z); - - let biome = - biome_supplier.biome(biome_x, biome_y, biome_z, multi_noise_sampler); + let biome = biome_supplier.get_biome(test_x, 0, test_z); if allowed_biomes.contains(&(biome.id as u16)) { found_count += 1; @@ -147,15 +140,14 @@ impl Default for GlobalStructureCache { } #[must_use] -#[expect(clippy::too_many_arguments)] +// #[expect(clippy::too_many_arguments)] pub fn should_generate_structure( placement: &StructurePlacement, calculator: &StructurePlacementCalculator, chunk_x: i32, chunk_z: i32, global_cache: &GlobalStructureCache, - biome_supplier: &dyn BiomeSupplier, - multi_noise_sampler: &mut MultiNoiseSampler, + biome_supplier: &ProtoChunk, allowed_biomes: &[u16], ) -> bool { is_start_chunk( @@ -166,7 +158,6 @@ pub fn should_generate_structure( placement.salt, global_cache, biome_supplier, - multi_noise_sampler, allowed_biomes, ) && apply_frequency_reduction( placement.frequency_reduction_method, @@ -238,8 +229,7 @@ fn is_start_chunk( chunk_z: i32, salt: u32, global_cache: &GlobalStructureCache, - biome_supplier: &dyn BiomeSupplier, - multi_noise_sampler: &mut MultiNoiseSampler, + biome_supplier: &ProtoChunk, allowed_biomes: &[u16], ) -> bool { match placement_type { @@ -251,7 +241,6 @@ fn is_start_chunk( calculator.seed, placement, biome_supplier, - multi_noise_sampler, allowed_biomes, ); strongholds.contains(&(chunk_x, chunk_z)) diff --git a/pumpkin/src/item/items/end_crystal.rs b/pumpkin/src/item/items/end_crystal.rs index 4a73c00d0..b1a5006d7 100644 --- a/pumpkin/src/item/items/end_crystal.rs +++ b/pumpkin/src/item/items/end_crystal.rs @@ -10,6 +10,7 @@ use pumpkin_data::entity::EntityType; use pumpkin_data::item::Item; use pumpkin_data::item_stack::ItemStack; use pumpkin_data::{Block, BlockDirection}; +use pumpkin_util::math::boundingbox::BoundingBox; use pumpkin_util::math::position::BlockPos; use pumpkin_util::math::vector3::Vector3; @@ -40,6 +41,19 @@ impl ItemBehaviour for EndCrystalItem { } let location = location.up(); + let location_vec = location.0.to_f64(); + + if !world.get_block_state(&location).await.is_air() + || !world + .get_entities_at_box(&BoundingBox::new( + Vector3::new(location_vec.x, location_vec.y, location_vec.z), + Vector3::new(location_vec.x + 1.0, location_vec.y + 2.0, location_vec.z), + )) + .is_empty() + { + return; + } + let entity = Entity::new(world.clone(), location.to_f64(), &EntityType::END_CRYSTAL); let end_crystal = Arc::new(EndCrystalEntity::new(entity)); world.spawn_entity(end_crystal.clone()).await;