Add BlockFace
This commit is contained in:
parent
91533c30df
commit
40fe40355f
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1303,6 +1303,8 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"num-derive",
|
||||||
|
"num-traits",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@ -16,3 +16,6 @@ flate2 = "1.0.31"
|
|||||||
serde = { version = "1.0.205", features = ["derive"] }
|
serde = { version = "1.0.205", features = ["derive"] }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
serde_json = "1.0.122"
|
serde_json = "1.0.122"
|
||||||
|
|
||||||
|
num-traits = "0.2"
|
||||||
|
num-derive = "0.4"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use lazy_static::lazy_static;
|
|||||||
|
|
||||||
use crate::world::WorldError;
|
use crate::world::WorldError;
|
||||||
|
|
||||||
const BLOCKS_JSON: &str = include_str!("../assets/blocks.json");
|
const BLOCKS_JSON: &str = include_str!("../../assets/blocks.json");
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
struct BlockDefinition {
|
struct BlockDefinition {
|
||||||
13
pumpkin-world/src/block/mod.rs
Normal file
13
pumpkin-world/src/block/mod.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use num_derive::FromPrimitive;
|
||||||
|
|
||||||
|
pub mod block_registry;
|
||||||
|
|
||||||
|
#[derive(FromPrimitive)]
|
||||||
|
pub enum BlockFace {
|
||||||
|
Bottom = 0,
|
||||||
|
Top,
|
||||||
|
North,
|
||||||
|
South,
|
||||||
|
West,
|
||||||
|
East,
|
||||||
|
}
|
||||||
@ -92,7 +92,7 @@ impl ChunkData {
|
|||||||
.palette
|
.palette
|
||||||
.iter()
|
.iter()
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
crate::block_registry::block_id_and_properties_to_block_state_id(
|
crate::block::block_registry::block_id_and_properties_to_block_state_id(
|
||||||
&entry.name,
|
&entry.name,
|
||||||
entry.properties.as_ref(),
|
entry.properties.as_ref(),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,6 +3,6 @@ pub mod dimension;
|
|||||||
pub const WORLD_HEIGHT: usize = 384;
|
pub const WORLD_HEIGHT: usize = 384;
|
||||||
pub const WORLD_Y_START_AT: i32 = -64;
|
pub const WORLD_Y_START_AT: i32 = -64;
|
||||||
pub const DIRECT_PALETTE_BITS: u32 = 15;
|
pub const DIRECT_PALETTE_BITS: u32 = 15;
|
||||||
mod block_registry;
|
mod block;
|
||||||
pub mod radial_chunk_iterator;
|
pub mod radial_chunk_iterator;
|
||||||
mod world;
|
mod world;
|
||||||
|
|||||||
@ -2,8 +2,8 @@ use num_traits::FromPrimitive;
|
|||||||
use pumpkin_entity::EntityId;
|
use pumpkin_entity::EntityId;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::play::{
|
client::play::{
|
||||||
Animation, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
Animation, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation, CSystemChatMessge,
|
||||||
CSystemChatMessge, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot,
|
||||||
},
|
},
|
||||||
server::play::{
|
server::play::{
|
||||||
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
Action, SChatCommand, SChatMessage, SClientInformationPlay, SConfirmTeleport, SInteract,
|
||||||
|
|||||||
@ -339,7 +339,7 @@ impl Server {
|
|||||||
// TODO: do this in a world
|
// TODO: do this in a world
|
||||||
async fn spawn_test_chunk(client: &mut Client, distance: u32) {
|
async fn spawn_test_chunk(client: &mut Client, distance: u32) {
|
||||||
let inst = std::time::Instant::now();
|
let inst = std::time::Instant::now();
|
||||||
let (sender, mut chunk_receiver) = mpsc::channel(1024);
|
let (sender, mut chunk_receiver) = mpsc::channel(distance as usize);
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let level = Dimension::OverWorld.into_level(
|
let level = Dimension::OverWorld.into_level(
|
||||||
// TODO: load form config
|
// TODO: load form config
|
||||||
@ -375,7 +375,7 @@ impl Server {
|
|||||||
}
|
}
|
||||||
client.send_packet(&CChunkData(&chunk_data));
|
client.send_packet(&CChunkData(&chunk_data));
|
||||||
}
|
}
|
||||||
let t = std::time::Instant::now().duration_since(inst);
|
let t = inst.elapsed();
|
||||||
dbg!("DONE", t);
|
dbg!("DONE", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user