aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-20 15:22:02 -0600
committermat <github@matdoes.dev>2021-12-20 15:22:02 -0600
commit6ae94b96e6d51e3bf251d4a01f17fa7d41c9500f (patch)
tree3153984562016e703eefd71b4b1de4151d47fdde /azalea-core/src
parentcf88c7b7956398eba2e0d6ed86dbf3268fdb512b (diff)
downloadazalea-drasl-6ae94b96e6d51e3bf251d4a01f17fa7d41c9500f.tar.xz
start adding nbt to the protocol
Diffstat (limited to 'azalea-core/src')
-rw-r--r--azalea-core/src/game_type.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/azalea-core/src/game_type.rs b/azalea-core/src/game_type.rs
index b0ca6a2d..61abf898 100644
--- a/azalea-core/src/game_type.rs
+++ b/azalea-core/src/game_type.rs
@@ -9,7 +9,7 @@ pub enum GameType {
}
impl GameType {
- fn to_id(&self) -> u8 {
+ pub fn to_id(&self) -> u8 {
match self {
GameType::SURVIVAL => 0,
GameType::CREATIVE => 1,
@@ -18,7 +18,15 @@ impl GameType {
}
}
- fn from_id(id: u8) -> GameType {
+ /// Get the id of the game type, but return -1 if the game type is invalid.
+ pub fn to_optional_id(game_type: &Option<GameType>) -> i8 {
+ match game_type {
+ Some(game_type) => game_type.to_id() as i8,
+ None => -1,
+ }
+ }
+
+ pub fn from_id(id: u8) -> GameType {
match id {
0 => GameType::SURVIVAL,
1 => GameType::CREATIVE,
@@ -28,7 +36,7 @@ impl GameType {
}
}
- fn short_name(&self) -> &'static str {
+ pub fn short_name(&self) -> &'static str {
// TODO: these should be translated TranslatableComponent("selectWorld.gameMode." + string2)
match self {
GameType::SURVIVAL => "Survival",
@@ -38,7 +46,7 @@ impl GameType {
}
}
- fn long_name(&self) -> &'static str {
+ pub fn long_name(&self) -> &'static str {
// TODO: These should be translated TranslatableComponent("gameMode." + string2);
match self {
GameType::SURVIVAL => "Survival Mode",
@@ -48,7 +56,7 @@ impl GameType {
}
}
- fn from_name(name: &str) -> GameType {
+ pub fn from_name(name: &str) -> GameType {
match name {
"survival" => GameType::SURVIVAL,
"creative" => GameType::CREATIVE,