Some minor improvements

This commit is contained in:
Snowiiii 2024-12-08 23:59:52 +01:00
parent 4763fa356c
commit d0d0f35a94
15 changed files with 429 additions and 398 deletions

View File

@ -35,7 +35,7 @@ debug = true
[workspace.dependencies]
log = "0.4"
tokio = { version = "1.41", features = [
tokio = { version = "1.42", features = [
"fs",
"io-util",
"macros",

View File

@ -11,12 +11,8 @@ pub struct Deserializer<'a> {
#[derive(Debug, Error)]
pub enum DeserializerError {
#[error("Unknown Packet")]
UnknownPacket,
#[error("serializer error {0}")]
Message(String),
#[error("Stdio error {0}")]
Stdio(std::io::Error),
}
impl de::Error for DeserializerError {

View File

@ -34,7 +34,7 @@ impl ClientPacket for CCommandSuggestions<'_> {
bytebuf.put_var_int(&self.length);
bytebuf.put_list(&self.matches, |bytebuf, suggestion| {
bytebuf.put_string(suggestion.suggestion.as_str());
bytebuf.put_string(suggestion.suggestion);
bytebuf.put_bool(suggestion.tooltip.is_some());
if let Some(tooltip) = &suggestion.tooltip {
bytebuf.put_slice(&tooltip.encode());
@ -45,12 +45,12 @@ impl ClientPacket for CCommandSuggestions<'_> {
#[derive(PartialEq, Eq, Hash, Debug)]
pub struct CommandSuggestion<'a> {
pub suggestion: String,
pub suggestion: &'a str,
pub tooltip: Option<TextComponent<'a>>,
}
impl<'a> CommandSuggestion<'a> {
pub fn new(suggestion: String, tooltip: Option<TextComponent<'a>>) -> Self {
pub fn new(suggestion: &'a str, tooltip: Option<TextComponent<'a>>) -> Self {
Self {
suggestion,
tooltip,

View File

@ -8,7 +8,7 @@ pumpkin-protocol = { path = "../pumpkin-protocol" }
pumpkin-nbt = { path = "../pumpkin-nbt" }
pumpkin-core = { path = "../pumpkin-core" }
indexmap = { version = "2.6.0", features = ["serde"] }
indexmap = { version = "2.7.0", features = ["serde"] }
serde.workspace = true
serde_json.workspace = true

View File

@ -22,7 +22,6 @@ num-traits.workspace = true
num-derive.workspace = true
futures = "0.3"
dashmap = "6.1.0"
lazy_static = "1.5.0"
# Compression
flate2 = "1.0"

View File

@ -74,9 +74,7 @@ pub trait NoisePosImpl {
}
pub mod built_in_density_function {
use std::sync::Arc;
use lazy_static::lazy_static;
use std::sync::{Arc, LazyLock};
use crate::world_gen::noise::built_in_noise_params::{self};
use crate::world_gen::positions::{MAX_COLUMN_HEIGHT, MIN_HEIGHT};
@ -106,136 +104,153 @@ pub mod built_in_density_function {
use super::weird::{RarityMapper, WierdScaledFunction};
lazy_static! {
pub static ref ZERO: SharedComponentReference = ConstantFunction::new(0f64).into();
pub static ref TEN: SharedComponentReference = ConstantFunction::new(10f64).into();
pub static ref BLEND_ALPHA: SharedComponentReference = BlendAlphaFunction::INSTANCE.into();
pub static ref BLEND_OFFSET: SharedComponentReference =
BlendOffsetFunction::INSTANCE.into();
pub static ref Y: SharedComponentReference = YClampedFunction::new(
pub static ZERO: LazyLock<SharedComponentReference> =
LazyLock::new(|| ConstantFunction::new(0f64).into());
pub static TEN: LazyLock<SharedComponentReference> =
LazyLock::new(|| ConstantFunction::new(10f64).into());
pub static BLEND_ALPHA: LazyLock<SharedComponentReference> =
LazyLock::new(|| BlendAlphaFunction::INSTANCE.into());
pub static BLEND_OFFSET: LazyLock<SharedComponentReference> =
LazyLock::new(|| BlendOffsetFunction::INSTANCE.into());
pub static Y: LazyLock<SharedComponentReference> = LazyLock::new(|| {
YClampedFunction::new(
MIN_HEIGHT * 2,
MAX_COLUMN_HEIGHT as i32 * 2,
(MIN_HEIGHT * 2) as f64,
((MAX_COLUMN_HEIGHT as i32) * 2) as f64
((MAX_COLUMN_HEIGHT as i32) * 2) as f64,
)
.into();
pub static ref SHIFT_X: SharedComponentReference =
.into()
});
pub static SHIFT_X: LazyLock<SharedComponentReference> = LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftAFunction::new(Arc::new(InternalNoise::new(
&built_in_noise_params::OFFSET,
None
)))
.into(),
WrapperType::Cache2D
)
ShiftAFunction::new(Arc::new(InternalNoise::new(
&built_in_noise_params::OFFSET,
None,
)))
.into(),
WrapperType::FlatCache
WrapperType::Cache2D,
)
.into();
pub static ref SHIFT_Z: SharedComponentReference =
.into(),
WrapperType::FlatCache,
)
.into()
});
pub static SHIFT_Z: LazyLock<SharedComponentReference> = LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftBFunction::new(Arc::new(InternalNoise::new(
&built_in_noise_params::OFFSET,
None
)))
.into(),
WrapperType::Cache2D
)
ShiftBFunction::new(Arc::new(InternalNoise::new(
&built_in_noise_params::OFFSET,
None,
)))
.into(),
WrapperType::FlatCache
WrapperType::Cache2D,
)
.into();
pub static ref BASE_3D_NOISE_OVERWORLD: SharedComponentReference =
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.125f64, 80f64, 160f64, 8f64
.into(),
WrapperType::FlatCache,
)
.into()
});
pub static BASE_3D_NOISE_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.125f64, 80f64, 160f64, 8f64,
)
.into()
});
pub static BASE_3D_NOISE_NETHER: LazyLock<SharedComponentReference> = LazyLock::new(|| {
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.375f64, 80f64, 60f64, 8f64,
)
.into()
});
pub static BASE_3D_NOISE_END: LazyLock<SharedComponentReference> = LazyLock::new(|| {
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.25f64, 80f64, 160f64, 4f64,
)
.into()
});
pub static CONTINENTS_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(
&built_in_noise_params::CONTINENTALNESS,
None,
)),
)
.into();
pub static ref BASE_3D_NOISE_NETHER: SharedComponentReference =
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.375f64, 80f64, 60f64, 8f64
.into(),
WrapperType::FlatCache,
)
.into()
});
pub static EROSION_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(&built_in_noise_params::EROSION, None)),
)
.into();
pub static ref BASE_3D_NOISE_END: SharedComponentReference =
InterpolatedNoiseFunction::create_base_3d_noise_function(
0.25f64, 0.25f64, 80f64, 160f64, 4f64
.into(),
WrapperType::FlatCache,
)
.into()
});
pub static RIDGES_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(&built_in_noise_params::RIDGE, None)),
)
.into();
pub static ref CONTINENTS_OVERWORLD: SharedComponentReference =
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(
&built_in_noise_params::CONTINENTALNESS,
None
))
)
.into(),
WrapperType::FlatCache
)
.into();
pub static ref EROSION_OVERWORLD: SharedComponentReference =
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(&built_in_noise_params::EROSION, None))
)
.into(),
WrapperType::FlatCache
)
.into();
pub static ref RIDGES_OVERWORLD: SharedComponentReference =
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
SHIFT_X.clone(),
ZERO.clone(),
SHIFT_Z.clone(),
0.25f64,
0f64,
Arc::new(InternalNoise::new(&built_in_noise_params::RIDGE, None))
)
.into(),
WrapperType::FlatCache
)
.into();
pub static ref RIDGES_FOLDED_OVERWORLD: SharedComponentReference = RIDGES_OVERWORLD
.into(),
WrapperType::FlatCache,
)
.into()
});
pub static RIDGES_FOLDED_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
RIDGES_OVERWORLD
.clone()
.abs()
.add_const(-0.6666666666666666f64)
.abs()
.add_const(-0.3333333333333333f64)
.mul_const(-3f64);
static ref JAGGED_NOISE: SharedComponentReference = NoiseFunction::new(
.mul_const(-3f64)
});
static JAGGED_NOISE: LazyLock<SharedComponentReference> = LazyLock::new(|| {
NoiseFunction::new(
Arc::new(InternalNoise::new(&built_in_noise_params::JAGGED, None)),
1500f64,
0f64
0f64,
)
.into();
pub static ref OFFSET_OVERWORLD: SharedComponentReference = apply_blending(
.into()
});
pub static OFFSET_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
apply_blending(
ConstantFunction::new(-0.50375f32 as f64).add(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_offset_spline(
@ -244,13 +259,15 @@ pub mod built_in_density_function {
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into()
.into(),
)
.into()
.into(),
),
BLEND_OFFSET.clone(),
);
pub static ref FACTOR_OVERWORLD: SharedComponentReference = apply_blending(
)
});
pub static FACTOR_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_factor_spline(
CONTINENTS_OVERWORLD.clone(),
@ -259,12 +276,14 @@ pub mod built_in_density_function {
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into()
.into(),
)
.into(),
TEN.clone(),
);
pub static ref JAGGEDNESS_OVERWORLD: SharedComponentReference = apply_blending(
)
});
pub static JAGGEDNESS_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_jaggedness_spline(
CONTINENTS_OVERWORLD.clone(),
@ -273,28 +292,31 @@ pub mod built_in_density_function {
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into()
.into(),
)
.into(),
ZERO.clone(),
);
pub static ref DEPTH_OVERWORLD: SharedComponentReference =
YClampedFunction::new(-64, 320, 1.5f64, -1.5f64).add(OFFSET_OVERWORLD.clone());
pub static ref SLOPED_CHEESE_OVERWORLD: SharedComponentReference = {
let density1 = JAGGEDNESS_OVERWORLD
)
});
pub static DEPTH_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
YClampedFunction::new(-64, 320, 1.5f64, -1.5f64).add(OFFSET_OVERWORLD.clone())
});
pub static SLOPED_CHEESE_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
let density1 = JAGGEDNESS_OVERWORLD
.clone()
.mul(JAGGED_NOISE.clone().half_negative());
let density2 = ConstantFunction::new(4f64).mul(
DEPTH_OVERWORLD
.clone()
.mul(JAGGED_NOISE.clone().half_negative());
let density2 = ConstantFunction::new(4f64).mul(
DEPTH_OVERWORLD
.clone()
.add(density1)
.mul(FACTOR_OVERWORLD.clone())
.quarter_negative(),
);
.add(density1)
.mul(FACTOR_OVERWORLD.clone())
.quarter_negative(),
);
density2.add(BASE_3D_NOISE_OVERWORLD.clone())
};
pub static ref CONTINENTS_OVERWORLD_LARGE_BIOME: SharedComponentReference =
density2.add(BASE_3D_NOISE_OVERWORLD.clone())
});
pub static CONTINENTS_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
@ -309,14 +331,16 @@ pub mod built_in_density_function {
0f64,
Arc::new(InternalNoise::new(
&built_in_noise_params::CONTINENTALNESS_LARGE,
None
))
None,
)),
)
.into(),
WrapperType::FlatCache
WrapperType::FlatCache,
)
.into();
pub static ref EROSION_OVERWORLD_LARGE_BIOME: SharedComponentReference =
.into()
});
pub static EROSION_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
ShiftedNoiseFunction::<
NoEnvironment,
@ -331,60 +355,73 @@ pub mod built_in_density_function {
0f64,
Arc::new(InternalNoise::new(
&built_in_noise_params::EROSION_LARGE,
None
))
None,
)),
)
.into(),
WrapperType::FlatCache
WrapperType::FlatCache,
)
.into();
pub static ref OFFSET_OVERWORLD_LARGE_BIOME: SharedComponentReference = apply_blending(
ConstantFunction::new(-0.50375f32 as f64).add(
.into()
});
pub static OFFSET_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
ConstantFunction::new(-0.50375f32 as f64).add(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_offset_spline(
CONTINENTS_OVERWORLD_LARGE_BIOME.clone(),
EROSION_OVERWORLD_LARGE_BIOME.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into(),
)
.into(),
),
BLEND_OFFSET.clone(),
)
});
pub static FACTOR_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_offset_spline(
create_factor_spline(
CONTINENTS_OVERWORLD_LARGE_BIOME.clone(),
EROSION_OVERWORLD_LARGE_BIOME.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into()
.into(),
)
.into()
),
BLEND_OFFSET.clone()
);
pub static ref FACTOR_OVERWORLD_LARGE_BIOME: SharedComponentReference = apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_factor_spline(
CONTINENTS_OVERWORLD_LARGE_BIOME.clone(),
EROSION_OVERWORLD_LARGE_BIOME.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into()
.into(),
TEN.clone(),
)
.into(),
TEN.clone()
);
pub static ref JAGGEDNESS_OVERWORLD_LARGE_BIOME: SharedComponentReference = apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_jaggedness_spline(
CONTINENTS_OVERWORLD_LARGE_BIOME.clone(),
EROSION_OVERWORLD_LARGE_BIOME.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
false,
});
pub static JAGGEDNESS_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_jaggedness_spline(
CONTINENTS_OVERWORLD_LARGE_BIOME.clone(),
EROSION_OVERWORLD_LARGE_BIOME.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
false,
)
.into(),
)
.into()
.into(),
ZERO.clone(),
)
.into(),
ZERO.clone()
);
pub static ref DEPTH_OVERWORLD_LARGE_BIOME: SharedComponentReference =
});
pub static DEPTH_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
YClampedFunction::new(-64, 320, 1.5f64, -1.5f64)
.add(OFFSET_OVERWORLD_LARGE_BIOME.clone());
pub static ref SLOPED_CHEESE_OVERWORLD_LARGE_BIOME: SharedComponentReference = {
.add(OFFSET_OVERWORLD_LARGE_BIOME.clone())
});
pub static SLOPED_CHEESE_OVERWORLD_LARGE_BIOME: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
let density1 = JAGGEDNESS_OVERWORLD_LARGE_BIOME
.clone()
.mul(JAGGED_NOISE.clone().half_negative());
@ -397,54 +434,65 @@ pub mod built_in_density_function {
);
density2.add(BASE_3D_NOISE_OVERWORLD.clone())
};
pub static ref OFFSET_OVERWORLD_AMPLIFIED: SharedComponentReference = apply_blending(
ConstantFunction::new(-0.50375f32 as f64).add(
});
pub static OFFSET_OVERWORLD_AMPLIFIED: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
ConstantFunction::new(-0.50375f32 as f64).add(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_offset_spline(
CONTINENTS_OVERWORLD.clone(),
EROSION_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
true,
)
.into(),
)
.into(),
),
BLEND_OFFSET.clone(),
)
});
pub static FACTOR_OVERWORLD_AMPLIFIED: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_offset_spline(
create_factor_spline(
CONTINENTS_OVERWORLD.clone(),
EROSION_OVERWORLD.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
true
true,
)
.into()
.into(),
)
.into()
),
BLEND_OFFSET.clone()
);
pub static ref FACTOR_OVERWORLD_AMPLIFIED: SharedComponentReference = apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_factor_spline(
CONTINENTS_OVERWORLD.clone(),
EROSION_OVERWORLD.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
true
)
.into()
.into(),
TEN.clone(),
)
.into(),
TEN.clone()
);
pub static ref JAGGEDNESS_OVERWORLD_AMPLIFIED: SharedComponentReference = apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_jaggedness_spline(
CONTINENTS_OVERWORLD.clone(),
EROSION_OVERWORLD.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
true
});
pub static JAGGEDNESS_OVERWORLD_AMPLIFIED: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
apply_blending(
SplineFunction::<NoEnvironment, ImmutableSplineRef>::new(
create_jaggedness_spline(
CONTINENTS_OVERWORLD.clone(),
EROSION_OVERWORLD.clone(),
RIDGES_OVERWORLD.clone(),
RIDGES_FOLDED_OVERWORLD.clone(),
true,
)
.into(),
)
.into()
.into(),
ZERO.clone(),
)
.into(),
ZERO.clone()
);
pub static ref DEPTH_OVERWORLD_AMPLIFIED: SharedComponentReference =
YClampedFunction::new(-64, 320, 1.5f64, -1.5f64)
.add(OFFSET_OVERWORLD_AMPLIFIED.clone());
pub static ref SLOPED_CHEESE_OVERWORLD_AMPLIFIED: SharedComponentReference = {
});
pub static DEPTH_OVERWORLD_AMPLIFIED: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
YClampedFunction::new(-64, 320, 1.5f64, -1.5f64).add(OFFSET_OVERWORLD_AMPLIFIED.clone())
});
pub static SLOPED_CHEESE_OVERWORLD_AMPLIFIED: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
let density1 = JAGGEDNESS_OVERWORLD_AMPLIFIED
.clone()
.mul(JAGGED_NOISE.clone().half_negative());
@ -457,10 +505,11 @@ pub mod built_in_density_function {
);
density2.add(BASE_3D_NOISE_OVERWORLD.clone())
};
pub static ref SLOPED_CHEESE_END: SharedComponentReference =
EndIslandFunction::new(0).add(BASE_3D_NOISE_END.clone());
pub static ref CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_OVERWORLD: SharedComponentReference = {
});
pub static SLOPED_CHEESE_END: LazyLock<SharedComponentReference> =
LazyLock::new(|| EndIslandFunction::new(0).add(BASE_3D_NOISE_END.clone()));
pub static CAVES_SPAGHETTI_ROUGHNESS_FUNCTION_OVERWORLD: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
let function = NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::SPAGHETTI_ROUGHNESS,
@ -483,20 +532,23 @@ pub mod built_in_density_function {
WrapperType::OnceCache,
)
.into()
};
pub static ref CAVES_SPAGHETTI_2D_THICKNESS_MODULAR_OVERWORLD: SharedComponentReference =
});
pub static CAVES_SPAGHETTI_2D_THICKNESS_MODULAR_OVERWORLD: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
noise_in_range(
&built_in_noise_params::SPAGHETTI_2D_THICKNESS,
2f64,
1f64,
-0.6f64,
-1.3f64
-1.3f64,
),
WrapperType::OnceCache,
)
.into();
pub static ref CAVES_SPAGHETTI_2D_OVERWORLD: SharedComponentReference = {
.into()
});
pub static CAVES_SPAGHETTI_2D_OVERWORLD: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
let function1 = NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::SPAGHETTI_2D_MODULATOR,
@ -534,8 +586,9 @@ pub mod built_in_density_function {
let function7 = function2.add(function4.mul_const(0.083f64));
function7.max(function6).clamp(-1f64, 1f64)
};
pub static ref CAVES_ENTRANCES_OVERWORLD: SharedComponentReference = {
});
pub static CAVES_ENTRANCES_OVERWORLD: LazyLock<SharedComponentReference> =
LazyLock::new(|| {
let function_ref: SharedComponentReference =
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
NoiseFunction::new(
@ -601,115 +654,114 @@ pub mod built_in_density_function {
WrapperType::OnceCache,
)
.into()
};
pub static ref CAVES_NOODLE_OVERWORLD: SharedComponentReference = {
let function2 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(&built_in_noise_params::NOODLE, None)),
1f64,
1f64,
)
.into(),
-60,
320,
-1,
);
let function3 = vertical_range_choice(
Y.clone(),
noise_in_range(
&built_in_noise_params::NOODLE_THICKNESS,
1f64,
1f64,
-0.05f64,
-0.1f64,
),
-60,
320,
0,
);
let function4 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::NOODLE_RIDGE_A,
None,
)),
2.6666666666666665f64,
2.6666666666666665f64,
)
.into(),
-60,
320,
0,
);
let function5 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::NOODLE_RIDGE_B,
None,
)),
2.6666666666666665f64,
2.6666666666666665f64,
)
.into(),
-60,
320,
0,
);
let function6 = function4.abs().max(function5.abs()).mul_const(1.5f64);
RangeFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
function2,
-1000000f64,
0f64,
ConstantFunction::new(64f64).into(),
function3.add(function6),
});
pub static CAVES_NOODLE_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
let function2 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(&built_in_noise_params::NOODLE, None)),
1f64,
1f64,
)
.into()
};
pub static ref CAVES_PILLARS_OVERWORLD: SharedComponentReference = {
let function = NoiseFunction::new(
Arc::new(InternalNoise::new(&built_in_noise_params::PILLAR, None)),
25f64,
0.3f64,
);
.into(),
-60,
320,
-1,
);
let function2 = noise_in_range(
&built_in_noise_params::PILLAR_RARENESS,
let function3 = vertical_range_choice(
Y.clone(),
noise_in_range(
&built_in_noise_params::NOODLE_THICKNESS,
1f64,
1f64,
0f64,
-2f64,
);
-0.05f64,
-0.1f64,
),
-60,
320,
0,
);
let function3 = noise_in_range(
&built_in_noise_params::PILLAR_THICKNESS,
1f64,
1f64,
0f64,
1.1f64,
);
let function4 = function.mul_const(2f64).add(function2);
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
function4.mul(function3.cube()),
WrapperType::OnceCache,
let function4 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::NOODLE_RIDGE_A,
None,
)),
2.6666666666666665f64,
2.6666666666666665f64,
)
.into()
};
}
.into(),
-60,
320,
0,
);
let function5 = vertical_range_choice(
Y.clone(),
NoiseFunction::new(
Arc::new(InternalNoise::new(
&built_in_noise_params::NOODLE_RIDGE_B,
None,
)),
2.6666666666666665f64,
2.6666666666666665f64,
)
.into(),
-60,
320,
0,
);
let function6 = function4.abs().max(function5.abs()).mul_const(1.5f64);
RangeFunction::<
NoEnvironment,
SharedComponentReference,
SharedComponentReference,
SharedComponentReference,
>::new(
function2,
-1000000f64,
0f64,
ConstantFunction::new(64f64).into(),
function3.add(function6),
)
.into()
});
pub static CAVES_PILLARS_OVERWORLD: LazyLock<SharedComponentReference> = LazyLock::new(|| {
let function = NoiseFunction::new(
Arc::new(InternalNoise::new(&built_in_noise_params::PILLAR, None)),
25f64,
0.3f64,
);
let function2 = noise_in_range(
&built_in_noise_params::PILLAR_RARENESS,
1f64,
1f64,
0f64,
-2f64,
);
let function3 = noise_in_range(
&built_in_noise_params::PILLAR_THICKNESS,
1f64,
1f64,
0f64,
1.1f64,
);
let function4 = function.mul_const(2f64).add(function2);
WrapperFunction::<NoEnvironment, SharedComponentReference>::new(
function4.mul(function3.cube()),
WrapperType::OnceCache,
)
.into()
});
}
pub fn peaks_valleys_noise(variance: f32) -> f32 {

View File

@ -1,6 +1,4 @@
use std::sync::Arc;
use lazy_static::lazy_static;
use std::sync::{Arc, LazyLock};
use crate::world_gen::{
noise::density::{
@ -37,14 +35,12 @@ use super::{
},
};
lazy_static! {
pub static ref OVERWORLD_NOISE_ROUTER: BaseRouter =
BaseRouter::create_surface_noise_router(false, false);
pub static ref OVERWORLD_NOISE_ROUTER_LARGE: BaseRouter =
BaseRouter::create_surface_noise_router(true, false);
pub static ref OVERWORLD_NOISE_ROUTER_AMPLIFIED: BaseRouter =
BaseRouter::create_surface_noise_router(false, true);
}
pub static OVERWORLD_NOISE_ROUTER: LazyLock<BaseRouter> =
LazyLock::new(|| BaseRouter::create_surface_noise_router(false, false));
pub static OVERWORLD_NOISE_ROUTER_LARGE: LazyLock<BaseRouter> =
LazyLock::new(|| BaseRouter::create_surface_noise_router(true, false));
pub static OVERWORLD_NOISE_ROUTER_AMPLIFIED: LazyLock<BaseRouter> =
LazyLock::new(|| BaseRouter::create_surface_noise_router(false, true));
pub struct BaseRouter {
pub(crate) barrier: SharedComponentReference,

View File

@ -64,11 +64,11 @@ sha2 = "0.10.8"
# icon loading
base64 = "0.22.1"
png = "0.17.14"
png = "0.17.15"
# logging
simple_logger = { version = "5.0.0", features = ["threads"] }
time = "0.3.36"
time = "0.3.37"
# commands
async-trait = "0.1.83"

View File

@ -404,7 +404,6 @@ impl Client {
"Failed to handle client packet id {} in Status State",
packet.id.0
);
return Err(DeserializerError::UnknownPacket);
}
};
@ -479,7 +478,6 @@ impl Client {
"Failed to handle client packet id {} in Config State",
packet.id.0
);
return Err(DeserializerError::UnknownPacket);
}
};
Ok(())

