Skip to content

Commit 271700f

Browse files
authored
Merge branch 'master' into master
2 parents f61c9df + d1f87bd commit 271700f

File tree

16 files changed

+477
-228
lines changed

16 files changed

+477
-228
lines changed

Cargo.toml

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -115,101 +115,102 @@ ferrumc-world-gen = { path = "src/lib/world_gen" }
115115
ferrumc-inventories = { path = "src/lib/inventories" }
116116

117117
# Asynchronous
118-
tokio = { version = "1.47.1", features = ["macros", "net", "rt", "sync", "time", "io-util", "test-util"], default-features = false }
118+
tokio = { version = "1.48.0", features = ["macros", "net", "rt", "sync", "time", "io-util", "test-util"], default-features = false }
119119

120120
# Logging
121121
tracing = "0.1.41"
122-
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
122+
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
123123
tracing-appender = "0.2.3"
124-
log = "0.4.27"
125-
console-subscriber = "0.4.1"
124+
log = "0.4.28"
126125

127126
# Concurrency/Parallelism
128-
parking_lot = "0.12.4"
127+
parking_lot = "0.12.5"
129128
rayon = "1.11.0"
130129
crossbeam-channel = "0.5.15"
131130
rusty_pool = "0.7.0"
132131
crossbeam-queue = "0.3.12"
133132

134133
# Network
135-
reqwest = { version = "0.12.22", features = ["json"] }
136-
ureq = "3.1.0"
134+
ureq = "3.1.2"
137135

138136
# Error handling
139-
thiserror = "2.0.15"
137+
thiserror = "2.0.17"
140138

141139
# Cryptography
142-
rand = "0.9.2"
140+
rand = "0.10.0-rc.0"
143141
fnv = "1.0.7"
144142
wyhash = "0.6.0"
145143
ahash = "0.8.12"
146144

147145
# Encoding/Serialization
148-
serde = { version = "1.0.219", features = ["derive"] }
149-
serde_json = "1.0.142"
150-
serde_derive = "1.0.219"
151-
serde_yaml_ng = "0.9.36"
146+
serde = { version = "1.0.228", features = ["derive"] }
147+
serde_json = "1.0.145"
148+
serde_derive = "1.0.228"
152149
base64 = "0.22.1"
153-
bitcode = "0.6.7"
154-
bitcode_derive = "0.6.7"
155-
toml = "0.9.5"
150+
151+
# When if bitcode's latest version has been changed, see if clippy still complains about
152+
# src/lib/net/src/packets/outgoing/chunk_and_light_data.rs
153+
#bitcode = "0.6.7"
154+
#bitcode_derive = "0.6.7"
155+
toml = "0.9.8"
156156
craftflow-nbt = "2.1.0"
157157
figment = { version = "0.10.19", features = ["toml", "env"] }
158-
simd-json = "0.15.1"
158+
simd-json = "0.17.0"
159159

160160
# Bit manipulation
161161
byteorder = "1.5.0"
162162

163163
# Data types
164164
dashmap = "7.0.0-rc2"
165-
uuid = { version = "1.18.0", features = ["v4", "v3", "serde"] }
166-
indexmap = { version = "2.10.0", features = ["serde"] }
165+
uuid = { version = "1.18.1", features = ["v4", "v3", "serde"] }
166+
indexmap = { version = "2.12.0", features = ["serde"] }
167167

168168
# Macros
169169
lazy_static = "1.5.0"
170-
quote = "1.0.40"
170+
quote = "1.0.41"
171171
syn = "2.0.106"
172172
proc-macro2 = "1.0.101"
173-
proc-macro-crate = "3.3.0"
174173
paste = "1.0.15"
175174
maplit = "1.0.2"
176175
macro_rules_attribute = "0.2.2"
177176

178177
# Magic
179178
dhat = "0.3.3"
180-
ctor = "0.4.2"
179+
ctor = "0.6.0"
181180

182181
# Compression/Decompression
183-
flate2 = { version = "1.1.2", features = ["zlib"], default-features = false }
182+
flate2 = { version = "1.1.4", features = ["zlib"], default-features = false }
184183
lzzzz = "2.0.0"
185184
yazi = "0.2.1"
186-
bzip2 = "0.6.0"
187-
lz4_flex = "0.11.5"
188185

189186
# Database
190187
heed = "0.22.0"
191-
moka = "0.12.10"
188+
moka = "0.12.11"
192189

193190
# CLI
194-
clap = "4.5.45"
191+
clap = "4.5.49"
195192
indicatif = "0.18.0"
196193
colored = "3.0.0"
197194

198195
# Misc
199196
deepsize = "0.2.0"
200197
page_size = "0.6.0"
201198
enum-ordinalize = "4.3.0"
202-
regex = "1.11.1"
199+
regex = "1.12.2"
203200
noise = "0.9.0"
204-
ctrlc = "3.4.7"
201+
ctrlc = "3.5.0"
205202
num_cpus = "1.17.0"
206203
typename = "0.1.2"
207204
bevy_ecs = { version = "0.16.1", features = ["multi_threaded", "trace"] }
208205
once_cell = "1.21.3"
209206

