This commit is contained in:
Snowiiii
2024-08-01 19:31:57 +02:00
parent b48d558112
commit b6d1dd7dfb
6 changed files with 27 additions and 22 deletions

3
Cargo.lock generated
View File

@@ -196,8 +196,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "fastnbt"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d4a73a95dc65551ccd98e1ecd1adb5d1ba5361146963b31f481ca42fc0520a3"
source = "git+https://github.com/owengage/fastnbt.git#0ea1a338671e51e62277645fbfffbdcaf2d2ec60"
dependencies = [
"byteorder",
"cesu8",

View File

@@ -29,7 +29,7 @@ mio = { version = "1.0.1", features = ["os-poll", "net"]}
crossbeam-channel = "0.5.13"
uuid = "1.10"
toml = "0.8.17"
fastnbt = "2.5.0"
fastnbt = { git = "https://github.com/owengage/fastnbt.git" }
fastsnbt = "0.2"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 835 KiB

View File

@@ -3,24 +3,24 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Dimension {
pub ambient_light: f32,
bed_works: bool,
bed_works: i32,
coordinate_scale: f64,
effects: DimensionEffects,
#[serde(skip_serializing_if = "Option::is_none")]
fixed_time: Option<i32>,
has_ceiling: bool,
has_raids: bool,
has_skylight: bool,
has_ceiling: i32,
has_raids: i32,
has_skylight: i32,
height: i32,
infiniburn: String,
logical_height: i32,
min_y: i32,
monster_spawn_block_light_limit: i32,
monster_spawn_light_level: MonsterSpawnLightLevel,
natural: bool,
piglin_safe: bool,
respawn_anchor_works: bool,
ultrawarm: bool,
natural: i32,
piglin_safe: i32,
respawn_anchor_works: i32,
ultrawarm: i32,
}
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, Debug)]
@@ -38,23 +38,23 @@ impl Default for Dimension {
fn default() -> Self {
Self {
ambient_light: 0.0,
bed_works: true,
bed_works: 1,
coordinate_scale: 1.0,
effects: DimensionEffects::default(),
fixed_time: None,
has_ceiling: false,
has_raids: true,
has_skylight: true,
has_ceiling: 0,
has_raids: 1,
has_skylight: 1,
height: 384,
infiniburn: "#minecraft:infiniburn_overworld".into(),
logical_height: 384,
min_y: -64,
monster_spawn_block_light_limit: 0,
monster_spawn_light_level: MonsterSpawnLightLevel::Int(7),
natural: true,
piglin_safe: false,
respawn_anchor_works: false,
ultrawarm: false,
natural: 1,
piglin_safe: 0,
respawn_anchor_works: 0,
ultrawarm: 0,
}
}
}

View File

@@ -1,4 +1,9 @@
use dimensions::Dimension;
use core::str;
use std::{fs::File, io::Read};
use dimensions::{Dimension, DimensionEffects, MonsterSpawnLightLevel};
use fastnbt::{nbt, to_bytes_with_opts, SerOpts};
use flate2::read::GzDecoder;
use serde::Serialize;
use super::bytebuf::ByteBuffer;
@@ -59,8 +64,8 @@ pub fn write_codec(out: &mut ByteBuffer, world_min_y: i32, world_height: u32) {
}, */
};
let val = &fastsnbt::to_string(&info).unwrap();
let val = &fastnbt::to_bytes_with_opts(&info, SerOpts::network_nbt()).unwrap();
dbg!(val);
// Dimension codec
out.put_string(val);
out.put_slice(val);
}

View File

@@ -118,6 +118,7 @@ impl Server {
))
.unwrap_or_else(|e| client.kick(&e.to_string()));
dbg!("spawning player");
client.player = Some(player);
}