View File

@ -57,7 +57,7 @@ impl ArgumentConsumer for BossbarColorArgumentConsumer {
let colors = ["blue", "green", "pink", "purple", "red", "white", "yellow"];
let suggestions: Vec<CommandSuggestion> = colors
.iter()
.map(|color| CommandSuggestion::new((*color).to_string(), None))
.map(|color| CommandSuggestion::new(color, None))
.collect();
Ok(Some(suggestions))
}

View File

@ -61,7 +61,7 @@ impl ArgumentConsumer for BossbarStyleArgumentConsumer {
];
let suggestions: Vec<CommandSuggestion> = styles
.iter()
.map(|style| CommandSuggestion::new((*style).to_string(), None))
.map(|style| CommandSuggestion::new(style, None))
.collect();
Ok(Some(suggestions))
}

View File

@ -59,7 +59,7 @@ impl ArgumentConsumer for CommandTreeArgumentConsumer {
.commands
.keys()
.filter(|suggestion| suggestion.starts_with(input))
.map(|suggestion| CommandSuggestion::new((*suggestion).to_string(), None))
.map(|suggestion| CommandSuggestion::new(suggestion, None))
.collect();
Ok(Some(suggestions))
}

View File

@ -44,17 +44,18 @@ impl ArgumentConsumer for ResourceLocationArgumentConsumer {
if !self.autocomplete {
return Ok(None);
}
// TODO
let suggestions = _server
.bossbars
.lock()
.await
.custom_bossbars
.keys()
.map(|suggestion| CommandSuggestion::new(suggestion.clone(), None))
.collect();
// let suggestions = server
// .bossbars
// .lock()
// .await
// .custom_bossbars
// .keys()
// .map(|suggestion| CommandSuggestion::new(suggestion, None))
// .collect();
Ok(Some(suggestions))
Ok(None)
}
}