210207
# I/O
211-
memmap2 = "0.9.7"
212-
tempfile = "3.20.0"
208+
memmap2 = "0.9.8"
209+
tempfile = "3.23.0"
213210

214211
# Benchmarking
215212
criterion = { version = "0.7.0", features = ["html_reports"] }
213+
214+
215+
bitcode = { git = "https://github.com/SoftbearStudios/bitcode" }
216+
bitcode_derive = { git = "https://github.com/SoftbearStudios/bitcode" }

src/bin/src/packet_handlers/play_packets/place_block.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tracing::{debug, error, trace};
1414

1515
use ferrumc_inventories::hotbar::Hotbar;
1616
use ferrumc_inventories::inventory::Inventory;
17+
use ferrumc_world::block_id::BlockId;
1718
use once_cell::sync::Lazy;
1819
use std::collections::HashMap;
1920
use std::str::FromStr;
@@ -128,9 +129,12 @@ pub fn handle(
128129
continue 'ev_loop;
129130
}
130131

131-
if let Err(err) =
132-
chunk.set_block(x & 0xF, y as i32, z & 0xF, VarInt::new(*mapped_block_id))
133-
{
132+
if let Err(err) = chunk.set_block(
133+
x & 0xF,
134+
y as i32,
135+
z & 0xF,
136+
BlockId(*mapped_block_id as u32),
137+
) {
134138
error!("Failed to set block: {:?}", err);
135139
continue 'ev_loop;
136140
}

src/bin/src/packet_handlers/play_packets/player_action.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use ferrumc_net::PlayerActionReceiver;
99
use ferrumc_net_codec::net_types::var_int::VarInt;
1010
use ferrumc_state::GlobalStateResource;
1111
use ferrumc_world::block_id::BlockId;
12-
use ferrumc_world::vanilla_chunk_format::BlockData;
1312
use tracing::{debug, error, trace};
1413

1514
pub fn handle(
@@ -42,7 +41,7 @@ pub fn handle(
4241
event.location.y as i32,
4342
event.location.z.abs() % 16,
4443
);
45-
chunk.set_block(relative_x, relative_y, relative_z, BlockData::default())?;
44+
chunk.set_block(relative_x, relative_y, relative_z, BlockId::default())?;
4645
// Save the chunk to disk
4746
state.0.world.save_chunk(Arc::new(chunk))?;
4847
for (eid, conn) in query {

src/lib/derive_macros/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ regex = { workspace = true }
2121
craftflow-nbt = { workspace = true }
2222
indexmap = { workspace = true, features = ["serde"] }
2323
bitcode = { workspace = true }
24+
simd-json = { workspace = true }
25+
26+
[dev-dependencies]
27+
ferrumc-world = { workspace = true }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use crate::block::JSON_FILE;
2+
use proc_macro::TokenStream;
3+
use quote::quote;
4+
use simd_json::base::{ValueAsObject, ValueAsScalar};
5+
use simd_json::derived::ValueObjectAccess;
6+
7+
struct Input {
8+
name: String,
9+
id_var: syn::Expr,
10+
}
11+
12+
impl syn::parse::Parse for Input {
13+
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
14+
let name_lit: syn::LitStr = input.parse()?;
15+
let _comma: syn::Token![,] = input.parse()?;
16+
let id_var: syn::Expr = input.parse()?;
17+
Ok(Input {
18+
name: name_lit.value(),
19+
id_var,
20+
})
21+
}
22+
}
23+
24+
// match_block!("stone", block_id); -> "if block_id == BlockId(1) { ... }
25+
// match_block!("dirt", block_id); -> "if block_name == BlockId( { ... }
26+
pub fn matches_block(input: TokenStream) -> TokenStream {
27+
let input = syn::parse_macro_input!(input as Input);
28+
let block_name = &input.name;
29+
let block_name = if block_name.starts_with("minecraft:") {
30+
block_name.to_string()
31+
} else {
32+
format!("minecraft:{}", block_name)
33+
};
34+
let block_id_var = &input.id_var;
35+
let mut buf = JSON_FILE.to_vec();
36+
let v = simd_json::to_owned_value(&mut buf).unwrap();
37+
let filtered_names = v
38+
.as_object()
39+
.unwrap()
40+
.iter()
41+
.filter(|(_, v)| v.get("name").as_str() == Some(&block_name))
42+
.map(|(k, v)| (k.parse::<u32>().unwrap(), v))
43+
.collect::<Vec<_>>();
44+
if filtered_names.is_empty() {
45+
return syn::Error::new_spanned(
46+
&input.id_var,
47+
format!("Block name '{}' not found in registry", block_name),
48+
)
49+
.to_compile_error()
50+
.into();
51+
}
52+
let mut arms = Vec::new();
53+
for (id, _) in filtered_names {
54+
arms.push(quote! {
55+
#block_id_var == BlockId(#id)
56+
});
57+
}
58+
let joined = quote! {
59+
#(#arms)||*
60+
};
61+
joined.into()
62+
}

0 commit comments

Comments
 (0)