Skip to content

Commit e5269d3

Browse files
committed
refactor: Implement Batch struct to lazily build and send packets
1 parent 931d16a commit e5269d3

21 files changed

+491
-643
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use blocks_report::ReportIdMapping;
22
use minecraft_protocol::prelude::{Coordinates, Dimension};
33
use pico_structures::prelude::World;
4+
use std::sync::Arc;
45

56
pub struct VoidChunkContext {
67
pub chunk_x: i32,
@@ -9,8 +10,8 @@ pub struct VoidChunkContext {
910
pub dimension: Dimension,
1011
}
1112

12-
pub struct WorldContext<'a> {
13-
pub world: &'a World,
13+
pub struct WorldContext {
14+
pub world: Arc<World>,
1415
pub paste_origin: Coordinates,
15-
pub report_id_mapping: &'a ReportIdMapping,
16+
pub report_id_mapping: Arc<ReportIdMapping>,
1617
}

crates/minecraft_packets/src/play/data/chunk_section.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ impl ChunkSection {
3030
biome_id: i32,
3131
) -> ChunkSection {
3232
if let Some(palette) = context.world.get_section(&section_position) {
33-
let block_states = PaletteContainer::from_palette(palette, context.report_id_mapping);
33+
let block_states =
34+
PaletteContainer::from_palette(palette, context.report_id_mapping.as_ref());
3435
let biomes = PaletteContainer::single_valued(biome_id);
3536

3637
ChunkSection {

0 commit comments

Comments
 (0)