View File

@ -50,10 +50,10 @@ impl CommandExecutor for CommandHelpExecutor {
TextComponent::text_string("-".repeat((52 - header_text.len()) / 2) + " ")
.color_named(NamedColor::Yellow),
)
.add_child(TextComponent::text_string(header_text.clone()))
.add_child(TextComponent::text(&header_text))
.add_child(
TextComponent::text_string(
" ".to_owned().to_string() + &"-".repeat((52 - header_text.len()) / 2) + "\n",
" ".to_owned() + &"-".repeat((52 - header_text.len()) / 2) + "\n",
)
.color_named(NamedColor::Yellow),
)
@ -168,13 +168,11 @@ impl CommandExecutor for BaseHelpExecutor {
.color_named(NamedColor::Yellow),
)
.add_child(arrow_left.clone())
.add_child(TextComponent::text_string(header_text.clone()))
.add_child(TextComponent::text(&header_text))
.add_child(arrow_right.clone())
.add_child(
TextComponent::text_string(
" ".to_owned().to_string()
+ &"-".repeat((52 - header_text.len() - 3) / 2)
+ "\n",
" ".to_owned() + &"-".repeat((52 - header_text.len() - 3) / 2) + "\n",
)
.color_named(NamedColor::Yellow),
);
@ -201,18 +199,17 @@ impl CommandExecutor for BaseHelpExecutor {
}
let footer_text = format!(" Page {page}/{total_pages} ");
message = message
.add_child(
TextComponent::text_string("-".repeat((52 - footer_text.len() - 3) / 2) + " ")
.color_named(NamedColor::Yellow),
)
.add_child(arrow_left)
.add_child(TextComponent::text_string(footer_text.clone()))
.add_child(TextComponent::text(&footer_text))
.add_child(arrow_right)
.add_child(
TextComponent::text_string(
" ".to_owned().to_string() + &"-".repeat((52 - footer_text.len() - 3) / 2),
" ".to_owned() + &"-".repeat((52 - footer_text.len() - 3) / 2),
)
.color_named(NamedColor::Yellow),
);

