Revert "feat: Add Mineshaft Generation (#2740)"
This commit is contained in:
parent
a748aae07e
commit
0050576be4
@ -217,7 +217,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => Self::Xoroshiro(x.split()),
|
||||
Self::Legacy(l) => Self::Legacy(l.split()),
|
||||
Self::WorldgenXoroshiro(w) => Self::WorldgenXoroshiro(w.split()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +225,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => RandomDeriver::Xoroshiro(x.next_splitter()),
|
||||
Self::Legacy(l) => l.next_splitter(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_splitter(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,7 +233,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_i32(),
|
||||
Self::Legacy(l) => l.next_i32(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_i32(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +241,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_bounded_i32(bound),
|
||||
Self::Legacy(l) => l.next_bounded_i32(bound),
|
||||
Self::WorldgenXoroshiro(w) => w.next_bounded_i32(bound),
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +249,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_i64(),
|
||||
Self::Legacy(l) => l.next_i64(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_i64(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +257,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_bool(),
|
||||
Self::Legacy(l) => l.next_bool(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_bool(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +265,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_f32(),
|
||||
Self::Legacy(l) => l.next_f32(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_f32(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +273,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_f64(),
|
||||
Self::Legacy(l) => l.next_f64(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_f64(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +281,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.next_gaussian(),
|
||||
Self::Legacy(l) => l.next_gaussian(),
|
||||
Self::WorldgenXoroshiro(w) => w.next_gaussian(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +289,6 @@ impl RandomImpl for RandomGenerator {
|
||||
match self {
|
||||
Self::Xoroshiro(x) => x.skip(count),
|
||||
Self::Legacy(l) => l.skip(count),
|
||||
Self::WorldgenXoroshiro(w) => w.skip(count),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,27 @@ use pumpkin_config::lighting::LightingEngineConfig;
|
||||
use super::{Cache, Chunk, StagedChunkEnum};
|
||||
|
||||
pub fn generate_single_chunk(
|
||||
dimension: &Dimension,
|
||||
biome_mixer_seed: i64,
|
||||
generator: &WorldGenerator,
|
||||
block_registry: &dyn WorldPortalExt,
|
||||
chunk_x: i32,
|
||||
chunk_z: i32,
|
||||
target_stage: StagedChunkEnum,
|
||||
) -> Chunk {
|
||||
generate_single_chunk_with_radius(
|
||||
dimension,
|
||||
biome_mixer_seed,
|
||||
generator,
|
||||
block_registry,
|
||||
chunk_x,
|
||||
chunk_z,
|
||||
target_stage,
|
||||
target_stage.get_direct_radius(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn generate_single_chunk_with_radius(
|
||||
_dimension: &Dimension,
|
||||
_biome_mixer_seed: i64,
|
||||
generator: &WorldGenerator,
|
||||
@ -15,9 +36,8 @@ pub fn generate_single_chunk(
|
||||
chunk_x: i32,
|
||||
chunk_z: i32,
|
||||
target_stage: StagedChunkEnum,
|
||||
radius: i32,
|
||||
) -> Chunk {
|
||||
let radius = target_stage.get_direct_radius();
|
||||
|
||||
let mut cache = Cache::new(chunk_x - radius, chunk_z - radius, radius * 2 + 1);
|
||||
|
||||
for dx in -radius..=radius {
|
||||
@ -49,12 +69,26 @@ pub fn generate_single_chunk(
|
||||
break;
|
||||
}
|
||||
|
||||
cache.advance(
|
||||
if matches!(
|
||||
stage,
|
||||
generator,
|
||||
block_registry,
|
||||
&LightingEngineConfig::Default,
|
||||
);
|
||||
StagedChunkEnum::Biomes
|
||||
| StagedChunkEnum::StructureStart
|
||||
| StagedChunkEnum::StructureReferences
|
||||
) {
|
||||
cache.advance_all(
|
||||
stage,
|
||||
generator,
|
||||
block_registry,
|
||||
&LightingEngineConfig::Default,
|
||||
);
|
||||
} else {
|
||||
cache.advance(
|
||||
stage,
|
||||
generator,
|
||||
block_registry,
|
||||
&LightingEngineConfig::Default,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mid = ((cache.size * cache.size) >> 1) as usize;
|
||||
@ -66,7 +100,9 @@ mod tests {
|
||||
use crate::biome::hash_seed;
|
||||
use crate::chunk::ChunkHeightmapType;
|
||||
use crate::chunk_system::Chunk;
|
||||
use crate::chunk_system::{StagedChunkEnum, generate_single_chunk};
|
||||
use crate::chunk_system::{
|
||||
StagedChunkEnum, generate_single_chunk, generation::generate_single_chunk_with_radius,
|
||||
};
|
||||
use crate::generation::get_world_gen;
|
||||
use crate::world::WorldPortalExt;
|
||||
use pumpkin_data::BlockStateId;
|
||||
@ -214,7 +250,7 @@ mod tests {
|
||||
let biome_mixer_seed = hash_seed(world_gen.seed());
|
||||
|
||||
// Vanilla 26.2 locates seed 0's nearest outpost at block 576, 1648.
|
||||
let chunk = generate_single_chunk(
|
||||
let chunk = generate_single_chunk_with_radius(
|
||||
&dimension,
|
||||
biome_mixer_seed,
|
||||
&world_gen,
|
||||
@ -222,6 +258,7 @@ mod tests {
|
||||
35,
|
||||
103,
|
||||
StagedChunkEnum::Spawn,
|
||||
16,
|
||||
);
|
||||
let super::Chunk::Proto(chunk) = chunk else {
|
||||
panic!("spawn stage should return a proto chunk");
|
||||
@ -265,7 +302,7 @@ mod tests {
|
||||
let block_registry = Arc::new(BlockRegistry);
|
||||
let world_gen = get_world_gen(seed, dimension.clone(), false, Vec::new(), String::new());
|
||||
let biome_mixer_seed = hash_seed(world_gen.seed());
|
||||
let chunk = generate_single_chunk(
|
||||
let chunk = generate_single_chunk_with_radius(
|
||||
&dimension,
|
||||
biome_mixer_seed,
|
||||
&world_gen,
|
||||
@ -273,6 +310,7 @@ mod tests {
|
||||
-306,
|
||||
-275,
|
||||
StagedChunkEnum::Features,
|
||||
16,
|
||||
);
|
||||
let Chunk::Proto(chunk) = chunk else {
|
||||
panic!("features stage should return a proto chunk");
|
||||
|
||||
@ -338,6 +338,63 @@ impl GenerationCache for Cache {
|
||||
}
|
||||
|
||||
impl Cache {
|
||||
pub fn advance_all(
|
||||
&mut self,
|
||||
stage: StagedChunkEnum,
|
||||
generator: &generator::WorldGenerator,
|
||||
block_registry: &dyn WorldPortalExt,
|
||||
lighting_config: &LightingEngineConfig,
|
||||
) {
|
||||
for index in 0..self.chunks.len() {
|
||||
self.advance_index(index, stage, generator, block_registry, lighting_config);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn advance_index(
|
||||
&mut self,
|
||||
index: usize,
|
||||
stage: StagedChunkEnum,
|
||||
generator: &generator::WorldGenerator,
|
||||
_block_registry: &dyn WorldPortalExt,
|
||||
_lighting_config: &LightingEngineConfig,
|
||||
) {
|
||||
match &self.chunks[index] {
|
||||
Chunk::Level(_) => return,
|
||||
Chunk::Proto(chunk) if chunk.stage >= stage => return,
|
||||
Chunk::Proto(_) => {}
|
||||
}
|
||||
match stage {
|
||||
StagedChunkEnum::Empty => panic!("empty stage"),
|
||||
StagedChunkEnum::StructureStart => match generator {
|
||||
generator::WorldGenerator::Noise(noise_gen) => {
|
||||
self.chunks[index]
|
||||
.get_proto_chunk_mut()
|
||||
.set_structure_starts(noise_gen);
|
||||
}
|
||||
generator::WorldGenerator::Flat(_) => {}
|
||||
},
|
||||
StagedChunkEnum::StructureReferences => match generator {
|
||||
generator::WorldGenerator::Noise(noise_gen) => {
|
||||
self.chunks[index]
|
||||
.get_proto_chunk_mut()
|
||||
.set_structure_references(noise_gen);
|
||||
}
|
||||
generator::WorldGenerator::Flat(_) => {}
|
||||
},
|
||||
StagedChunkEnum::Biomes => match generator {
|
||||
generator::WorldGenerator::Noise(noise_gen) => {
|
||||
self.chunks[index]
|
||||
.get_proto_chunk_mut()
|
||||
.step_to_biomes(noise_gen);
|
||||
}
|
||||
generator::WorldGenerator::Flat(flat_gen) => {
|
||||
flat_gen.step_to_biomes(self.chunks[index].get_proto_chunk_mut());
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn new(x: i32, z: i32, size: i32) -> Self {
|
||||
Self {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use crate::generation::structure::placement::GlobalStructureCache;
|
||||
use std::sync::Arc;
|
||||
|
||||
use pumpkin_data::block_properties::is_air;
|
||||
@ -1260,6 +1261,7 @@ impl ProtoChunk {
|
||||
if set.structures.len() == 1 {
|
||||
if let Some(entry) = set.structures.first() {
|
||||
self.try_set_structure_start(
|
||||
global_cache,
|
||||
settings.sea_level,
|
||||
entry,
|
||||
random_config,
|
||||
@ -1291,6 +1293,7 @@ impl ProtoChunk {
|
||||
let selected_entry = &candidates[selected_idx];
|
||||
|
||||
if self.try_set_structure_start(
|
||||
global_cache,
|
||||
settings.sea_level,
|
||||
selected_entry,
|
||||
random_config,
|
||||
@ -1308,19 +1311,29 @@ impl ProtoChunk {
|
||||
|
||||
fn try_set_structure_start(
|
||||
&mut self,
|
||||
global_cache: &GlobalStructureCache,
|
||||
sea_level: i32,
|
||||
entry: &WeightedEntry,
|
||||
random_config: &GlobalRandomConfig,
|
||||
height_sampler: &mut dyn crate::generation::structure::structures::HeightSampler,
|
||||
) -> bool {
|
||||
let structure = Structure::get(&entry.structure);
|
||||
let position = try_generate_structure(
|
||||
&entry.structure,
|
||||
structure,
|
||||
random_config.seed as i64,
|
||||
self,
|
||||
sea_level,
|
||||
Some(height_sampler),
|
||||
let chunk_x = self.x;
|
||||
let chunk_z = self.z;
|
||||
let position = global_cache.get_or_compute_structure_start(
|
||||
entry.structure,
|
||||
chunk_x,
|
||||
chunk_z,
|
||||
|| {
|
||||
let structure = Structure::get(&entry.structure);
|
||||
try_generate_structure(
|
||||
&entry.structure,
|
||||
structure,
|
||||
random_config.seed as i64,
|
||||
self,
|
||||
sea_level,
|
||||
Some(height_sampler),
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
if let Some(pos) = position {
|
||||
|
||||
@ -202,11 +202,7 @@ mod test {
|
||||
mismatches += 1;
|
||||
}
|
||||
}
|
||||
let allowed_mismatches = if dimension == Dimension::THE_NETHER {
|
||||
850
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let allowed_mismatches = 1060;
|
||||
assert!(
|
||||
mismatches <= allowed_mismatches,
|
||||
"[{test_name}] Chunk surface generation mismatches vanilla! (got {mismatches} mismatches, allowed {allowed_mismatches})"
|
||||
|
||||
@ -582,7 +582,7 @@ impl StructurePiecesCollector {
|
||||
chunk.bottom_y() as i32,
|
||||
chunk_z,
|
||||
chunk_x + 15,
|
||||
chunk.bottom_y() as i32 + chunk.height() as i32 - 1,
|
||||
i32::MAX,
|
||||
chunk_z + 15,
|
||||
);
|
||||
|
||||
|
||||
@ -283,7 +283,20 @@ pub(crate) fn get_block_entity_id(block_name: &str) -> Option<&'static str> {
|
||||
"minecraft:smoker" => Some("minecraft:smoker"),
|
||||
"minecraft:shulker_box" => Some("minecraft:shulker_box"),
|
||||
"minecraft:bed" => Some("minecraft:bed"),
|
||||
"minecraft:dragon_wall_head" => Some("minecraft:skull"),
|
||||
"minecraft:dragon_head"
|
||||
| "minecraft:dragon_wall_head"
|
||||
| "minecraft:skeleton_skull"
|
||||
| "minecraft:skeleton_wall_skull"
|
||||
| "minecraft:wither_skeleton_skull"
|
||||
| "minecraft:wither_skeleton_wall_skull"
|
||||
| "minecraft:zombie_head"
|
||||
| "minecraft:zombie_wall_head"
|
||||
| "minecraft:player_head"
|
||||
| "minecraft:player_wall_head"
|
||||
| "minecraft:creeper_head"
|
||||
| "minecraft:creeper_wall_head"
|
||||
| "minecraft:piglin_head"
|
||||
| "minecraft:piglin_wall_head" => Some("minecraft:skull"),
|
||||
"minecraft:sign"
|
||||
| "minecraft:oak_sign"
|
||||
| "minecraft:spruce_sign"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user