Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 90 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [
"server/template",
"server/chat",
"server/chunk",
"server/commands",
"server/config",
"server/entity",
"server/lighting",
Expand Down
2 changes: 1 addition & 1 deletion core/inventory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
feather-items = { path = "../items" }

fecs = { git = "https://github.com/feather-rs/fecs", rev = "fed8bcb516941b12cb980e354e77b699be075a89" }
fecs = { git = "https://github.com/feather-rs/fecs", rev = "0c4838d65b41ca059012b6e9147eabf0c275a731" }
legion = { git = "https://github.com/TomGillen/legion", rev = "bd441f4811e7a9e877a0f479a674bbdbf4e4cda3" }
thiserror = "1.0"
parking_lot = "0.10"
Expand Down
5 changes: 5 additions & 0 deletions core/network/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ static PACKET_ID_MAPPINGS: Lazy<AHashMap<PacketId, PacketType>> = Lazy::new(|| {
PacketType::CollectItem,
);

m.insert(
PacketId(0x50, PacketDirection::Clientbound, PacketStage::Play),
PacketType::EntityTeleport,
);

m
});

Expand Down
12 changes: 12 additions & 0 deletions core/network/src/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ pub static IMPL_MAP: Lazy<AHashMap<PacketType, PacketBuilder>> = Lazy::new(|| {
SpawnPosition,
TimeUpdate,
CollectItem,
EntityTeleport,
Response,
Pong,
);
Expand Down Expand Up @@ -2279,3 +2280,14 @@ pub struct CollectItem {
pub collector: VarInt,
pub count: VarInt,
}

#[derive(Default, AsAny, Packet, Clone)]
pub struct EntityTeleport {
pub entity_id: VarInt,
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: u8,
pub pitch: u8,
pub on_ground: bool,
}
45 changes: 26 additions & 19 deletions core/text/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::borrow::Cow;
use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
use uuid::Uuid;

Expand Down Expand Up @@ -64,7 +65,7 @@ impl From<Color> for Text {
}
}

#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Style {
Bold,
Expand Down Expand Up @@ -95,7 +96,7 @@ impl From<Style> for Text {
}
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
/// Represent all possible keybinds in vanilla.
pub enum Keybind {
Attack,
Expand All @@ -108,7 +109,7 @@ pub enum Keybind {
Sneak,
Sprint,
Drop,
Iventory,
Inventory,
Chat,
ListPlayers,
PickBlock,
Expand Down Expand Up @@ -176,7 +177,7 @@ where
"key_key.sneak" => Keybind::Sneak,
"key_key.sprint" => Keybind::Sprint,
"key_key.drop" => Keybind::Drop,
"key_key.inventory" => Keybind::Iventory,
"key_key.inventory" => Keybind::Inventory,
"key_key.chat" => Keybind::Chat,
"key_key.playerlist" => Keybind::ListPlayers,
"key_key.pickItem" => Keybind::PickBlock,
Expand Down Expand Up @@ -217,7 +218,7 @@ impl From<&Keybind> for String {
Keybind::Sneak => "key_key.sneak",
Keybind::Sprint => "key_key.sprint",
Keybind::Drop => "key_key.drop",
Keybind::Iventory => "key_key.inventory",
Keybind::Inventory => "key_key.inventory",
Keybind::Chat => "key_key.chat",
Keybind::ListPlayers => "key_key.playerlist",
Keybind::PickBlock => "key_key.pickItem",
Expand Down Expand Up @@ -246,7 +247,7 @@ impl From<&Keybind> for String {
}
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
/// Represent all possible translation keys in vanilla.
pub enum Translate {
ChatTypeText,
Expand Down Expand Up @@ -309,7 +310,7 @@ impl<'a> From<&Translate> for String {
}
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "action", content = "value")]
// TODO: Accept any json primitive as string
pub enum Click {
Expand All @@ -322,14 +323,14 @@ pub enum Click {
}

#[serde_with::skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Entity {
id: Uuid,
ty: Option<Cow<'static, str>>,
name: Cow<'static, str>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "action", content = "value")]
// TODO: Accept any json primitive as string
pub enum Hover {
Expand All @@ -342,7 +343,7 @@ pub enum Hover {
ShowEntity(Entity),
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
/// Text component can either be Text, Translate, Score, Selector, Keybind, or Nbt.
pub enum TextValue {
Expand Down Expand Up @@ -424,7 +425,7 @@ impl TextValue {
}

#[serde_with::skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
/// Text json object that holds all styles.
pub struct TextComponent {
#[serde(flatten)]
Expand Down Expand Up @@ -895,7 +896,7 @@ impl From<Text> for TextComponent {
}

/// Text can either be a json String, Object, or an Array.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Text {
String(Cow<'static, str>),
Expand Down Expand Up @@ -952,6 +953,18 @@ impl Text {
}
}

impl From<Text> for String {
fn from(text: Text) -> Self {
TextRoot(text).into()
}
}

impl Display for Text {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str(&serde_json::to_string(self).unwrap())
}
}

impl From<TextComponent> for Text {
fn from(component: TextComponent) -> Self {
Text::Component(Box::new(component))
Expand Down Expand Up @@ -994,19 +1007,13 @@ impl std::ops::Add<Text> for Text {
}
}

impl From<Text> for String {
fn from(text: Text) -> String {
serde_json::to_string(&text).unwrap()
}
}

/// Ensures Text is either an Array or Object.
/// This is required at some places when sending to the client.
pub struct TextRoot(Text);

impl From<TextRoot> for String {
fn from(text: TextRoot) -> String {
text.0.into()
text.0.to_string()
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/util/src/positions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ops::{Add, Sub};

#[macro_export]
macro_rules! position {
($x:expr, $y:expr, $z:expr, $pitch:expr, $yaw:expr, $on_ground:expr) => {
($x:expr, $y:expr, $z:expr, $pitch:expr, $yaw:expr, $on_ground:expr $(,)?) => {
$crate::Position {
x: $x,
y: $y,
Expand All @@ -16,13 +16,13 @@ macro_rules! position {
on_ground: $on_ground,
}
};
($x:expr, $y:expr, $z:expr, $pitch: expr, $yaw: expr) => {
($x:expr, $y:expr, $z:expr, $pitch: expr, $yaw: expr $(,)?) => {
position!($x, $y, $z, $pitch, $yaw, true)
};
($x:expr, $y:expr, $z:expr) => {
($x:expr, $y:expr, $z:expr $(,)?) => {
position!($x, $y, $z, 0.0, 0.0)
};
($x:expr, $y:expr, $z:expr, $on_ground: expr) => {
($x:expr, $y:expr, $z:expr, $on_ground: expr $(,)?) => {
position!($x, $y, $z, 0.0, 0.0, $on_ground)
};
}
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ feather-server-util = { path = "util" }
feather-server-weather = { path = "weather" }
feather-server-worldgen = { path = "worldgen" }

fecs = { git = "https://github.com/feather-rs/fecs", rev = "fed8bcb516941b12cb980e354e77b699be075a89" }
fecs = { git = "https://github.com/feather-rs/fecs", rev = "0c4838d65b41ca059012b6e9147eabf0c275a731" }
tokio = { version = "0.2", features = ["full"] }
simple_logger = "1.6"
log = "0.4"
Expand Down
Loading