View File

@ -14,7 +14,6 @@ use pumpkin_core::text::color::{Color, NamedColor};
use std::collections::{HashMap, HashSet};
#[derive(Debug)]
#[allow(dead_code)]
pub(crate) enum CommandError {
/// This error means that there was an error while parsing a previously consumed argument.
/// That only happens when consumption is wrongly implemented, as it should ensure parsing may
@ -92,7 +91,7 @@ impl<'a> CommandDispatcher<'a> {
let Some(key) = parts.next() else {
return Vec::new();
};
let raw_args: Vec<&str> = parts.rev().collect();
let mut raw_args: Vec<&str> = parts.rev().collect();
let Ok(tree) = self.get_tree(key) else {
return Vec::new();
@ -103,15 +102,8 @@ impl<'a> CommandDispatcher<'a> {
// try paths and collect the nodes that fail
// todo: make this more fine-grained
for path in tree.iter_paths() {
match Self::try_find_suggestions_on_path(
src,
server,
&path,
tree,
raw_args.clone(),
cmd,
)
.await
match Self::try_find_suggestions_on_path(src, server, &path, tree, &mut raw_args, cmd)
.await
{
Err(InvalidConsumption(s)) => {
log::error!("Error while parsing command \"{cmd}\": {s:?} was consumed, but couldn't be parsed");
@ -137,7 +129,7 @@ impl<'a> CommandDispatcher<'a> {
}
let mut suggestions = Vec::from_iter(suggestions);
suggestions.sort_by(|a, b| a.suggestion.cmp(&b.suggestion));
suggestions.sort_by(|a, b| a.suggestion.cmp(b.suggestion));
suggestions
}
@ -153,13 +145,13 @@ impl<'a> CommandDispatcher<'a> {
let key = parts
.next()
.ok_or(GeneralCommandIssue("Empty Command".to_string()))?;
let raw_args: Vec<&str> = parts.rev().collect();
let mut raw_args: Vec<&str> = parts.rev().collect();
let tree = self.get_tree(key)?;
// try paths until fitting path is found
for path in tree.iter_paths() {
if Self::try_is_fitting_path(src, server, &path, tree, raw_args.clone()).await? {
if Self::try_is_fitting_path(src, server, &path, tree, &mut raw_args).await? {
return Ok(());
}
}
@ -193,7 +185,7 @@ impl<'a> CommandDispatcher<'a> {
server: &'a Server,
path: &[usize],
tree: &CommandTree<'a>,
mut raw_args: RawArgs<'a>,
raw_args: &mut RawArgs<'a>,
) -> Result<bool, CommandError> {
let mut parsed_args: ConsumedArgs = HashMap::new();
@ -213,7 +205,7 @@ impl<'a> CommandDispatcher<'a> {
}
}
NodeType::Argument { consumer, name, .. } => {
match consumer.consume(src, server, &mut raw_args).await {
match consumer.consume(src, server, raw_args).await {
Some(consumed) => {
parsed_args.insert(name, consumed);
}
@ -236,7 +228,7 @@ impl<'a> CommandDispatcher<'a> {
server: &'a Server,
path: &[usize],
tree: &CommandTree<'a>,
mut raw_args: RawArgs<'a>,
raw_args: &mut RawArgs<'a>,
input: &'a str,
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
let mut parsed_args: ConsumedArgs = HashMap::new();
@ -252,7 +244,7 @@ impl<'a> CommandDispatcher<'a> {
}
}
NodeType::Argument { consumer, name } => {
match consumer.consume(src, server, &mut raw_args).await {
match consumer.consume(src, server, raw_args).await {
Some(consumed) => {
parsed_args.insert(name, consumed);
}