Skip to content

Commit b1b2a31

Browse files
committed
fix: vanilla level.dat loading
1 parent e480f32 commit b1b2a31

82 files changed

Lines changed: 2083 additions & 599 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
and customizable experience. It prioritizes performance and player enjoyment while adhering to the core mechanics of the game.
1313
<div align="center">
1414

15-
![chunk loading](/assets/pumpkin_chunk_loading.webp)
15+
<video src="/assets/pumpkin_chunk_loading.webm" autoplay loop muted playsinline>
16+
Your browser does not support the video tag.
17+
</video>
1618

1719
</div>
1820

assets/pumpkin_chunk_loading.webm

10.8 MB
Binary file not shown.

assets/pumpkin_chunk_loading.webp

-22.9 MB
Binary file not shown.

pumpkin-config/src/chunk.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55
/// Configuration for chunk storage format.
66
///
77
/// Supports multiple chunk formats, currently `Anvil` and `Linear`.
8-
#[derive(Deserialize, Default, Serialize, Clone)]
8+
#[derive(Deserialize, Serialize, Clone)]
99
#[serde(tag = "type")]
1010
pub enum ChunkConfig {
1111
/// Standard Anvil chunk storage.
@@ -16,10 +16,15 @@ pub enum ChunkConfig {
1616
Linear,
1717
/// Pumpkin's own optimized world format.
1818
#[serde(rename = "pump")]
19-
#[default]
2019
Pump,
2120
}
2221

22+
impl Default for ChunkConfig {
23+
fn default() -> Self {
24+
Self::Anvil(AnvilChunkConfig::default())
25+
}
26+
}
27+
2328
/// Configuration for Anvil chunk storage.
2429
#[derive(Deserialize, Serialize, Default, Clone)]
2530
#[serde(default)]

pumpkin-config/src/lib.rs

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use pumpkin_util::{Difficulty, GameMode, PermissionLvl, random};
55
use recipe::RecipeConfig;
66
use serde::{Deserialize, Serialize, de::DeserializeOwned};
77

8-
use std::net::SocketAddr;
98
use std::path::PathBuf;
109
use std::{fs, num::NonZeroU8, path::Path};
1110
use tracing::{debug, warn};
@@ -20,7 +19,9 @@ pub mod resource_pack;
2019
pub use chat::ChatConfig;
2120
pub use commands::CommandsConfig;
2221
pub use networking::auth::AuthenticationConfig;
22+
pub use networking::bedrock::BedrockConfig;
2323
pub use networking::compression::CompressionConfig;
24+
pub use networking::java::JavaConfig;
2425
pub use networking::lan_broadcast::LANBroadcastConfig;
2526
pub use networking::rcon::RCONConfig;
2627
pub use plugins::PluginsConfig;
@@ -64,6 +65,48 @@ impl LoadConfiguration for PumpkinConfig {
6465
fn validate(&self) {
6566
self.basic.validate();
6667
self.advanced.validate();
68+
69+
let min_vd = NonZeroU8::new(2).unwrap();
70+
let max_vd = NonZeroU8::new(64).unwrap();
71+
72+
// Validate Java
73+
assert!(
74+
self.advanced.networking.java.view_distance >= min_vd,
75+
"Java View distance must be at least 2"
76+
);
77+
assert!(
78+
self.advanced.networking.java.view_distance <= max_vd,
79+
"Java View distance must be less than 64"
80+
);
81+
if self.advanced.networking.java.online_mode {
82+
assert!(
83+
self.advanced.networking.java.encryption,
84+
"When online mode is enabled, encryption must be enabled"
85+
);
86+
}
87+
88+
// Validate Bedrock
89+
assert!(
90+
self.advanced.networking.bedrock.view_distance >= min_vd,
91+
"Bedrock View distance must be at least 2"
92+
);
93+
assert!(
94+
self.advanced.networking.bedrock.view_distance <= max_vd,
95+
"Bedrock View distance must be less than 64"
96+
);
97+
if self.advanced.networking.bedrock.online_mode {
98+
assert!(
99+
self.advanced.networking.bedrock.encryption,
100+
"When online mode is enabled, bedrock_encryption must be enabled"
101+
);
102+
}
103+
104+
if self.basic.allow_chat_reports {
105+
assert!(
106+
self.advanced.networking.java.online_mode,
107+
"When allow_chat_reports is enabled, java.online_mode must be enabled"
108+
);
109+
}
67110
}
68111
}
69112

@@ -110,24 +153,8 @@ pub struct AdvancedConfiguration {
110153
#[derive(Serialize, Deserialize)]
111154
#[serde(default)]
112155
pub struct BasicConfiguration {
113-
/// Whether Java Edition Clients are Accepted.
114-
pub java_edition: bool,
115-
/// The address and port to which the Java Edition server will bind.
116-
pub java_edition_address: SocketAddr,
117-
/// Whether Bedrock Edition Clients are Accepted.
118-
pub bedrock_edition: bool,
119-
/// Whether Bedrock Edition Clients are Accepted.
120-
pub bedrock_edition_address: SocketAddr,
121-
/// Whether packet encryption is enabled for Bedrock Edition.
122-
pub bedrock_encryption: bool,
123156
/// The seed for the world generation.
124157
pub seed: Seed,
125-
/// The maximum number of players allowed on the server. Specifying `0` disables the limit.
126-
pub max_players: u32,
127-
/// The maximum view distance for players.
128-
pub view_distance: NonZeroU8,
129-
/// The maximum simulated view distance.
130-
pub simulation_distance: NonZeroU8,
131158
/// The default game difficulty.
132159
pub default_difficulty: Difficulty,
133160
/// The op level assigned by the /op command.
@@ -138,12 +165,6 @@ pub struct BasicConfiguration {
138165
pub allow_end: bool,
139166
/// Whether the server is in hardcore mode.
140167
pub hardcore: bool,
141-
/// Whether online mode is enabled. Requires valid Minecraft accounts.
142-
pub online_mode: bool,
143-
/// Whether packet encryption is enabled. Required when online mode is enabled.
144-
pub encryption: bool,
145-
/// Message of the Day; the server's description displayed on the status screen.
146-
pub motd: String,
147168
/// The server's ticks per second.
148169
pub tps: f32,
149170
/// The default gamemode for players.
@@ -169,23 +190,12 @@ pub struct BasicConfiguration {
169190
impl Default for BasicConfiguration {
170191
fn default() -> Self {
171192
Self {
172-
java_edition: true,
173-
java_edition_address: "0.0.0.0:25565".parse().unwrap(),
174-
bedrock_edition: true,
175-
bedrock_edition_address: "0.0.0.0:19132".parse().unwrap(),
176-
bedrock_encryption: true,
177193
seed: Seed(random::get_seed()),
178-
max_players: 1000,
179-
view_distance: NonZeroU8::new(16).unwrap(),
180-
simulation_distance: NonZeroU8::new(10).unwrap(),
181194
default_difficulty: Difficulty::Normal,
182195
op_permission_level: PermissionLvl::Four,
183196
allow_nether: true,
184197
allow_end: true,
185198
hardcore: false,
186-
online_mode: true,
187-
encryption: true,
188-
motd: "A blazingly fast Pumpkin server!".to_string(),
189199
tps: 20.0,
190200
default_gamemode: GameMode::Survival,
191201
force_gamemode: false,
@@ -207,35 +217,7 @@ impl BasicConfiguration {
207217
PathBuf::from(&self.default_level_name)
208218
}
209219

210-
pub fn validate(&self) {
211-
let min = NonZeroU8::new(2).unwrap();
212-
let max = NonZeroU8::new(64).unwrap();
213-
214-
assert!(
215-
self.view_distance.ge(&min),
216-
"View distance must be at least 2"
217-
);
218-
assert!(
219-
self.view_distance.le(&max),
220-
"View distance must be less than 64"
221-
);
222-
if self.online_mode {
223-
assert!(
224-
self.encryption,
225-
"When online mode is enabled, encryption must be enabled"
226-
);
227-
assert!(
228-
self.bedrock_encryption,
229-
"When online mode is enabled, bedrock_encryption must be enabled"
230-
);
231-
}
232-
if self.allow_chat_reports {
233-
assert!(
234-
self.online_mode,
235-
"When allow_chat_reports is enabled, online_mode must be enabled"
236-
);
237-
}
238-
}
220+
pub const fn validate(&self) {}
239221
}
240222

241223
impl AdvancedConfiguration {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
use crate::CompressionConfig;
2+
use serde::{Deserialize, Serialize};
3+
use std::net::SocketAddr;
4+
use std::num::NonZeroU8;
5+
6+
/// Configuration for Bedrock authentication.
7+
#[derive(Deserialize, Serialize, Clone)]
8+
#[serde(default)]
9+
pub struct BedrockAuthenticationConfig {
10+
/// Whether Xbox Live authentication is enabled/enforced.
11+
pub enabled: bool,
12+
/// Optional custom authentication/discovery URL.
13+
pub url: Option<String>,
14+
/// Connection timeout in milliseconds.
15+
pub connect_timeout: u32,
16+
/// Read timeout in milliseconds.
17+
pub read_timeout: u32,
18+
}
19+
20+
impl Default for BedrockAuthenticationConfig {
21+
fn default() -> Self {
22+
Self {
23+
enabled: true,
24+
url: None,
25+
connect_timeout: 5000,
26+
read_timeout: 5000,
27+
}
28+
}
29+
}
30+
31+
/// Configuration for Bedrock Edition client connections.
32+
#[derive(Deserialize, Serialize, Clone)]
33+
#[serde(default)]
34+
pub struct BedrockConfig {
35+
/// Whether Bedrock Edition Clients are Accepted.
36+
pub enabled: bool,
37+
/// Whether Bedrock Edition Clients are Accepted.
38+
pub address: SocketAddr,
39+
/// Whether packet encryption is enabled for Bedrock Edition.
40+
pub encryption: bool,
41+
/// Whether online mode is enabled.
42+
pub online_mode: bool,
43+
/// The maximum number of players allowed on the server. Specifying `0` disables the limit.
44+
pub max_players: u32,
45+
/// The maximum view distance for players.
46+
pub view_distance: NonZeroU8,
47+
/// The maximum simulated view distance.
48+
pub simulation_distance: NonZeroU8,
49+
/// Bedrock Edition packet compression settings.
50+
pub compression: CompressionConfig,
51+
/// Message of the Day; the server's description displayed on the status screen.
52+
pub motd: String,
53+
/// Bedrock Edition authentication settings.
54+
pub authentication: BedrockAuthenticationConfig,
55+
}
56+
57+
impl Default for BedrockConfig {
58+
fn default() -> Self {
59+
Self {
60+
enabled: true,
61+
address: "0.0.0.0:19132".parse().unwrap(),
62+
encryption: true,
63+
online_mode: true,
64+
max_players: 1000,
65+
view_distance: NonZeroU8::new(16).unwrap(),
66+
simulation_distance: NonZeroU8::new(10).unwrap(),
67+
compression: CompressionConfig::default(),
68+
motd: "A blazingly fast Pumpkin server!".to_string(),
69+
authentication: BedrockAuthenticationConfig::default(),
70+
}
71+
}
72+
}

pumpkin-config/src/networking/compression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
33
/// Configuration for packet compression.
44
///
55
/// Controls whether network packet compression is enabled and the compression parameters.
6-
#[derive(Deserialize, Serialize)]
6+
#[derive(Deserialize, Serialize, Clone)]
77
#[serde(default)]
88
pub struct CompressionConfig {
99
/// Whether compression is enabled.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use crate::{AuthenticationConfig, CompressionConfig};
2+
use serde::{Deserialize, Serialize};
3+
use std::net::SocketAddr;
4+
use std::num::NonZeroU8;
5+
6+
/// Configuration for Java Edition client connections.
7+
#[derive(Deserialize, Serialize, Clone)]
8+
#[serde(default)]
9+
pub struct JavaConfig {
10+
/// Whether Java Edition Clients are Accepted.
11+
pub enabled: bool,
12+
/// The address and port to which the Java Edition server will bind.
13+
pub address: SocketAddr,
14+
/// Whether packet encryption is enabled. Required when online mode is enabled.
15+
pub encryption: bool,
16+
/// Whether online mode is enabled. Requires valid Minecraft accounts.
17+
pub online_mode: bool,
18+
/// The maximum number of players allowed on the server. Specifying `0` disables the limit.
19+
pub max_players: u32,
20+
/// The maximum view distance for players.
21+
pub view_distance: NonZeroU8,
22+
/// The maximum simulated view distance.
23+
pub simulation_distance: NonZeroU8,
24+
/// Java Edition packet compression settings.
25+
pub compression: CompressionConfig,
26+
/// Message of the Day; the server's description displayed on the status screen.
27+
pub motd: String,
28+
/// Authentication settings for client connections.
29+
pub authentication: AuthenticationConfig,
30+
}
31+
32+
impl Default for JavaConfig {
33+
fn default() -> Self {
34+
Self {
35+
enabled: true,
36+
address: "0.0.0.0:25565".parse().unwrap(),
37+
encryption: true,
38+
online_mode: true,
39+
max_players: 1000,
40+
view_distance: NonZeroU8::new(16).unwrap(),
41+
simulation_distance: NonZeroU8::new(10).unwrap(),
42+
compression: CompressionConfig::default(),
43+
motd: "A blazingly fast Pumpkin server!".to_string(),
44+
authentication: AuthenticationConfig::default(),
45+
}
46+
}
47+
}
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
use auth::AuthenticationConfig;
21
use proxy::ProxyConfig;
32
use query::QueryConfig;
43
use rcon::RCONConfig;
54
use serde::{Deserialize, Serialize};
65

7-
use crate::{CompressionConfig, LANBroadcastConfig};
6+
use crate::LANBroadcastConfig;
7+
use bedrock::BedrockConfig;
8+
use java::JavaConfig;
89

910
pub mod auth;
11+
pub mod bedrock;
1012
pub mod compression;
13+
pub mod java;
1114
pub mod lan_broadcast;
1215
pub mod proxy;
1316
pub mod query;
@@ -18,19 +21,18 @@ pub mod rcon;
1821
/// Covers authentication, query, RCON, proxying, packet compression,
1922
/// and LAN broadcast behaviour.
2023
#[derive(Deserialize, Serialize, Default)]
24+
#[serde(default)]
2125
pub struct NetworkingConfig {
22-
/// Authentication settings for client connections.
23-
pub authentication: AuthenticationConfig,
2426
/// Query protocol settings for server status requests.
2527
pub query: QueryConfig,
2628
/// RCON (remote console) configuration.
2729
pub rcon: RCONConfig,
2830
/// Proxy-related networking settings.
2931
pub proxy: ProxyConfig,
30-
/// Java Edition packet compression settings.
31-
pub java_compression: CompressionConfig,
32-
/// Bedrock Edition packet compression settings.
33-
pub bedrock_compression: CompressionConfig,
3432
/// LAN broadcast settings.
3533
pub lan_broadcast: LANBroadcastConfig,
34+
/// Java Edition configuration settings.
35+
pub java: JavaConfig,
36+
/// Bedrock Edition configuration settings.
37+
pub bedrock: BedrockConfig,
3638
}

pumpkin-protocol/src/bedrock/client/raknet/unconnected_pong.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl PacketWrite for CUnconnectedPong {
2626
pub struct ServerInfo {
2727
/// (BE or MCEE for Education Edition)
2828
pub edition: &'static str,
29-
pub motd_line_1: &'static str,
29+
pub motd_line_1: String,
3030
pub protocol_version: u32,
3131
pub version_name: &'static str,
3232
pub player_count: i32,

0 commit comments

Comments
 (0)